名稱空間
變體
操作

typeof 運算子 (C23 起)

來自 cppreference.com
< c‎ | 語言

確定物件的型別。

目錄

[編輯] 語法

typeof( 型別 ) (1)
typeof( 表示式 ) (2)
typeof_unqual( 型別 ) (3)
typeof_unqual( 表示式 ) (4)

[編輯] 解釋

1) 生成型別名,並計算其中任何巢狀的 typeof-specifier
2) 生成表示其運算元型別的型別名。不對 表示式 應用隱式轉換。
3,4) 分別與 (1)(2) 相同,但移除限定符

[編輯] 備註

typeoftypeof_unqual 統稱為 typeof 運算子typeof 運算子不能應用於位域成員。如果運算元的型別是可變修改型別,則計算運算元;否則,不計算運算元。typeof_unqual 運算子的結果是 typeof 運算子將產生的非原子非限定型別。typeof 運算子保留所有限定符。

[編輯] 示例

[編輯] 參考文獻

  • C23 標準 (ISO/IEC 9899:2024)
  • 6.7.2.5 typeof 說明符 (p: 115-118)

[編輯] 另請參閱

C++ 文件 關於 decltype