Re:C++ 17 is Done
by yongjik on Saturday March 25, 2017 @03:03PM
(#13957057)
std::optional is nice if you have a class with invariants that you want to always maintain (i.e., you don't want to deal with the pesky "uninitialized" state). You can build a class that always requires proper parameter in its constructor, and then you apply optional<> only when you defer initialization.
In most cases, I imagine the performance penalty would be dwarfed by the cost of actually using the class.
In most cases, I imagine the performance penalty would be dwarfed by the cost of actually using the class.