Type Traits: Categories and Transformations
Explore the concept of C++ type traits focusing on 14 primary and 7 composite type categories. Understand how type traits aid in optimized memory operations and static type comparisons. Learn how to perform compile-time type transformations to modify or generate new types, enhancing your grasp of C++ utilities for more efficient programming.
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:
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, std::fill, or std::equal, will be directly applied to the memory area. Instead of using std::copy to copy the elements individually, the process is completed ...