How it works...

All the functions mentioned in this recipe, and other similar functions that are not discussed here, have multiple overloads grouped in two categories:

  • Overloads that take as a last argument a reference to an std::error_code: these overloads do not throw an exception (they are defined with the noexcept specification), but instead set the value of the error_code object to the operating system error code, if an operating system error occurred. If no such error occurred, then the clear() method on the error_code object is called to reset any possible previously set code.
  • Overloads that do not take the last argument of the std::error_code type: these overloads throw exceptions if errors occur. If an operating system error occurs, ...

Get Modern C++ Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.