|
Boost Users : |
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();
}
=========================
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net