Skip to content

Instantly share code, notes, and snippets.

@acmorrow
Created January 21, 2013 21:13
Show Gist options
  • Save acmorrow/4589450 to your computer and use it in GitHub Desktop.
Save acmorrow/4589450 to your computer and use it in GitHub Desktop.
Using std::pair to return an error code.
// Promising
std::pair<Status, Foo*> makeAFoo(int param1, int param2);
std::pair<Status, Foo*> result = makeAFoo(42, 0);
if (result.first) {
result.second->doSomething();
} else {
// handle error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment