Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
PrevUpHomeNext

Categorizing a Type

These traits identify what "kind" of type some type T is. These are split into two groups: primary traits which are all mutually exclusive, and composite traits that are compositions of one or more primary traits.

For any given type, exactly one primary type trait will inherit from true_type, and all the others will inherit from false_type, in other words these traits are mutually exclusive.

This means that is_integral<T>::value and is_floating_point<T>::value will only ever be true for built-in types; if you want to check for a user-defined class type that behaves "as if" it is an integral or floating point type, then use the std::numeric_limits template instead.

Synopsis:

template <class T>
struct is_array;
  
template <class T>
struct is_class;

template <class T>
struct is_complex;
  
template <class T>
struct is_enum;
  
template <class T>
struct is_floating_point;
  
template <class T>
struct is_function;

template <class T>
struct is_integral;
  
template <class T>
struct is_member_function_pointer;
  
template <class T>
struct is_member_object_pointer;
  
template <class T>
struct is_pointer;
  
template <class T>
struct is_reference;
  
template <class T>
struct is_union;
  
template <class T>
struct is_void;

The following traits are made up of the union of one or more type categorizations. A type may belong to more than one of these categories, in addition to one of the primary categories.

template <class T>
struct is_arithmetic;

template <class T>
struct is_compound;

template <class T>
struct is_fundamental;

template <class T>
struct is_member_pointer;

template <class T>
struct is_object;

template <class T>
struct is_scalar;

PrevUpHomeNext