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

来自cppreference.com
< cpp‎ | types‎ | type index
 
 
工具库
通用工具
格式化库 (C++20)
(C++11)
关系运算符 (C++20 中弃用)
整数比较函数
(C++20)(C++20)(C++20)
(C++20)
swap 与类型运算
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
常用词汇类型
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)

初等字符串转换
(C++17)
(C++17)
栈踪
 
类型支持
基本类型
基础类型
定宽整数类型 (C++11)
数值极限
C 数值极限接口
运行时类型信息
类型特性
类型类别
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
类型属性
(C++11)
(C++11)
(C++14)
(C++11)
(C++11)(C++20 前)
(C++11)(C++20 中弃用)
(C++11)
类型特性常量
元函数
(C++17)
常量求值语境
受支持操作
关系与属性查询
类型修改
(C++11)(C++11)(C++11)
类型变换
(C++11)
(C++11)
(C++17)
(C++11)(C++20 前)(C++17)
 
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++11)(C++11)(C++20 前)(C++11)(C++11)(C++11)(C++11)(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