3 ms·
> I often end up wrapping class members in std::optional to arrange for one That's not going to help you unless you explicitly unset the optional in your move
by ot 7y ago
> I often end up wrapping class members in std::optional to arrange for one
That's not going to help you unless you explicitly unset the optional in your move constructor. std::optional's move constructor doesn't unset the argument (see #3 in https://en.cppreference.com/w/cpp/utility/optional/optional https://en.cppreference.com/w/cpp/utility/optional/optional).
But if you have to implement your own constructors to emplace/unset the optionals, you can just have a sentinel state for your whole object.