Type-Traits Overview
In this lesson, we'll study the type traits library and its goals along with type-checks. This section could only provide an overview of the many functions of the type-traits library.
We'll cover the following...
Type-Traits Library #
Type-traits enable type checks, type comparisons, and type modifications at compile-time.
Below are some applications of template metaprogramming:
- Programming at compile-time
- Programming with types and values
- Compiler translates the templates and transforms it in C++ source code
We need to add a type_traits
library in the header to enable all the functions present in the library.
#include <type_traits>
Type-Traits: Goals #
If you look carefully, you’ll see that type-traits have a significant optimization potential. In the first step, type-traits help to analyze the code at compile-time and in the second step, to optimize the code based on that analysis. How is that possible? Depending on the type of variable, a ...