- You're right, that's a bug. There is some discussion about it in the Main Page Talk section titled Search for "remove" does not show the C++ algorithm.
- Unrelated question: for
what does "incorrect operation" mean (i.e. undefined behavior, unspecified behavior, etc.)? For what types is this true? I'm having trouble finding evidence to support this claim. http://stackoverflow.com/questions/9322174/move-assignment-operator-and-if-this-rhs suggests that there is nothing in the standard that forbids self-move assignment. --Nate 14:23, 24 August 2013 (PDT)
- It's true for C++ standard library, 22.214.171.124 Function arguments [res.on.arguments]. Quotes: "implementation may assume", "impelemtation is free to optimize". (User, of course, can provide correct behaviour by implementing check in custom 'operator=(&&)') Ruslo 02:20, 25 August 2013 (PDT)
- How about: "in stl containers case, result is implementation dependent and not guarantee to be correct"? I've file a bug to libc++ to support debug check in this situation, hope this gave some clarification http://llvm.org/bugs/show_bug.cgi?id=16993 Ruslo 02:20, 25 August 2013 (PDT)
- Agreed. --Nate 11:09, 25 August 2013 (PDT)
Moved-from objects are in a valid but unspecified state. A valid way to implement move assignment is swap.T. Canens (talk) 23:20, 22 October 2015 (PDT)
- Actually, I take that back. Due to allocator propagation requirements, swap won't work as an implementation of move assignment for std::strings in the general case. We should find an example where swap is actually valid. T. Canens (talk) 20:05, 19 January 2016 (PST)