Search code examples
c++booststlc++11shared-ptr

Where is the std equivalent of boost::shared_polymorphic_downcast in C++11?


boost::shared_polymorphic_downcast and the other boost::shared_ptr functions reside in <boost/shared_ptr.hpp>

I recently enabled support for C++11 in GCC with -std=c++0x. In order to avoid confusion, I moved from boost::shared_ptr to std::shared_ptr which resides in #include <memory>.

However it appears that shared_polymorphic_downcast is not part of the std namespace and is not included with #include <memory>.

Do you know where it is? Did I miss the deprecation memo ;-)


Solution

  • You either need std::static_pointer_cast or std::dynamic_pointer_cast, depending on whether you want static_cast or dynamic_cast behavior.

    Recent versions of Boost's Smart Pointers library include these functions for boost::shared_ptr too.