typeinfo(3C++)


typeinfo -- type identification

Synopsis

   #include <typeinfo> 
   

namespace std { class type_info; class bad_cast; class bad_typeid; }

Description

The header typeinfo defines a type associated with type information generated by the implementation. It also defines two types for reporting dynamic type identification errors.

Class type_info

   namespace std { 
     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 class type_info describes type information generated by the implementation. Objects of this class effectively store a pointer to a name for the type, and an encoded value suitable for comparing two types for equality or collating order. The names, encoding rule, and collating sequence for types are all unspecified and may differ between programs.

bool operator==(const type_info& rhs) const;
Effects: Compares the current object with rhs.
Returns: True if the two values describe the same type.

bool operator!=(const type_info& rhs) const;
Returns: !(*this == rhs).

bool before(const type_info& rhs) const;
Effects: Compares the current object with rhs.
Returns: True if *this precedes rhs in the implementation's collation order.

const char* name() const;
Returns: A null-terminated byte string containing the name of the type.
Notes: The message may be a null-terminated multibyte string, suitable for conversion and display as a wstring.

type_info(const type_info& rhs);

type_info& operator=(const type_info& rhs);
Effects: Copies a type_info object.
Notes: Since the copy constructor and assignment operator for type_info are private to the class, objects of this type cannot be copied.

Class bad_cast

   namespace std { 
     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(); 
     }; 
   } 
The class bad_cast defines the type of objects thrown as exceptions by the implementation to report the execution of an invalid dynamic-cast expression.

bad_cast() throw();
Effects: Constructs an object of class bad_cast.

bad_cast(const bad_cast&) throw();

bad_cast& operator=(const bad_cast&) throw();
Effects: Copies an object of class bad_cast.

virtual const char* what() const throw();
Returns: The string ``std::bad_cast''.

Class bad_typeid

   namespace std { 
     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(); 
     }; 
   } 
The class bad_typeid defines the type of objects thrown as exceptions by the implementation to report a null pointer in a typeid expression.

bad_typeid() throw();
Effects: Constructs an object of class bad_typeid.

bad_typeid(const bad_typeid&) throw();

bad_typeid& operator=(const bad_typeid&) throw();
Effects: Copies an object of class bad_typeid.

virtual const char* what() const throw();
Returns: The string std::bad_typeid.

30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.