How should one use std::optional?

The simplest example I can think of: std::optional<int> try_parse_int(std::string s) { //try to parse an int from the given string, //and return “nothing” if you fail } The same thing might be accomplished with a reference argument instead (as in the following signature), but using std::optional makes the signature and usage nicer. bool try_parse_int(std::string s, … Read more