当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


C++ type_info before用法及代码示例



描述

它返回该类型是否以某种特定于实现的顺序位于 rhs 标识的类型之前。

声明

以下是 std::type_info::before 的声明。

C++98

bool before (const type_info& rhs) const;

C++11

bool before (const type_info& rhs) const noexcept;

参数

rhs− 标识对象类型。

返回值

它返回该类型是否以某种特定于实现的顺序位于 rhs 标识的类型之前。

异常

No-throw guarantee- 该成员函数从不抛出异常。

数据竞争

区域设置对象被修改。

示例

在下面的 std::type_info::before 示例中。

#include <iostream>
#include <typeinfo>

int main() {
   if ( typeid(int).before(typeid(char)) )
      std::cout << "int goes before char while implementation.\n";
   else
      std::cout << "char goes before int while implementation.\n";

   return 0;
}

输出应该是这样的 -

char goes before int while iimplementation.

相关用法


注:本文由纯净天空筛选整理自 C++ Type_info Library - before Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。