
| $ 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