The fundamental problem here is that you assume that people do not write their own swap , which are the best matches, which do subtle or completely different things for the semantics of std::swap and related friends. For a simple example, consider
void swap(int* a, int* b);
where the contents of the pointers are replaced. Now try swapping the int* pair. You might think that the pointers change places, but instead be surprised! this is the content that is being replaced.
Indeed, the manual for swap is the same as any other, only using in the maximum possible local area and not earlier and definitely not in the header.
Puppy
source share