[webkit-dev] Use WTF::move() instead of std::move()

Daniel Bates dbates at webkit.org
Thu Jul 3 16:04:25 PDT 2014

Hi all,

Following <http://trac.webkit.org/changeset/170774>, please use WTF::move()
instead of std::move(). I substituted WTF::move() for std::move() in all
code to date. WTF::move() is a replacement for std::move() that is less
error prone to use.

Depending on std::move() to lead to a move operation has led to bugs in
some contexts, including <https://bugs.webkit.org/show_bug.cgi?id=134304>
and <http://trac.webkit.org/changeset/170594>. In particular, assigning the
result of std::move() that is passed a const value will lead to a copy
operation (*). For comparison, WTF::move() compile asserts that its
argument is a non-const lvalue reference (**). So, passing a const value to
WTF::move() will cause a compile-time error. This behavior prevents
introducing such bugs and catches unnecessary calls to move() with an
rvalue (as such calls are no-ops).

If you encounter issues using WTF::move() or have suggestions for
improvement then please file a bug and CC me.

Have a happy Fourth of July weekend!


(*) I'm disregarding functions with nonsensical signatures and behavior,
such as a move assignment operator taking a const rvalue reference.

(**) A person must still ensure that using WTF::move() is necessary at each
call site. That is, that the usage of WTF::move() leads to a move operation
as opposed to a copy operation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20140703/539f3176/attachment.html>

More information about the webkit-dev mailing list