名稱空間
變體
操作

std::type_index::name

來自 cppreference.com
< cpp‎ | 型別‎ | 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 2144 C++11 type_index::name 不需要為 noexcept 需要