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 swap members + ADL functions #642

Merged
merged 1 commit into from
Jan 2, 2021
Merged

Add swap members + ADL functions #642

merged 1 commit into from
Jan 2, 2021

Conversation

capickett
Copy link
Contributor

@capickett capickett commented Jan 2, 2021

Fixes #58.

Adds swap members to each of Slice, Str, Vec, Box, and String. Also adds private friend functions so that Argument Dependent Lookup may function via the using std::swap; idiom.

Addresses dtolnay#58.

Adds `swap` members to each of `Slice`, `Str`, `Vec`, `Box`, and `String`. Also adds private friend functions so that Argument Dependent Lookup may function via the `using std::swap;` idiom.
@capickett
Copy link
Contributor Author

One comment @dtolnay - I noticed some members were implemented later in the header, whilst others were implemented in the cpp file. I wasn't clear on the rationale between when to implement in one or the other, so I tried to be consistent with existing code.

@dtolnay
Copy link
Owner

dtolnay commented Jan 2, 2021

some members were implemented later in the header, whilst others were implemented in the cpp file. I wasn't clear on the rationale

Function templates need to be in a header in C++ for the caller to instantiate. Plain non-template functions go in the source file.

@dtolnay dtolnay merged commit 756556e into dtolnay:master Jan 2, 2021
@capickett
Copy link
Contributor Author

@dtolnay yep that makes a ton of sense! The holidays have gotten to me :)

@capickett capickett deleted the swap branch January 9, 2021 17:56
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.

Provide a swap implementation for types in cxxbridge.h
2 participants