Created
May 18, 2014 10:01
-
-
Save kybernetyk/02f4e017abb5f6483121 to your computer and use it in GitHub Desktop.
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
//compile with: | |
// clang++ -std=c++1y -stdlib=libc++ optional.cpp | |
#include <experimental/optional> | |
#include <string> | |
#include <cstdio> | |
std::experimental::optional<std::string> get_fancy_shit() { | |
//return std::string("some fancy shit!"); | |
return std::experimental::nullopt; | |
} | |
int main(int argc, char *argv[]) { | |
auto s = get_fancy_shit().value_or("no fancy shit!"); | |
printf("I got: %s\n", s.c_str()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment