Re:Care is needed to use C++ std:optional with non-trivial o...
by omnicognate on Friday January 13, 2023 @07:57AM
(#34367082)
Yeah, that's the whole point of std::optional. Pointers (including smart ones) have the possibility of being empty/pointing-to-nothing built in. std::optional adds it to value types.
To avoid tons of unnecessary copies use move semantics, which std::optional of course supports.
To avoid tons of unnecessary copies use move semantics, which std::optional of course supports.