std::type_info::before

From cppreference.com
< cpp‎ | types‎ | type info
 
 
Utilities library
Type support (basic types, RTTI, type traits)
Dynamic memory management
Error handling
Program utilities
Variadic functions
Date and time
Function objects
(C++11)
Relational operators
Optional and any
(C++17)
(C++17)
Pairs and tuples
(C++11)
(C++17)
Swap, forward and move
(C++14)
(C++11)
(C++11)
Type operations
(C++11)
(C++17)
 
Type support
Basic types
Fundamental types
Fixed width integer types (C++11)
Numeric limits
C numeric limits interface
Runtime type information
Type traits
Type categories
(C++11)
(C++14)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Type properties
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++14)
(C++11)
Type trait constants
Metafunctions
(C++17)
(C++17)
(C++17)
Supported operations
Relationships and property queries
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Type modifications
(C++11)(C++11)(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
Type transformations
(C++11)
(C++11)
(C++11)
(C++11)
(C++17)
(C++11)
(C++11)
(C++11)
(C++11)
 
 
bool before( const type_info& rhs );

Returns true if the referred type precedes type, referred to by rhs in the implementation's collation order. No guarantees are given, in particular, the collation order can change between the invocations of the same program.

Contents

[edit] Parameters

rhs - another type information object to compare to

[edit] Return value

true if the referred type precedes type, referred to by rhs in the implementation's collation order.

[edit] Example

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

Possible output:

char goes before int in this implementation.

[edit] See also

checks whether the objects refer to the same type
(public member function)