Created
January 21, 2013 21:13
-
-
Save acmorrow/4589450 to your computer and use it in GitHub Desktop.
Using std::pair to return an error code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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