Partager via


<type_traits>

Defines templates that provide compile-time constants that give information about the properties of their type arguments.

#include <type_traits>

Remarks

A type predicate is a template that takes one or two type arguments. When a type predicate holds true, it is publicly derived, directly or indirectly, from true_type Typedef. When a type predicate holds false, it is publicly derived, directly or indirectly, from false_type Typedef.

A type modifier is a template that takes one or more template arguments and has one member, as follows:

  • typedef modified-type type;

A type query is a template that takes one or more template arguments. A type query is publicly derived, directly or indirectly, from integral_constant<std::size_t, value>. It holds the value that is passed as the argument value.

Alias Templates

Alias templates for typename foo<T>::type are provided, where "foo" is the template class name. For example, add_const has the alias template for its type add_const_t, defined as:

template<class T>
    using add_const_t = typename add_const<T>::type;

add_const_t

aligned_storage_t

make_signed_t

remove_pointer_t

add_cv_t

aligned_union_t

make_unsigned_t

remove_reference_t

add_lvalue_reference_t

common_type_t

remove_all_extents_t

remove_volatile_t

add_pointer_t

conditional_t

remove_const_t

result_of_t

add_rvalue_reference_t

decay_t

remove_cv_t

underlying_type_t

add_volatile_t

enable_if_t

remove_extent_t

Classes

add_const

Makes const type from type.

add_cv

Makes const/volatile type from type.

add_pointer

Makes pointer to type from type.

add_reference

Makes reference to type from type.

add_volatile

Makes volatile type from type.

aligned_storage

Makes suitably aligned type.

alignment_of

Gets alignment of type.

common_type

Makes an instance of the common type of two types.

conditional

Makes an instance of the common type of two types.

decay

Makes non-reference, non-const, or non-volatile type, or makes a pointer to type.

enable_if

Makes an instance of a type, or an undefined type.

extent

Gets an array dimension.

has_nothrow_assign

Tests whether the type does not throw on assign.

has_nothrow_constructor

Tests whether the type does not throw on default construction.

has_nothrow_copy

Tests whether the type does not throw on copy construction.

has_nothrow_copy_constructor

Tests if type doesn't throw on copy construction.

has_nothrow_default_constructor

Tests if type doesn't throw on default construction.

has_trivial_assign

Tests whether the type has a trivial assign.

has_trivial_constructor

Tests whether the type has a trivial default constructor.

has_trivial_copy

Tests whether the type has a trivial copy constructor.

has_trivial_copy_constructor

Tests if type has a trivial copy constructor.

has_trivial_default_constructor

Tests if type has a trivial default constructor.

has_trivial_destructor

Tests whether the type has a trivial destructor.

has_virtual_destructor

Tests whether the type has a virtual destructor.

is_abstract

Tests whether the type is an abstract class.

is_arithmetic

Tests whether the type is arithmetic.

is_array

Tests whether the type is an array.

is_base_of

Tests whether one type is the base of another.

is_class

Tests whether the type is a class.

is_compound

Tests whether the type is not scalar.

is_const

Tests whether the type is const.

is_convertible

Tests whether one type is convertible to another.

is_empty

Tests whether the type is an empty class.

is_enum

Tests whether the type is an enumeration.

is_floating_point

Tests whether the type is floating-point.

is_function

Tests whether the type is a function type.

is_fundamental

Tests whether the type is void or arithmetic.

is_integral

Tests whether the type is integral.

is_lvalue_reference

Tests if type is an lvalue reference.

is_member_function_pointer

Tests whether the type is a pointer to a member function.

is_member_object_pointer

Tests whether the type is a pointer to a member object.

is_member_pointer

Tests whether the type is a pointer to a member.

is_object

Tests whether the type is an object type.

is_pod

Tests whether the type is a POD.

is_pointer

Tests whether the type is a pointer.

is_polymorphic

Tests whether the type has a virtual function.

is_reference

Tests whether the type is a reference.

is_rvalue_reference

Tests if type is an rvalue reference.

is_same

Tests whether two types are the same.

is_scalar

Tests whether the type is scalar.

is_signed

Tests whether the type is a signed integer.

is_standard_layout

Tests if type is a standard layout.

is_union

Tests whether the type is a union.

is_unsigned

Tests whether the type is an unsigned integer.

is_void

Tests whether the type is void.

is_volatile

Tests whether the type is volatile.

make_signed

Makes type or the smallest signed type greater than or equal in size to type.

make_unsigned

Makes type or the smallest unsigned type greater than or equal in size to type.

rank

Gets the number of array dimensions.

remove_all_extents

Makes non-array type from array type.

remove_const

Makes non-const type from type.

remove_cv

Makes non-const/volatile type from type.

remove_extent

Makes element type from array type.

remove_pointer

Makes type from a pointer to type.

remove_reference

Makes non-reference type from type.

remove_volatile

Makes non-volatile type from type.

integral_constant

Makes integral constant from type and value.

Typedefs

false_type

Holds integral constant with false value.

true_type

Holds integral constant with true value.

See Also

Reference

<functional>