...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::type_erasure::any_cast
// In header: <boost/type_erasure/any_cast.hpp> template<typename T, typename Concept, typename Tag> T any_cast(any< Concept, Tag > & arg); template<typename T, typename Concept, typename Tag> T any_cast(const any< Concept, Tag > & arg); template<typename T, typename Concept, typename Tag> T any_cast(any< Concept, Tag > * arg); template<typename T, typename Concept, typename Tag> T any_cast(const any< Concept, Tag > * arg);
Attempts to extract the object that arg
holds. If casting to a pointer fails, any_cast
returns a null pointer. Casting to void*
always succeeds and returns the address of stored object.
Requires: |
if
|
Throws: |
bad_any_cast if arg doesn't contain an object of type T and we're casting to a value or reference. |