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

Add explicit move assignment operator #873

Closed
wants to merge 1 commit into from

Conversation

pps83
Copy link

@pps83 pps83 commented Jan 19, 2019

this fixes linking error mentioned in #871 when building chrome/webrtc

Copy link
Contributor

@hjmjohnson hjmjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIce. Thanks for making the function signature changes to match common conventions as mandated by the "rule-of-five"
https://cpppatterns.com/patterns/rule-of-five.html

@pps83
Copy link
Author

pps83 commented Jan 20, 2019

Also, afaik when there are custom ctor/dtors compiler cannot add implicit move assignment operator which potentially may prevent some optimizations.

@hjmjohnson
Copy link
Contributor

correct.

Value& Value::operator=(Value other) {
Value& Value::operator=(const Value& other) {
Value tmp(other);
swap(tmp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swapping into a temporary is wasted work.
I think we should rather write "real" operators rather than relying on swap.

I'll work on that now and send a different PR proposal.

@hjmjohnson
Copy link
Contributor

@pps83 Could you please rebase to resolve conflicts so that we may merge this branch?

@hjmjohnson
Copy link
Contributor

@pps83 This work was supperceeded by work of @BillyDonahue in 0c1cc6e.

@hjmjohnson hjmjohnson closed this Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants