标准库标头 <typeinfo>

来自cppreference.com
< cpp‎ | header


 
 
标准库头
通用工具
<any> (C++17)
<bitset>
<bit> (C++20)
<charconv> (C++17)
<expected> (C++23)
<format> (C++20)
<functional>
<optional> (C++17)
<stdbit.h> (C++26)
<tuple> (C++11)
<typeindex> (C++11)
<utility>
<variant> (C++17)
容器
<array> (C++11)
<deque>
<flat_map> (C++23)
<flat_set> (C++23)
<forward_list> (C++11)
<hive> (C++26)
<inplace_vector> (C++26)   
<list>
<map>
<mdspan> (C++23)
<queue>
<set>
<span> (C++20)
<stack>
<unordered_map> (C++11)
<unordered_set> (C++11)
<vector>
迭代器
<iterator>
范围
<generator> (C++23)
<ranges> (C++20)
 

此头文件是类型支持库的一部分。

目录

[编辑]

包含某个类型的信息,typeid 运算符所返回的类
(类) [编辑]
typeid 表达式中的实参为空值时抛出的异常
(类) [编辑]
由非法的 dynamic_cast 表达式(即引用类型转型失败)抛出的异常
(��) [编辑]

[编辑] 概要

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

[编辑] std::type_info

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;                   // 不能复制
    type_info& operator=(const type_info&) = delete;        // 不能复制
  };
}

[编辑] std::bad_cast

namespace std {
  class bad_cast : public exception {
  public:
    // 特殊成员函数的规定见 [exception]
    const char* what() const noexcept override;
  };
}

[编辑] std::bad_typeid

namespace std {
  class bad_typeid : public exception {
  public:
    // 特殊成员函数的规定见 [exception]
    const char* what() const noexcept override;
  };
}