命名空间
变体
操作

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

出自 cppreference.cn
< cpp‎ | types‎ | 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) true 如果底层的 std::type_info 对象引用相同的类型,则为 false 否则为否。
2) true 如果底层的 std::type_info 对象不引用相同的类型,则为 false 否则为否。
3-6) true 如果底层 std::type_info 对象引用的类型按相应的顺序排序,则为 false 否则为否。
7) std::strong_ordering::equal 如果底层的 std::type_info 对象引用相同的类型,否则,如果 *this 的底层 std::type_info 对象在实现定义的顺序中位于 rhs 之前,则为 std::strong_ordering::less,否则为 std::strong_ordering::greater