Exploring the Standard Type Traits: Part 2
Explore how to use C++ standard type traits to modify cv-qualifiers, references, and pointers at compile-time. Understand the role of metafunctions like std::decay and std::conditional, and learn to simplify template code by applying these transformations effectively. This lesson enhances your ability to write flexible and robust template-based functions.
We'll cover the following...
Modifying cv-specifiers, references, pointers, or a sign
The type traits that are performing transformations on types are also called metafunctions. These type traits provided a member type (typedef) called type that represents the transformed type. This category of type traits includes the following:
Type Traits for Certain Transformations
Name | Description |
| Add the |
| Remove the |
| Add an Ivalue or value reference to a type. |
| Removes a reference (either value or rvalue) from a type. |
| Removes the |
| Adds a pointer to a type. |
| Removes a pointer from a type. |
| Make an integral type (except for |
| Remove one or all extents from an array type. |
With the exception of remove_cvref, which was added in C++20, all the other type traits listed in this table are available in C++11. These aren’t all the metafunctions from the standard library. More are listed next.
Miscellaneous transformations
Apart from the metafunctions previously listed, there are other type traits performing type ...