#include#include int main() { boost::system::error_code ec; std::cout << "Error code value = " << ec.value() << "\n"; std::cout << "Error message = " << ec.message() << "\n"; return 0; }
#includeIn the above example, an error_code object is created and passed as a reference to the foo() function. The function sets an error code and returns it via the reference parameter. The main() function checks if an error was set and prints the error message if one is found. The package library for the boost.system error_code is Boost C++ Libraries.#include void foo(boost::system::error_code& ec) { // Perform some operation that sets an error code ec = boost::system::errc::no_such_file_or_directory; } int main() { boost::system::error_code ec; foo(ec); if (ec) { std::cout << "Error: " << ec.message() << "\n"; } return 0; }