type_traits


  1. Check if a type is signed:

#include <type_traits>

template <typename T>
struct is_signed : std::integral_constant<bool, std::is_signed<T>::value> {};

static_assert(is_signed<int>::value);
static_assert(!is_signed<unsigned int>::value);
  1. Check if a type is floating-point:

#include <type_traits>

template <typename T>
struct is_floating_point : std::integral_constant<bool, std::is_floating_point<T>::value> {};

static_assert(is_floating_point<float>::value);
static_assert(!is_floating_point<int>::value);
  1. Check if a type is a fundamental type:

#include <type_traits>

template <typename T>
struct is_fundamental : std::integral_constant<bool, std::is_fundamental<T>::value> {};

static_assert(is_fundamental<int>::value);
static_assert(!is_fundamental<std::string>::value);
  1. Check if a type is a pointer:

  1. Check if a type is a reference:

  1. Check if a type is an array:

  1. Check if a type is a function:

  1. Check if a type is a class:

  1. Check if a type is a structure:

  1. Check if a type is an enumeration:

  1. Check if a type is a union:

  1. Get the size of a type in bytes:

  1. Get the alignment of a type in bytes:

  1. Check if a type is a const-qualified type:

  1. Check if a type is a volatile-qualified type:

  1. Check if a type is a const-volatile-qualified type:

  1. Get the underlying type of a pointer or reference type: