I am using boost::any
to store pointers and was wondering if there was
a way to extract a polymorphic data type.
Here is a simple example of what ideally I'd like to do, but currently doesn't work.
struct A {};
struct B : A {};
int main() {
boost::any a;
a = new B();
boost::any_cast< A* >(a);
}
This fails because a is storing a B*, and I'm trying to extract an A*. Is there a way to accomplish this?
Thanks.