|
|
Typical implementations either 1) Define a non-member swap in the enclosing namespace, which may forward to a member swap if access to non-public data members is required 2) Define a friend function in-class (this approach hides the class-specific swap from name lookup other than ADL) https://en.cppreference.com/w/cpp/named_req/Swappable |
std::iter_swap()
and the is_swappable()
family of template functions.std::swap( a, b );
looks "swap" from qualified scope "std": https://en.cppreference.com/w/cpp/language/qualified_lookupswap( a, b );
looks for unqualified "swap": https://en.cppreference.com/w/cpp/language/unqualified_lookup and ADL