Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.


Header <boost/core/typeinfo.hpp>


  • Peter Dimov

The header <boost/core/typeinfo.hpp> defines a class boost::core::typeinfo, which is an alias for std::type_info when RTTI is enabled, and is a reasonable substitute when RTTI is not supported.

The macro BOOST_CORE_TYPEID, when applied to a type T, is the equivalent of typeid(T) and produces a reference to a const typeinfo object.

The function boost::core::demangled_name takes a boost::core::typeinfo const & ti and either returns, when that string doesn't need to be demangled, or boost::core::demangle(, when it does. The return type of boost::core::demangled_name is char const* in the first case and std::string in the second.

namespace boost

namespace core
    class typeinfo;
    /* char const* or std::string */ demangled_name( typeinfo const & ti );


#define BOOST_CORE_TYPEID(T) /*unspecified*/
#include <boost/core/typeinfo.hpp>
#include <iostream>

template<class T1, class T2> struct X

int main()
    typedef X<void const*, void(*)(float)> T;

    boost::core::typeinfo const & ti = BOOST_CORE_TYPEID(T);

    std::cout << boost::core::demangled_name( ti ) << std::endl;