http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57049

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> 
2013-04-25 09:55:47 UTC ---
Here are two different things to consider:

1) The standard library specification of basic_string's move-assignment
operator currently requires that it works for self-assignment:

<quote>
21 Effects: If *this and str are not the same object, modifies *this as shown
in Table 71. [...]

22 If *this and str are the same object, the member has no effect.
</quote>

This might or might not change, depending on the outcome of LWG issue

http://cplusplus.github.io/LWG/lwg-active.html#2063

2) The generic swap template from <utility> imposes requirements on the
argument types and describes what it does (which can only rely on the
requirements). So if you call swap with the same argument value and if for
these argument values the move-assignment is undefined behaviour, you get what
you are asking for. There is no single evidence that swap would be even allowed
to prevent swapping for identical arguments, because the semantics are
specified clearly to exchange the two values.

Reply via email to