Thanks for pointing that out, Chris.
This advice goes beyond std::optional, by the way. For anything that we move
from, there are two operations at are intended to be safe, from a C++ language
and library design point of view: destroying the object and overwriting it by
assigning a new value.
Another thing Darin didn’t mention but I think people should be careful about:
The move constructor for std::optional does not clear the is-set flag (while
the one for WTF::Optional did).
As a result, you will be having a very bad time if you do a use-after-move of a
Mail list logo