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

[pairs.pair] Replace std::forward with std::move where equivalent #6849

Closed
wants to merge 1 commit into from

Conversation

Eisenwave
Copy link
Contributor

The use of std::forward for the following assignment operators is unnecessary:

  • operator=(pair&& p)
  • operator=(pair&& p) const.

In both cases, we know 100% that the types of this->first and p.first and the type of this->second and p.second match, and we are working with an rvalue reference, not a forwarding reference.

In such cases, it's not necessary to use std::forward, and it arguably misleads the reader into thinking that this is ever copying instead of moving, which isn't the case (unless the two are equivalent).

@Eisenwave Eisenwave changed the title [pairs.pair] Replace std::forward with std::move where equivalent [pairs.pair] Replace std::forward with std::move where equivalent Mar 3, 2024
@Eisenwave
Copy link
Contributor Author

Nevermind, I have missed the possibility of reference members.

@Eisenwave Eisenwave closed this Mar 3, 2024
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

1 participant