命名空间
变体
操作

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

来自 cppreference.cn
< 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