Re: [webkit-dev] Moving from WTF::Optional to std::optional

2021-06-02 Thread Darin Adler via webkit-dev
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. I

Re: [webkit-dev] Moving from WTF::Optional to std::optional

2021-06-01 Thread Chris Dumez via webkit-dev
Hi, 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 std::optional. Please m

[webkit-dev] Moving from WTF::Optional to std::optional

2021-06-01 Thread Darin Adler via webkit-dev
Hi folks. We’re getting rid of the WTF::Optional class template, because, hooray, std::optional is supported quite well by all the C++17 compilers we use, and we don’t have to keep using our own special version. Generally we don’t want to reimplement the C++ standard library when there is not a