
29 Jun
2009
29 Jun
'09
10:18 a.m.
Daniel James writes:
[It's] not recommended to do an unqualified call to boost::swap:
std::string a1[42]; std::string a2[42];
boost::swap(a1, a2); // Okay.
using boost::swap; swap(a1, a2); // Does not compile!
why do you think this code won't compile? As far as I can tell, ADL would resolve the call to invoke std::swap().
Try it.
| $ 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 Peter