15 Dec
2005
15 Dec
'05
3:34 p.m.
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(); } =========================