
On Sun, Aug 28, 2011 at 3:06 PM, Pierre Morcello < pmorcell-cppfrance@yahoo.fr> wrote:
Hi,
Pierre Morcello escribió: I was waiting for you to correct the bug Ion Gaztañaga wrote : Please try trunk code and let me know if you are happy.
1/ This works, you did it ! 2/ But I got another compilation error on almost the same case, if I use std::swap instead of defining swap :
The standard way to extend swap to a UDT is to define a swap function in the same namespace as the UDT and findable via ADL. #include <boost/container/vector.hpp>
class swapOnly2 { public: swapOnly2():i(0){} private: int i; swapOnly2(const swapOnly2&); swapOnly2& operator=(const swapOnly2&); };
namespace std {
Opening up namespace std is undefined behavior, AFAIK.
template <> void swap( swapOnly2& a, swapOnly2& b ) { std::swap(a.i, b.i);
Aside from the aforementioned problem, how is this suppose to work with SwapOnly2::i having private access and no friend declarations? }
}
int main() { boost::container::vector< swapOnly2 > swapOnlys(3); return 0; } This does not compile. Is this the correct behaviour? Did I miss something?
Based on the above, I think so...? (on both accounts) - Jeff