> On Dec 16, 2018, at 8:37 PM, Chris Dumez <cdu...@apple.com> wrote: > > >> On Dec 16, 2018, at 7:43 PM, Fujii Hironori <fujii.hiron...@gmail.com> wrote: >> >> I don't like the proposal because it encourages misuse of move. >> We can use move only for values about to be destroyed. > > Just for reference, there are close to 400 matches for "WTFMove(m_” in our > code base. People do seem to rely on the state of objects after being moved > out. > I totally agree that the state of the object being moved out is not defined > by the C++ standard. However, so far, in WebKit, we’ve been careful with our > move-constructors. > > I think that if we do not update std::optional’s move constructor, then I > worry we’ll keep having to fix bugs in the future due to its misuse. > Although, maybe this mail thread will help. > > That being said, I agree with your and Daniel and we should use std::exchange > more. I think all the "WTFMove(m_” lines in our code bases should probably be > replaced with std::exchange.
I think it would be easier to enforce a rule of “always use WTF::Optional instead of std::optional” than a rule of “use std::exchange more, but sometimes you really need WTFMove(), but don’t use move when it would be wrong to do so”. Better to set up the code to create simple rules that don’t require judgment IMO. > > >> >> I like Dan's suggestion. We should use std::exchange or std::optional::swap >> for the cases. >> Or, what about adding a new method WTF::Optional::release() for the case? >> >> _______________________________________________ >> webkit-dev mailing list >> webkit-dev@lists.webkit.org >> https://lists.webkit.org/mailman/listinfo/webkit-dev > > _______________________________________________ > webkit-dev mailing list > webkit-dev@lists.webkit.org > https://lists.webkit.org/mailman/listinfo/webkit-dev _______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev