Skip to content

Instantly share code, notes, and snippets.

@alexander-somov
Created August 27, 2017 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexander-somov/90e4fadc92e7e66c57940de6264ecb61 to your computer and use it in GitHub Desktop.
Save alexander-somov/90e4fadc92e7e66c57940de6264ecb61 to your computer and use it in GitHub Desktop.
libstdc++ system_error failure sample
#include <iostream>
#include <system_error>
using namespace std;
void Test1() {
const auto value = errc::no_such_file_or_directory;
const auto code = make_error_code(value);
cout << "value == code: " << (value == code) << "\n";
}
void Test2() {
error_condition ec = make_error_condition(errc::no_such_file_or_directory);
auto ec2 = ec.category().default_error_condition(ec.value());
auto ec3 = ec2.category().default_error_condition(ec.value());
cout << ec3.category().name() << endl;
}
int main() {
Test1();
Test2();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment