std::type_index::name

来自cppreference.com
< cpp‎ | types‎ | type index
 
 
 
 
 
const char* name() const noexcept;
(C++11 起)

返回关联的 std::type_info 对象的名称。等价于直接调用 std::type_info::name()

参数

(无)

返回值

关联的 std::type_info 对象的名称。

示例

#include <iostream>
#include <typeindex>
int main() {
    std::cout << std::type_index(typeid(std::cout)).name();
}

可能的输出:

NSt3__113basic_ostreamIcNS_11char_traitsIcEEEE

缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告应用于出版时的行为正确行为
LWG 2144C++11未要求 type_index::name 为 noexcept已要求