-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Expert C++
By :
So far in this chapter, we can say that we have discussed only one technique of metaprogramming, which is called (as you already saw in its behavior) improved runtime performance. There is also a second approach, called improved type safety. If, with the first option, we could compute values at compile time, we can calculate the precise types required for algorithms or data structures in this section. Type features are a prime illustration of the second possibility. We can assess and alter types using a range of utilities called type traits, which are included in the Standard Library. This is also called the metaprogramming library. To use type traits, we must include the <type_traits> header:
Helper classes are the first category on the list:
integral_constant(C++11)bool_constant(C++17)true_typefalse_typeAs the root class for all C++ type traits is the std::integral constant, all standard type traits that produce values are descended...