class
<typeinfo>

std::type_info

class type_info;
Type information type
Stores information about a type.

An object of this class is returned by the typeid operator (as a const-qualified lvalue). Although its actual dynamic type may be of a derived class.

It can be used to compare two types or to retrieve information identifying a type.

typeid can be applied to any type or any expression that has a type.
If applied to a reference type (lvalue), the type_info returned identifies the referenced type. Any const or volatile qualified type is identified as its unqualified equivalent.

A typedef type is considered the same as its aliased type.

When typeid is applied to a reference or dereferenced pointer to an object of a polymorphic class type (a class declaring or inheriting a virtual function), it considers its dynamic type (i.e., the type of the most derived object). This requires the RTTI (Run-time type information) to be available.

When typeid is applied to a dereferenced null pointer, a bad_typeid exception is thrown.

The lifetime of the object returned by typeid extends to the end of the program.

The copy and assignment operators of type_info are private: objects of this type cannot be copied.
The copy and assignment operators of type_info are deleted: objects of this type cannot be copied.
See type_index for a wrapper class that adapts type_info values to make them copyable and indexable with standard hash values.

Member functions


Note: No public copy-constructor or copy-assignment.

See also