
On Fri, Mar 5, 2010 at 10:30 AM, Joseph Gauterin < joseph.gauterin@googlemail.com> wrote:
It's really a replacement for the common idiom:
using std::swap; swap(a,b);
IIRC one should write 'using namespace std' to avoid artificially preferring std::swap over swap from other namespaces.
Which enables the use of ADL with a fallback to std::swap. Unfortunately, there are a number of compilers that choke on that idiom. boost::swap abstracts the idiom in a more portable way (and adds support for arrays).
While your point is completely correct, I think that it is an important point that boost::swap allows the use of qualified calls to swap while maintaining extensibility. This allows one to avoid using XXX::swap in header files etc. This is extremely useful when writing header only libraries for example. Neil Groves