C++ Programming Guide

type_info Class

The class type_info describes type information generated by the typeid operator. The primary functions provided by type_info are equality, inequality, before and name. From <typeinfo.h>, the definition is:


    class type_info {
        public:
            virtual ~type_info( );
            bool operator==( const type_info &rhs ) const;
            bool operator!=( const type_info &rhs ) const;
            bool before( const type_info &rhs ) const;
            const char *name( ) const;
        private:
            type_info( const type_info &rhs );
            type_info &operator=( const type_info &rhs );
    };

The before function compares two types relative to their implementation-dependent collation order. The name function returns an implementation-defined, null-terminated, multibyte string, suitable for conversion and display.

The constructor is a private member function, so you cannot create a variable of type type_info. The only source of type_info objects is in the typeid operator.