Boost C++ Libraries: Ticket #11786: Shouldn't boost::container::vector handle self-move-assignment? https://svn.boost.org/trac10/ticket/11786 <p> Right now boost::container::vector disallows self-move-assignment. Looking at this seems to have been done by mistake. The code in question(taken from the function priv_move_assign in boost/container/vector.hpp) says: </p> <pre class="wiki">//for move constructor, no aliasing (&amp;x != this) is assummed. BOOST_ASSERT(this != &amp;x); </pre><p> (where x is the parameter) </p> <p> As this isn't a move constructor I can only assume this is a mistake. If it isn't a mistake, just a bad comment, then I'd still argue that this should be changed. Mostly because VS2015 implementation of std::stable_partition assumes that self-move-assignment works... </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11786 Trac 1.4.3 Ion Gaztañaga Fri, 06 Nov 2015 20:54:47 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11786#comment:1 https://svn.boost.org/trac10/ticket/11786#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Thanks for the report. It's an error in the comment as self assignment is not allowed for move assignments: </p> <p> <a class="ext-link" href="http://en.cppreference.com/w/cpp/utility/move"><span class="icon">​</span>http://en.cppreference.com/w/cpp/utility/move</a> </p> <p> "Also, the standard library functions called with xvalue arguments may assume the argument is the only reference to the object; if it was constructed from an lvalue with std::move, no aliasing checks are made. In particular, this means that standard library move assignment operators do not have to perform self-assignment checks" </p> <pre class="wiki"> std::vector&lt;int&gt; v = {2, 3, 3}; v = std::move(v); // undefined behavior </pre><p> Comment changed in commit <a class="ext-link" href="https://github.com/boostorg/container/commit/08e768f1d89289f0783b5bab9ea9f2eb0753ed70"><span class="icon">​</span>https://github.com/boostorg/container/commit/08e768f1d89289f0783b5bab9ea9f2eb0753ed70</a> </p> Ticket