Namespaces
Variants
Views
Actions

Standard library header <type_traits>

From cppreference.com
< cpp‎ | header
Revision as of 08:44, 16 February 2013 by Eric (Talk | contribs)

This header is part of the type support library.


Contents

Classes

Helper Classes
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
(C++11)
checks if a type is void
(class template) [edit]
checks if a type is integral type
(class template) [edit]
checks if a type is floating-point type
(class template) [edit]
(C++11)
checks if a type is an array type
(class template) [edit]
(C++11)
checks if a type is an enumeration type
(class template) [edit]
(C++11)
checks if a type is an union type
(class template) [edit]
(C++11)
checks if a type is a class type (but not union type)
(class template) [edit]
checks if a type is a function type
(class template) [edit]
checks if a type is a pointer type
(class template) [edit]
checks if a type is lvalue reference
(class template) [edit]
checks if a type is rvalue reference
(class template) [edit]
checks if a type is a pointer to a non-static member object
(class template) [edit]
checks if a type is a pointer to a non-static member function
(class template) [edit]
Composite type categories
checks if a type is fundamental type
(class template) [edit]
checks if a type is arithmetic type
(class template) [edit]
(C++11)
checks if a type is scalar type
(class template) [edit]
(C++11)
checks if a type is object type
(class template) [edit]
checks if a type is compound type
(class template) [edit]
checks if a type is either lvalue reference or rvalue reference
(class template) [edit]
checks if a type is a pointer to a non-static member function or object
(class template) [edit]
Type properties
(C++11)
checks if a type is const-qualified
(class template) [edit]
checks if a type is volatile-qualified
(class template) [edit]
checks if a type is trivial
(class template) [edit]
checks if a type is trivially copyable
(class template) [edit]
checks if a type is standard-layout type
(class template) [edit]
(C++11)
checks if a type is plain-old data (POD) type
(class template) [edit]
checks if a type is literal type
(class template) [edit]
(C++11)
checks if a type is class (but not union) type and has no data
(class template) [edit]
checks if a type is polymorphic class type
(class template) [edit]
checks if a type is abstract class type
(class template) [edit]
(C++11)
checks if a type is signed arithmetic type
(class template) [edit]
checks if a type is unsigned arithmetic type
(class template) [edit]
Supported operations
checks if a type has a constructor for specific arguments
(class template) [edit]
checks if a type has a default constructor
(class template) [edit]
checks if a type has a copy constructor
(class template) [edit]
checks if a type has a move constructor
(class template) [edit]
checks if a type has a assignment operator for a specific argument
(class template) [edit]
checks if a type has a copy assignment operator
(class template) [edit]
checks if a type has a move assignment operator
(class template) [edit]
checks if a type has a non-deleted destructor
(class template) [edit]
checks if a type has a virtual destructor
(class template) [edit]
Property queries
obtains the type's alignment requirements
(class template) [edit]
(C++11)
obtains the number of dimensions of an array type
(class template) [edit]
(C++11)
obtains the size of an array type along a specified dimension
(class template) [edit]
Type relationships
(C++11)
checks if two types are the same
(class template) [edit]
checks if a type is derived from the other type
(class template) [edit]
checks if a type can be converted to the other type
(class template) [edit]
Const-volatility specifiers
removes const or/and volatile specifiers from the given type
(class template) [edit]
(C++11)(C++11)(C++11)
adds const or/and volatile specifiers to the given type
(class template) [edit]
References
removes reference from the given type
(class template) [edit]
adds lvalue or rvalue reference to the given type
(class template) [edit]
Pointers
removes pointer from the given type
(class template) [edit]
adds pointer to the given type
(class template) [edit]
Sign modifiers
makes the given integral type signed
(class template) [edit]
makes the given integral type unsigned
(class template) [edit]
Arrays
removes one extent from the given array type
(class template) [edit]
removes all extents from the given array type
(class template) [edit]
Miscellaneous transformations
defines the type suitable for use as uninitialized storage for types of given size
(class template) [edit]
defines the type suitable for use as uninitialized storage for all given types
(class template) [edit]
(C++11)
applies type transformations as when passing a function argument by value
(class template) [edit]
(C++11)
hides a function overload or template specialization based on compile-time boolean
(class template) [edit]
chooses one type or another based on compile-type boolean
(class template) [edit]
deduces the result type of a mixed-mode arithmetic expression
(class template) [edit]
obtains the underlying integer type for a given enumeration type
(class template) [edit]
(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_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;
    // reference modifications:
    template <class T> struct remove_reference;
    template <class T> struct add_lvalue_reference;
    template <class T> struct add_rvalue_reference;
    // sign modifications:
    template <class T> struct make_signed;
    template <class T> struct make_unsigned;
    // array modifications:
    template <class T> struct remove_extent;
    template <class T> struct remove_all_extents;
    // pointer modifications:
    template <class T> struct remove_pointer;
    template <class T> struct add_pointer;
    // other transformations:
    template <std::size_t Len, std::size_t Align> 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...)>;
} // namespace std

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;