public member function
<typeinfo>

std::type_info::before

bool before (const type_info& rhs) const;
bool before (const type_info& rhs) const noexcept;
Compare order of types
Returns whether the type precedes the type identified by rhs in some implementation-specific order.

This implementation-specific order is not necessarily related to size, inheritance relations or declaration order, and may differ between programs.

Parameters

rhs
A type_info object identifying a type.

Return Value

Returns true if the type identified by *this is considered to go before the type identified by rhs, and false otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
// ordering types
#include <iostream>   // std::cout
#include <typeinfo>   // operator typeid

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";

  return 0;
}

Possible output:
char goes before int in this implementation.


Exception safety

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

See also