标准库标头 <typeinfo>
来自cppreference.com
此头文件是类型支持库的一部分。
类
| 包含某个类型的信息,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;
};
}