$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Stephen Gross (sgross_at_[hidden])
Date: 2005-12-15 10:34:34
In the following snippet, I've got a simple inherited system (base and 
derived). I create a boost::any and assign it a derived instance. Then I try 
to any_cast it to the base. It compiles, but at runtime it segfaults. Is 
this expected behavior? Is there a way to make this work?
Thanks!
--Steve
===== CODE FOLLOWS =====
class base { public: virtual void go() const { ; } };
class foo1 : public base { virtual void go() const { std::cout << "foo1" << 
std::endl; } };
void test1()
{
  foo1 f;
  boost::any a = f;
  boost::any_cast<base> (&a)->go();
}
=========================