Type Traits: Categories and Transformations
This lesson is an extension of the previous lesson where we'll study categories and transformations of type traits.
Primary type categories #
C++ has 14 primary type categories. They are complete and orthogonal, meaning that each type is exactly a member of one type category. The check for the type categories is independent of the type qualifiers const
or volatile
.
The 14 primary type categories are as follows:
Press + to interact
template <class T> struct is_void;template <class T> struct is_integral;template <class T> struct is_floating_point;template <class T> struct is_array;template <class T> struct is_pointer;template <class T> struct is_reference;template <class T> struct is_member_object_pointer;template <class T> struct is_member_function_pointer;template <class T> struct is_enum;template <class T> struct is_union;template <class T> struct is_class;template <class T> struct is_function;template <class T> struct is_lvalue_reference;template <class T> struct is_rvalue_reference;
Composite type categories #
Based on the 14 primary type categories, there are 7 composite type categories in C++.
Performance - working on the entire memory area #
This idea is quite straightforward and is used in current implementations of the STL. If the elements of a container are simple enough, the algorithm of the STL, such as std::copy
, ...