I use boost::any to store pointers and wonder if there is a way to extract a polymorphic data type.
Here is a simple example of what, ideally, I would like to do, but is currently not working.
struct A {}; struct B : A {}; int main() { boost::any a; a = new B(); boost::any_cast< A* >(a); }
This fails because a stores B *, and I'm trying to extract A *. Is there any way to do this?
Thanks.
source share