typeinfo [C++ Reference]
Keywords: typeinfo,start
Date: 2010-04-28T06:16:25-0700

[[typeinfo]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## typeinfo

The `<typeinfo>` header provides class definitions used for run-time type information.

### type_info

    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 );
    };

Class type_info is the type of the object that is returned by the typeid expression. It provides implementation specific type information. The type name provided and collation sequence are implementation defined, and may vary between programs even when using the same compiler.

### bad_cast

    class bad_cast : public exception
    {
    public:
        bad_cast() throw();
        bad_cast(const bad_cast&) throw();
        bad_cast& operator=(const bad_cast&) throw();
        virtual ~bad_cast() throw();
        virtual const char* what() const throw();
    };

Class bad_cast is the type of the object that is thrown by an invalid dynamic_cast expression. The standard explicitly defines it will be thrown when a cast to a reference type fails.

### bad_typeid

    class bad_typeid : public exception
    {
    public:
        bad_typeid() throw();
        bad_typeid(const bad_typeid&) throw();
        bad_typeid& operator=(const bad_typeid&) throw();
        virtual ~bad_typeid() throw();
        virtual const char* what() const throw();
    };

Class bad_typeid is the type of the object that is thrown if the argument in a typeid expression is null.

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •