News for hackers. Stuff that matters.
Re:Modern C++ Features – std::optional by 0xmaverick on Saturday June 09, 2018 @04:03PM (#17274710)
I find this useful for older paradigms where you want an error as well as pass in something to fill in as the output. Instead of doing bool foo(OutFoo* out_foo) or overloading Id getId(); // returns -1 if not present. You could use base::Optional<OutFoo> / base::Optional<Id> in each case respectively.
Re:Modern C++ Features – std::optional by klodolph on Saturday June 09, 2018 @07:48PM (#17275642)
You may find std::variant also very useful. You can do something like std::variant<Error, Foo>.