Exploring the Standard Type Traits: Part 1

Take your knowledge of templates to the next level by understanding the standard type traits.

The standard library features a series of type traits for querying properties of types as well as performing transformations on types. These type traits are available in the <type_traits> header as part of the type support library. There are several categories of type traits, including the following:

  • Querying the type category (primary or composite)

  • Querying type properties

  • Querying supported operations

  • Querying type relationships

  • Modifying cv-specifiers, references, pointers, or a sign

  • Miscellaneous transformations

Although looking at every single type trait is beyond the scope of this course, we’ll explore all these categories to see what they contain. In this lesson, we’ll list the type traits (or most of them) that make up each of these categories. These lists as well as detailed information about each type trait can be found in the C++ standard (see Further Readings lesson at the end of the course for a link to a freely available draft version) or on the cppreference website (license usage link).

We'll start with the type traits for querying the type category.

Querying the type category

Throughout this course so far, we have used several type traits, such as std::is_integral, std::is_floating_point, and std::is_arithmetic. These are just some of the standard type traits used for querying primary and composite type categories. The following table lists the entire set of such type traits:

Get hands-on with 1200+ tech skills courses.