This came up while I was bringing GCC's shared_ptr up to date with the latest C++0x working paper.
What will happen here?
$ g++ -xc++ -std=c++0x - <<EOT && ./a.out #include <memory> #include <cassert> struct A { }; struct B : A { }; int main() { std::shared_ptr<A> pa(new A); std::shared_ptr<B> pb(new B); std::swap<A>(pa, pb); assert( pa.get() != pb.get() ); return 0; } EOT
What do you think should happen?