Skip to content

Remove boost::any wrapper around std::shared_ptr

Jeff Trull requested to merge jaafar/graph-tool:simplify-shared-any into master

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:

  1. to hide the pointed-to type so a uniform container can be used
  2. to represent "no pointer"

both of which can be handled natively by shared_ptr with a small performance gain from removing one indirection.

Merge request reports

Loading