bool before( const type_info& rhs ) const; | (until C++11) | |
bool before( const type_info& rhs ) const noexcept; | (since C++11) |
Returns true
if the type of this type_info
precedes the type of 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.
rhs | - | another type information object to compare to |
true
if the type of this type_info
precedes the type of rhs
in the implementation's collation order.
#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.
(removed in C++20) | checks whether the objects refer to the same type (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/types/type_info/before