Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//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
You can’t perform that action at this time.