Boost logo

Boost :

Subject: Re: [boost] [swap] please update documentation...
From: Niels Dekker - address until 2010-10-10 (niels_address_until_2010-10-10_at_[hidden])
Date: 2009-06-29 10:14:08


 | $ cat >test.cpp <<EOF
 | #include <string>
 | #include <boost/swap.hpp>
 |
 | int main(int, char * [])
 | {
 | std::string a1[42];
 | std::string a2[42];
 |
 | boost::swap(a1, a2); // Okay.
 |
 | using boost::swap;
 | swap(a1, a2); // Does not compile!
 |
 | return 0;
 | }
 | EOF
 | $ g++ -pedantic test.cpp && ./a.out && echo okay
 | okay

>> Can you tell us whether it picks std::swap or boost::swap?

Peter Simons wrote:
> It picks boost::swap():
>
> void boost::swap(T1&, T2&) [with T1 = std::string [42], T2 =
> std::string [42]]

I'm very surprised it doesn't pick std::swap, as found by
argument-dependent lookup. What version of GCC are you using exactly?

Note that boost::swap is tested extensively
<www.boost.org/development/tests/trunk/developer/utility-swap_.html> but
/not/ by doing unqualified swap calls, because that's just not the
intended usage.

Kind regards, Niels


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk