命名空间
变体
操作

std::type_info::before

来自 cppreference.cn
< cpp‎ | 类型‎ | 类型信息
 
 
 
 
 
bool before( const type_info& rhs ) const;
(C++11 起无异常抛出)

如果此 type_info 的类型在实现的排序顺序中位于 rhs 的类型之前,则返回 true。不作任何保证;特别是,排序顺序在同一程序的调用之间可能会改变。

目录

[编辑] 参数

rhs - 另一个用于比较的类型信息对象

[编辑] 返回值

如果此 type_info 的类型在实现的排序顺序中位于 rhs 的类型之前,则返回 true

[编辑] 示例

#include <iostream>
#include <typeinfo>
 
int main()
{
    if (typeid(int).before(typeid(char)))
        std::cout << "int goes before char in this implementation.\n";
    else
        std::cout << "char goes before int in this implementation.\n";
}

可能的输出

char goes before int in this implementation.

[编辑] 参阅

(在 C++20 中移除)
检查对象是否引用相同的类型
(公共成员函数) [编辑]