Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement C++17 MoveAssignable requirements for self-move assignments #88

Closed
igaztanaga opened this issue Nov 12, 2018 · 5 comments

Comments

@igaztanaga
Copy link
Member

commented Nov 12, 2018

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

@Mike-Devel

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2019

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?

@igaztanaga

This comment has been minimized.

Copy link
Member Author

commented Mar 13, 2019

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 ]

@Mike-Devel

This comment has been minimized.

Copy link
Contributor

commented Mar 13, 2019

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).

Lastique added a commit to Lastique/container that referenced this issue May 19, 2019
@faithandbrave

This comment has been minimized.

Copy link

commented Jul 8, 2019

@linholmes

This comment has been minimized.

Copy link

commented Sep 17, 2019

Will it influence the old C++ version of compiler,just like c++14 or c++11?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.