
12 Mar
2014
12 Mar
'14
11:22 a.m.
Dear Experts, Can boost::type_erasure::any_cast cast to a base class? For example: class Base {}; class Derived: public Base {}; Derived d; any< ??? > a (d); Base* b = any_cast<Base*>(&a); assert(b); I know that this isn't possible with Boost.Any, but was hoping that Boost.TypeErasure would include some "magic" to make it possible. Failing that, are there any other options? (What I'd really like to do is to store a weak_ptr<Derived> and retrieve a shared_ptr<Base>, and other similar combinations, but I get stuck before I get that far.) Thanks, Phil.