##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# Standard library header <type_traits>

From cppreference.com
< cpp‎ | header

This header is part of the type support library.

### Classes
##### Helper Classes
integral_constant (C++11) | compile-time constant of specified type with specified value (class template) [edit]
`true_type` | std::integral_constant<bool, true>
`false_type` | std::integral_constant<bool, false>
##### Primary type categories
is_void (C++11) | checks if a type is void (class template) [edit]
is_null_pointer (C++14) | checks if a type is std::nullptr_t (class template) [edit]
is_integral (C++11) | checks if a type is integral type (class template) [edit]
is_floating_point (C++11) | checks if a type is floating-point type (class template) [edit]
is_array (C++11) | checks if a type is an array type (class template) [edit]
is_enum (C++11) | checks if a type is an enumeration type (class template) [edit]
is_union (C++11) | checks if a type is an union type (class template) [edit]
is_class (C++11) | checks if a type is a class type (but not union type) (class template) [edit]
is_function (C++11) | checks if a type is a function type (class template) [edit]
is_pointer (C++11) | checks if a type is a pointer type (class template) [edit]
is_lvalue_reference (C++11) | checks if a type is lvalue reference (class template) [edit]
is_rvalue_reference (C++11) | checks if a type is rvalue reference (class template) [edit]
is_member_object_pointer (C++11) | checks if a type is a pointer to a non-static member object (class template) [edit]
is_member_function_pointer (C++11) | checks if a type is a pointer to a non-static member function (class template) [edit]
##### Composite type categories
is_fundamental (C++11) | checks if a type is fundamental type (class template) [edit]
is_arithmetic (C++11) | checks if a type is arithmetic type (class template) [edit]
is_scalar (C++11) | checks if a type is scalar type (class template) [edit]
is_object (C++11) | checks if a type is object type (class template) [edit]
is_compound (C++11) | checks if a type is compound type (class template) [edit]
is_reference (C++11) | checks if a type is either lvalue reference or rvalue reference (class template) [edit]
is_member_pointer (C++11) | checks if a type is a pointer to a non-static member function or object (class template) [edit]
##### Type properties
is_const (C++11) | checks if a type is const-qualified (class template) [edit]
is_volatile (C++11) | checks if a type is volatile-qualified (class template) [edit]
is_trivial (C++11) | checks if a type is trivial (class template) [edit]
is_trivially_copyable (C++11) | checks if a type is trivially copyable (class template) [edit]
is_standard_layout (C++11) | checks if a type is standard-layout type (class template) [edit]
is_pod (C++11) | checks if a type is plain-old data (POD) type (class template) [edit]
is_literal_type (C++11) | checks if a type is literal type (class template) [edit]
is_empty (C++11) | checks if a type is class (but not union) type and has no data (class template) [edit]
is_polymorphic (C++11) | checks if a type is polymorphic class type (class template) [edit]
is_abstract (C++11) | checks if a type is abstract class type (class template) [edit]
is_signed (C++11) | checks if a type is signed arithmetic type (class template) [edit]
is_unsigned (C++11) | checks if a type is unsigned arithmetic type (class template) [edit]

##### Supported operations
is_constructible is_trivially_constructible is_nothrow_constructible (C++11)(C++11)(C++11) | checks if a type has a constructor for specific arguments (class template) [edit]
is_default_constructible is_trivially_default_constructible is_nothrow_default_constructible (C++11)(C++11)(C++11) | checks if a type has a default constructor (class template) [edit]
is_copy_constructible is_trivially_copy_constructible is_nothrow_copy_constructible (C++11)(C++11)(C++11) | checks if a type has a copy constructor (class template) [edit]
is_move_constructible is_trivially_move_constructible is_nothrow_move_constructible (C++11)(C++11)(C++11) | checks if a type has a move constructor (class template) [edit]
is_assignable is_trivially_assignable is_nothrow_assignable (C++11)(C++11)(C++11) | checks if a type has a assignment operator for a specific argument (class template) [edit]
is_copy_assignable is_trivially_copy_assignable is_nothrow_copy_assignable (C++11)(C++11)(C++11) | checks if a type has a copy assignment operator (class template) [edit]
is_move_assignable is_trivially_move_assignable is_nothrow_move_assignable (C++11)(C++11)(C++11) | checks if a type has a move assignment operator (class template) [edit]
is_destructible is_trivially_destructible is_nothrow_destructible (C++11)(C++11)(C++11) | checks if a type has a non-deleted destructor (class template) [edit]
has_virtual_destructor (C++11) | checks if a type has a virtual destructor (class template) [edit]

##### Property queries
alignment_of (C++11) | obtains the type's alignment requirements (class template) [edit]
rank (C++11) | obtains the number of dimensions of an array type (class template) [edit]
extent (C++11) | obtains the size of an array type along a specified dimension (class template) [edit]

##### Type relationships
is_same (C++11) | checks if two types are the same (class template) [edit]
is_base_of (C++11) | checks if a type is derived from the other type (class template) [edit]
is_convertible (C++11) | checks if a type can be converted to the other type (class template) [edit]
##### Const-volatility specifiers
remove_cv remove_const remove_volatile (C++11)(C++11)(C++11) | removes const or/and volatile specifiers from the given type (class template) [edit]
add_cv add_const add_volatile (C++11)(C++11)(C++11) | adds const or/and volatile specifiers to the given type (class template) [edit]
##### References
remove_reference (C++11) | removes reference from the given type (class template) [edit]
add_lvalue_reference add_rvalue_reference (C++11)(C++11) | adds lvalue or rvalue reference to the given type (class template) [edit]
##### Pointers
remove_pointer (C++11) | removes pointer from the given type (class template) [edit]
add_pointer (C++11) | adds pointer to the given type (class template) [edit]
##### Sign modifiers
make_signed (C++11) | makes the given integral type signed (class template) [edit]
make_unsigned (C++11) | makes the given integral type unsigned (class template) [edit]
##### Arrays
remove_extent (C++11) | removes one extent from the given array type (class template) [edit]
remove_all_extents (C++11) | removes all extents from the given array type (class template) [edit]
##### Miscellaneous transformations
aligned_storage (C++11) | defines the type suitable for use as uninitialized storage for types of given size (class template) [edit]
aligned_union (C++11) | defines the type suitable for use as uninitialized storage for all given types (class template) [edit]
decay (C++11) | applies type transformations as when passing a function argument by value (class template) [edit]
enable_if (C++11) | hides a function overload or template specialization based on compile-time boolean (class template) [edit]
conditional (C++11) | chooses one type or another based on compile-type boolean (class template) [edit]
common_type (C++11) | deduces the result type of a mixed-mode arithmetic expression (class template) [edit]
underlying_type (C++11) | obtains the underlying integer type for a given enumeration type (class template) [edit]
result_of (C++11) | deduces the return type of a function call expression (class template) [edit]

### [edit] Synopsis

    namespace std {
        // helper class:
        template <class T, T v> struct integral_constant;
        typedef integral_constant<bool, true> true_type;
        typedef integral_constant<bool, false> false_type;
        // primary type categories:
        template <class T> struct is_void;
        template <class T> struct is_null_pointer;
        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_lvalue_reference;
        template <class T> struct is_rvalue_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;
        // composite type categories:
        template <class T> struct is_reference;
        template <class T> struct is_arithmetic;
        template <class T> struct is_fundamental;
        template <class T> struct is_object;
        template <class T> struct is_scalar;
        template <class T> struct is_compound;
        template <class T> struct is_member_pointer;
        // type properties:
        template <class T> struct is_const;
        template <class T> struct is_volatile;
        template <class T> struct is_trivial;
        template <class T> struct is_trivially_copyable;
        template <class T> struct is_standard_layout;
        template <class T> struct is_pod;
        template <class T> struct is_literal_type;
        template <class T> struct is_empty;
        template <class T> struct is_polymorphic;
        template <class T> struct is_abstract;
        template <class T> struct is_signed;
        template <class T> struct is_unsigned;
        template <class T, class... Args> struct is_constructible;
        template <class T> struct is_default_constructible;
        template <class T> struct is_copy_constructible;
        template <class T> struct is_move_constructible;
        template <class T, class U> struct is_assignable;
        template <class T> struct is_copy_assignable;
        template <class T> struct is_move_assignable;
        template <class T> struct is_destructible;
        template <class T, class... Args> struct is_trivially_constructible;
        template <class T> struct is_trivially_default_constructible;
        template <class T> struct is_trivially_copy_constructible;
        template <class T> struct is_trivially_move_constructible;
        template <class T, class U> struct is_trivially_assignable;
        template <class T> struct is_trivially_copy_assignable;
        template <class T> struct is_trivially_move_assignable;
        template <class T> struct is_trivially_destructible;
        template <class T, class... Args> struct is_nothrow_constructible;
        template <class T> struct is_nothrow_default_constructible;
        template <class T> struct is_nothrow_copy_constructible;
        template <class T> struct is_nothrow_move_constructible;
        template <class T, class U> struct is_nothrow_assignable;
        template <class T> struct is_nothrow_copy_assignable;
        template <class T> struct is_nothrow_move_assignable;
        template <class T> struct is_nothrow_destructible;
        template <class T> struct has_virtual_destructor;
        // type property queries:
        template <class T> struct alignment_of;
        template <class T> struct rank;
        template <class T, unsigned I = 0> struct extent;
        // type relations:
        template <class T, class U> struct is_same;
        template <class Base, class Derived> struct is_base_of;
        template <class From, class To> struct is_convertible;
        // const-volatile modifications:
        template <class T> struct remove_const;
        template <class T> struct remove_volatile;
        template <class T> struct remove_cv;
        template <class T> struct add_const;
        template <class T> struct add_volatile;
        template <class T> struct add_cv;
        template <class T>
        using remove_const_t = typename remove_const<T>::type;
        template <class T>
        using remove_volatile_t = typename remove_volatile<T>::type;
        template <class T>
        using remove_cv_t = typename remove_cv<T>::type;
        template <class T>
        using add_const_t = typename add_const<T>::type;
        template <class T>
        using add_volatile_t = typename add_volatile<T>::type;
        template <class T>
        using add_cv_t = typename add_cv<T>::type;
        // reference modifications:
        template <class T> struct remove_reference;
        template <class T> struct add_lvalue_reference;
        template <class T> struct add_rvalue_reference;
        template <class T>
        using remove_reference_t = typename remove_reference<T>::type;
        template <class T>
        using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
        template <class T>
        using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
        // sign modifications:
        template <class T> struct make_signed;
        template <class T> struct make_unsigned;
        template <class T>
        using make_signed_t = typename make_signed<T>::type;
        template <class T>
        using make_unsigned_t = typename make_unsigned<T>::type;
        // array modifications:
        template <class T> struct remove_extent;
        template <class T> struct remove_all_extents;
        template <class T>
        using remove_extent_t = typename remove_extent<T>::type;
        template <class T>
        using remove_all_extents_t = typename remove_all_extents<T>::type;
        // pointer modifications:
        template <class T> struct remove_pointer;
        template <class T> struct add_pointer;
        template <class T>
        using remove_pointer_t = typename remove_pointer<T>::type;
        template <class T>
        using add_pointer_t = typename add_pointer<T>::type;
        // other transformations:
        template <std::size_t Len,
                  std::size_t Align = /*default-alignment*/>
        struct aligned_storage;
        template <class T> struct decay;
        template <bool, class T = void> struct enable_if;
        template <bool, class T, class F> struct conditional;
        template <class... T> struct common_type;
        template <class T> struct underlying_type;
        template <class> class result_of; // not defined
        template <class F, class... ArgTypes> class result_of<F(ArgTypes...)>;

        template <std::size_t Len,
                  std::size_t Align = /*default-alignment*/>
        using aligned_storage_t = typename aligned_storage<Len,Align>::type;
        template <std::size_t Len, class... Types>
        using aligned_union_t = typename aligned_union<Len,Types...>::type;
        template <class T>
        using decay_t = typename decay<T>::type;
        template <bool b, class T = void>
        using enable_if_t = typename enable_if<b,T>::type;
        template <bool b, class T, class F>
        using conditional_t = typename conditional<b,T,F>::type;
        template <class... T>
        using common_type_t = typename common_type<T...>::type;
        template <class T>
        using underlying_type_t = typename underlying_type<T>::type;
        template <class T>
        using result_of_t = typename result_of<T>::type;
    } // namespace std

#### [edit] Class std::integral_constant

    template <class T, T v>
    struct integral_constant {
        static constexpr T value = v;
        typedef T value_type;
        typedef integral_constant<T,v> type;
        constexpr operator value_type() { return value; }
    };
    typedef integral_constant<bool, true> true_type;
    typedef integral_constant<bool, false> false_type;

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/header/type_traits&oldid=66214"