命名空间
变体
操作

std::type_info::before

来自 cppreference.cn
< cpp‎ | types‎ | type info
 
 
 
 
 
bool before( const type_info& rhs ) const;
(noexcept since C++11) (自 C++11 起为 noexcept)

如果此 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 中移除)
检查对象是否引用同一类型
(公共成员函数) [编辑]