Type Comparisons and Modifications
Sometimes we need to manipulate or compare different types. We can use the type traits library for that!
We'll cover the following
Type Comparisons
The library supports three kinds of type comparisons:
Function | Description |
---|---|
template <class Base, class Derived> |
Checks if Derived is derived from Base . |
struct is_base_of |
|
template <class From, class To> |
Checks if From can be converted to To . |
struct is_convertible |
|
template <class T, class U> |
Checks if the types T and U are the same. |
struct is_same |
Type Modifications
The type traits library enables you to modify types during compile time. So you can modify the constness of a type: