Closed igaztanaga closed 5 years ago
Are you sure that self move is allowed/required to work in c++17? That would be a breaking change. Can you post a link to the section?
According to the final draft before C++17 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf):
Section 20.5.3.1, Table 25 — MoveAssignable requirements [moveassignable]
Expression: t = rv Return type: T& Return value: t Post-condition: If t and rv do not refer to the same object, t is equivalent to the value of rv before the assignment rv’s state is unspecified. [ Note: rv must still meet the requirements of the library component that is using it, whether or not t and rv refer to the same object. The operations listed in those requirements must work as specified whether rv has been moved from or not. — end note ]
I guess you are right. I read this as "even after self move assignment the object must still be in a valid state" (even if it isn't specified what that state is exactly).
Will it influence the old C++ version of compiler,just like c++14 or c++11?
In C++17, self-move assignment is no longer undefined behavior:
MoveAssignable requirements [moveassignable]
[ Note: rv must still meet the requirements of the library component that is using it, whether or not t and rv refer to the same object. The operations listed in those requirements must work as specified whether rv has been moved from or not. — end note ]
All Boost.Container classes should be updated to guarantee MoveAssignable requirements