...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
namespace boost { template <class Derived, class Base> inline Derived polymorphic_cast(Base* x); // Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 ) // Returns: dynamic_cast<Derived>(x) template <class Derived, class Base> inline Derived polymorphic_downcast(Base* x); // Effects: assert( dynamic_cast<Derived>(x) == x ); // Returns: static_cast<Derived>(x) template <class Derived, class Base> inline auto polymorphic_pointer_cast(Base x); // Throws: std::bad_cast if ( dynamic_pointer_cast<Derived>(x) == 0 ) // Returns: dynamic_pointer_cast<Derived>(x) template <class Derived, class Base> inline auto polymorphic_pointer_downcast(Base x); // Effects: assert( dynamic_pointer_cast<Derived>(x) == x ); // Returns: static_pointer_cast<Derived>(x) }