C++ Type_info Library - before Function


Advertisements

Description

It returns whether the type precedes the type identified by rhs in some implementation-specific order.

Declaration

Following is the declaration for std::type_info::before.

C++98

	
bool before (const type_info& rhs) const;

C++11

bool before (const type_info& rhs) const noexcept;

Parameters

rhs − It identify the object type.

Return Value

It returns whether the type precedes the type identified by rhs in some implementation-specific order.

Exceptions

No-throw guarantee − this member function never throws exceptions.

Data races

The locale object is modified.

Example

In below example for 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;
}

The output should be like this −

char goes before int while iimplementation.
typeinfo.htm
Advertisements