6 Aug 2008 redi   » (Master)

C++0x quiz

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?

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!