Re:A brief introduction to C++'s model for type- and resourc...
by stinos on Saturday January 16, 2016 @09:14AM
(#10915297)
That's actually std::optional, minus the nothing/just notation? Indeed more people should use things like this. Reminds me of a similar concept I also have wrappers for: instead of manually having to compare the results of std::find etc against range.end() all over the place, the result is basically in a small container which has both the iterator returned and the end of the range. So I write
instead of typcial
Not that much of a gain, but once used to it I could never go back. And I realize now this could actually just be rewritten using your maybe class or std::optional.
[ Parent
| on HN ]
Re:A brief introduction to C++'s model for type- and resourc...
by lorenzhs on Saturday January 16, 2016 @09:37AM
(#10915348)
Yeah it's pretty much std::optional but unfortunately that's in the library fundamentals TS and still in the experimental namespace last I checked. But I have to say that I prefer the name "maybe", it does convey the notion that you have to check whether it's valid much better than "optional" in my opinion.