名稱空間
變體
操作

std::type_index::operator==,!=,<,<=,>,>=,<=>

來自 cppreference.com
< cpp‎ | 型別‎ | type_index
 
 
 
 
std::type_index
成員函式
type_index::operator=type_index::operator!=type_index::operator<type_index::operator<=type_index::operator>type_index::operator>=type_index::operator<=>
(C++20 前)(C++20)
輔助類
 
bool operator==( const type_index& rhs ) const noexcept;
(1) (C++11 起)
bool operator!=( const type_index& rhs ) const noexcept;
(2) (C++11 起)
(C++20 前)
bool operator<( const type_index& rhs ) const noexcept;
(3) (C++11 起)
bool operator<=( const type_index& rhs ) const noexcept;
(4) (C++11 起)
bool operator>( const type_index& rhs ) const noexcept;
(5) (C++11 起)
bool operator>=( const type_index& rhs ) const noexcept;
(6) (C++11 起)
std::strong_ordering operator<=>( const type_index& rhs ) const noexcept;
(7) (C++20 起)

比較底層的 std::type_info 物件。

1,2) 檢查底層的 std::type_info 物件是否指代同一型別。
3-7) 按由實現定義的排序關係,比較底層的 std::type_info 物件。比較透過 type_info::before 進行。

!= 運算子由 operator== 合成

(C++20 起)

[編輯] 引數

rhs - - 用於比較的另一個 type_index 物件

[編輯] 返回值

1) 如果底層的 std::type_info 物件指代同一型別,則為 true,否則為 false
2) 如果底層的 std::type_info 物件不指代同一型別,則為 true,否則為 false
3-6) 如果底層 std::type_info 物件所指代的型別按相應順序排序,則為 true,否則為 false
7) 如果底層 std::type_info 物件指代同一型別,則為 std::strong_ordering::equal,否則如果 *this 的底層 std::type_info 物件在實現定義的排序中先於 rhs 的,則為 std::strong_ordering::less,否則為 std::strong_ordering::greater