std::shared_ptr provides a limited amount of type erasure natively based on void* and the fact that it stores the original type in the deleter. As a result, if you know the original type, you can call std::static_pointer_cast and recover a legitimate shared_ptr of the right type, very efficiently.
It looks like the use of boost::any in this code is:
- to hide the pointed-to type so a uniform container can be used
- to represent "no pointer"
both of which can be handled natively by shared_ptr with a small performance gain from removing one indirection.