Standard library header <type_traits>
From cppreference.com
This header is part of the type support library.
Classes |
||
Helper Classes |
||
(C++11)
|
compile-time constant of specified type with specified value (class template) |
|
true_type
|
std::integral_constant<bool, true> | |
false_type
|
std::integral_constant<bool, false> | |
Primary type categories |
||
(C++11)
|
checks if a type is void (class template) |
|
(C++14)
|
checks if a type is std::nullptr_t (class template) |
|
(C++11)
|
checks if a type is integral type (class template) |
|
(C++11)
|
checks if a type is floating-point type (class template) |
|
(C++11)
|
checks if a type is an array type (class template) |
|
(C++11)
|
checks if a type is an enumeration type (class template) |
|
(C++11)
|
checks if a type is an union type (class template) |
|
(C++11)
|
checks if a type is a class type (but not union type) (class template) |
|
(C++11)
|
checks if a type is a function type (class template) |
|
(C++11)
|
checks if a type is a pointer type (class template) |
|
(C++11)
|
checks if a type is lvalue reference (class template) |
|
(C++11)
|
checks if a type is rvalue reference (class template) |
|
(C++11)
|
checks if a type is a pointer to a non-static member object (class template) |
|
(C++11)
|
checks if a type is a pointer to a non-static member function (class template) |
|
Composite type categories |
||
(C++11)
|
checks if a type is fundamental type (class template) |
|
(C++11)
|
checks if a type is arithmetic type (class template) |
|
(C++11)
|
checks if a type is scalar type (class template) |
|
(C++11)
|
checks if a type is object type (class template) |
|
(C++11)
|
checks if a type is compound type (class template) |
|
(C++11)
|
checks if a type is either lvalue reference or rvalue reference (class template) |
|
(C++11)
|
checks if a type is a pointer to a non-static member function or object (class template) |
|
Type properties |
||
(C++11)
|
checks if a type is const-qualified (class template) |
|
(C++11)
|
checks if a type is volatile-qualified (class template) |
|
(C++11)
|
checks if a type is trivial (class template) |
|
(C++11)
|
checks if a type is trivially copyable (class template) |
|
(C++11)
|
checks if a type is standard-layout type (class template) |
|
(C++11)
|
checks if a type is plain-old data (POD) type (class template) |
|
(C++11)
|
checks if a type is literal type (class template) |
|
(C++11)
|
checks if a type is class (but not union) type and has no data (class template) |
|
(C++11)
|
checks if a type is polymorphic class type (class template) |
|
(C++11)
|
checks if a type is abstract class type (class template) |
|
(C++11)
|
checks if a type is signed arithmetic type (class template) |
|
(C++11)
|
checks if a type is unsigned arithmetic type (class template) |
Supported operations |
|
(C++11)(C++11)(C++11)
|
checks if a type has a constructor for specific arguments (class template) |
checks if a type has a default constructor (class template) |
|
(C++11)(C++11)(C++11)
|
checks if a type has a copy constructor (class template) |
(C++11)(C++11)(C++11)
|
checks if a type has a move constructor (class template) |
(C++11)(C++11)(C++11)
|
checks if a type has a assignment operator for a specific argument (class template) |
(C++11)(C++11)(C++11)
|
checks if a type has a copy assignment operator (class template) |
(C++11)(C++11)(C++11)
|
checks if a type has a move assignment operator (class template) |
(C++11)(C++11)(C++11)
|
checks if a type has a non-deleted destructor (class template) |
(C++11)
|
checks if a type has a virtual destructor (class template) |
Property queries |
|
(C++11)
|
obtains the type's alignment requirements (class template) |
(C++11)
|
obtains the number of dimensions of an array type (class template) |
(C++11)
|
obtains the size of an array type along a specified dimension (class template) |
Type relationships |
|
(C++11)
|
checks if two types are the same (class template) |
(C++11)
|
checks if a type is derived from the other type (class template) |
(C++11)
|
checks if a type can be converted to the other type (class template) |
Const-volatility specifiers |
|
(C++11)(C++11)(C++11)
|
removes const or/and volatile specifiers from the given type (class template) |
(C++11)(C++11)(C++11)
|
adds const or/and volatile specifiers to the given type (class template) |
References |
|
(C++11)
|
removes reference from the given type (class template) |
(C++11)(C++11)
|
adds lvalue or rvalue reference to the given type (class template) |
Pointers |
|
(C++11)
|
removes pointer from the given type (class template) |
(C++11)
|
adds pointer to the given type (class template) |
Sign modifiers |
|
(C++11)
|
makes the given integral type signed (class template) |
(C++11)
|
makes the given integral type unsigned (class template) |
Arrays |
|
(C++11)
|
removes one extent from the given array type (class template) |
(C++11)
|
removes all extents from the given array type (class template) |
Miscellaneous transformations |
|
(C++11)
|
defines the type suitable for use as uninitialized storage for types of given size (class template) |
(C++11)
|
defines the type suitable for use as uninitialized storage for all given types (class template) |
(C++11)
|
applies type transformations as when passing a function argument by value (class template) |
(C++11)
|
hides a function overload or template specialization based on compile-time boolean (class template) |
(C++11)
|
chooses one type or another based on compile-type boolean (class template) |
(C++11)
|
deduces the result type of a mixed-mode arithmetic expression (class template) |
(C++11)
|
obtains the underlying integer type for a given enumeration type (class template) |
(C++11)
|
deduces the return type of a function call expression (class template) |
[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;