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

For swap use ADL instead of specializing std::swap #3656

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

randombit
Copy link
Owner

Not using ADL is a remnant of pre-C++11

Not using ADL is a remnant of pre-C++11
Copy link
Collaborator

@reneme reneme left a comment

Choose a reason for hiding this comment

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

Isn't that (technically) a breaking API change that requires users to switch from std::swap() to just swap()?

At least that's how understand the example code in the STL documentation.

@randombit
Copy link
Owner Author

I don't think this is a breaking change. It does mean that using std::swap, at least with the usual implementation of

T c = move(a);
a = move(b);
b = move(c);

will be a bit slower than it was since we do 3 swaps instead of 1. But it still works just fine.

I'm basing this change on comments from Dave Abrahams and Howard Hinnant in this SO post https://stackoverflow.com/questions/11562/how-to-overload-stdswap

@randombit randombit merged commit 7c03c1b into master Aug 17, 2023
33 checks passed
@randombit randombit deleted the jack/no-swap-in-std branch August 17, 2023 19:00
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.

2 participants