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 swap. #80

Open
joto opened this issue Jan 29, 2016 · 1 comment
Open

Implement swap. #80

joto opened this issue Jan 29, 2016 · 1 comment
Milestone

Comments

@joto
Copy link
Contributor

joto commented Jan 29, 2016

In the current code there is no implementation for swap() which means std::swap() will be used. This should do the right thing (as long as the move constructor and move assignment do the right thing) and the tests show this.

But this solution is not optimal, because the default std::swap() will always do one move construction and two move assignments (in this case of the variant). If there is a more efficient swap for the type in the variant, it will not be used. The upcoming standard P0088R0 describes the effects of swap as: "if index() == rhs.index(), calls swap(get<i>(*this), get<i>(hrs)) with i being index(). Else calls swap(*this, hrs)."

We might want to implement our own swap in the future.

@joto joto added this to the 2.0.0 milestone Jan 29, 2016
@artemp
Copy link
Contributor

artemp commented Jan 6, 2017

@joto - do you have plans for swap? Should we steal swap from std::variant ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants