# Standard library header <typeinfo>

> C++ Atlas: `cppatlas.com/w/cpp/header/typeinfo` | Source: https://en.cppreference.com/w/cpp/header/typeinfo | Domain: Standard headers

This header is part of the type support library.

## Official Specification Summary (cppreference)

This header is part of the type support library.

### Classes

- `type_info`: contains some type’s information, the class returned by the typeid operator (class)
- `bad_typeid`: exception that is thrown if an argument in a typeid expression is null (class)
- `bad_cast`: exception that is thrown by an invalid `dynamic_cast` expression, i.e. a cast of reference type fails (class)

### Synopsis

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

#### Class `std::type_info`

```cpp
namespace std {
  class type_info {
  public:
    virtual ~type_info();
    constexpr bool operator==(const type_info& rhs) const noexcept;
    bool before(const type_info& rhs) const noexcept;
    size_t hash_code() const noexcept;
    const char* name() const noexcept;

    type_info(const type_info&) = delete;                   // cannot be copied
    type_info& operator=(const type_info&) = delete;        // cannot be copied
  };
}
```

#### Class `std::bad_cast`

```cpp
namespace std {
  class bad_cast : public exception {
  public:
    // see [exception] for the specification of the special member functions
    const char* what() const noexcept override;
  };
}
```

#### Class `std::bad_typeid`

```cpp
namespace std {
  class bad_typeid : public exception {
  public:
    // see [exception] for the specification of the special member functions
    const char* what() const noexcept override;
  };
}
```

---
Attribution: content from https://en.cppreference.com/w/cpp/header/typeinfo (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.