Standard library header (C++11) (original) (raw)
This header is part of the metaprogramming library.
| Supported operations | |
|---|---|
| is_constructibleis_trivially_constructibleis_nothrow_constructible(C++11)(C++11)(C++11) | checks if a type has a constructor for specific arguments (class template) [edit] |
| is_default_constructibleis_trivially_default_constructibleis_nothrow_default_constructible(C++11)(C++11)(C++11) | checks if a type has a default constructor (class template) [edit] |
| is_copy_constructibleis_trivially_copy_constructibleis_nothrow_copy_constructible(C++11)(C++11)(C++11) | checks if a type has a copy constructor (class template) [edit] |
| is_move_constructibleis_trivially_move_constructibleis_nothrow_move_constructible(C++11)(C++11)(C++11) | checks if a type can be constructed from an rvalue reference (class template) [edit] |
| is_assignableis_trivially_assignableis_nothrow_assignable(C++11)(C++11)(C++11) | checks if a type has an assignment operator for a specific argument (class template) [edit] |
| is_copy_assignableis_trivially_copy_assignableis_nothrow_copy_assignable(C++11)(C++11)(C++11) | checks if a type has a copy assignment operator (class template) [edit] |
| is_move_assignableis_trivially_move_assignableis_nothrow_move_assignable(C++11)(C++11)(C++11) | checks if a type has a move assignment operator (class template) [edit] |
| is_destructibleis_trivially_destructibleis_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] |
| is_swappable_withis_swappableis_nothrow_swappable_withis_nothrow_swappable(C++17)(C++17)(C++17)(C++17) | checks if objects of a type can be swapped with objects of same or different type (class template) [edit] |
| reference_converts_from_temporary(C++23) | checks if a reference is bound to a temporary in copy-initialization (class template) [edit] |
| reference_constructs_from_temporary(C++23) | checks if a reference is bound to a temporary in direct-initialization (class template) [edit] |
| Property queries |
|---|
| 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 a base of the other type (class template) [edit] |
| is_virtual_base_of(C++26) | checks if a type is a virtual base of the other type (class template) [edit] |
| is_convertibleis_nothrow_convertible(C++11)(C++20) | checks if a type can be converted to the other type (class template) [edit] |
| is_layout_compatible(C++20) | checks if two types are layout-compatible (class template) [edit] |
| is_pointer_interconvertible_base_of(C++20) | checks if a type is a pointer-interconvertible (initial) base of another type (class template) [edit] |
| is_invocableis_invocable_ris_nothrow_invocableis_nothrow_invocable_r(C++17) | checks if a type can be invoked (as if by std::invoke) with the given argument types (class template) [edit] |
| Const-volatility specifiers | |
| remove_cvremove_constremove_volatile(C++11)(C++11)(C++11) | removes const and/or volatile specifiers from the given type (class template) [edit] |
| add_cvadd_constadd_volatile(C++11)(C++11)(C++11) | adds const and/or volatile specifiers to the given type (class template) [edit] |
| References | |
| remove_reference(C++11) | removes a reference from the given type (class template) [edit] |
| add_lvalue_referenceadd_rvalue_reference(C++11)(C++11) | adds an lvalue or rvalue reference to the given type (class template) [edit] |
| Pointers | |
| remove_pointer(C++11) | removes a pointer from the given type (class template) [edit] |
| add_pointer(C++11) | adds a pointer to the given type (class template) [edit] |
| Sign modifiers | |
| make_signed(C++11) | obtains the corresponding signed type for the given integral type (class template) [edit] |
| make_unsigned(C++11) | obtains the corresponding signed type for the given integral type (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(since C++11)(deprecated in C++23) | defines the type suitable for use as uninitialized storage for types of given size (class template) [edit] |
| aligned_union(since C++11)(deprecated in C++23) | 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] |
| remove_cvref(C++20) | combines std::remove_cv and std::remove_reference (class template) [edit] |
| enable_if(C++11) | conditionally removes a function overload or template specialization from overload resolution (class template) [edit] |
| conditional(C++11) | chooses one type or another based on compile-time boolean (class template) [edit] |
| common_type(C++11) | determines the common type of a group of types (class template) [edit] |
| common_referencebasic_common_reference(C++20) | determines the common reference type of a group of types (class template) [edit] |
| underlying_type(C++11) | obtains the underlying integer type for a given enumeration type (class template) [edit] |
| result_ofinvoke_result(C++11)(removed in C++20)(C++17) | deduces the result type of invoking a callable object with a set of arguments (class template) [edit] |
| void_t(C++17) | void variadic alias template (alias template)[edit] |
| type_identity(C++20) | returns the type argument unchanged (class template) [edit] |
| unwrap_referenceunwrap_ref_decay(C++20)(C++20) | get the reference type wrapped in std::reference_wrapper (class template) [edit] |
| Operations on traits | |
| conjunction(C++17) | variadic logical AND metafunction (class template) [edit] |
| disjunction(C++17) | variadic logical OR metafunction (class template) [edit] |
| negation(C++17) | logical NOT metafunction (class template) [edit] |
| Functions | |
| Member relationships | |
| is_pointer_interconvertible_with_class(C++20) | checks if objects of a type are pointer-interconvertible with the specified subobject of that type (function template) [edit] |
| is_corresponding_member(C++20) | checks if two specified members correspond to each other in the common initial subsequence of two specified types (function template) [edit] |
| Constant evaluation context | |
| is_constant_evaluated(C++20) | detects whether the call occurs within a constant-evaluated context (function) [edit] |
| is_within_lifetime(C++26) | checks whether a pointer is within the object's lifetime at compile time (function) [edit] |
[edit] Synopsis
namespace std { // helper class template<class T, T v> struct integral_constant; template using bool_constant = integral_constant<bool, B>; using true_type = bool_constant; using false_type = bool_constant; // primary type categories template struct is_void; template struct is_null_pointer; template struct is_integral; template struct is_floating_point; template struct is_array; template struct is_pointer; template struct is_lvalue_reference; template struct is_rvalue_reference; template struct is_member_object_pointer; template struct is_member_function_pointer; template struct is_enum; template struct is_union; template struct is_class; template struct is_function; // composite type categories template struct is_reference; template struct is_arithmetic; template struct is_fundamental; template struct is_object; template struct is_scalar; template struct is_compound; template struct is_member_pointer; // type properties template struct is_const; template struct is_volatile; template struct is_trivial; template struct is_trivially_copyable; template struct is_standard_layout; template struct is_empty; template struct is_polymorphic; template struct is_abstract; template struct is_final; template struct is_aggregate; template struct is_signed; template struct is_unsigned; template struct is_bounded_array; template struct is_unbounded_array; template struct is_scoped_enum; template<class T, class... Args> struct is_constructible; template struct is_default_constructible; template struct is_copy_constructible; template struct is_move_constructible; template<class T, class U> struct is_assignable; template struct is_copy_assignable; template struct is_move_assignable; template<class T, class U> struct is_swappable_with; template struct is_swappable; template struct is_destructible; template<class T, class... Args> struct is_trivially_constructible; template struct is_trivially_default_constructible; template struct is_trivially_copy_constructible; template struct is_trivially_move_constructible; template<class T, class U> struct is_trivially_assignable; template struct is_trivially_copy_assignable; template struct is_trivially_move_assignable; template struct is_trivially_destructible; template<class T, class... Args> struct is_nothrow_constructible; template struct is_nothrow_default_constructible; template struct is_nothrow_copy_constructible; template struct is_nothrow_move_constructible; template<class T, class U> struct is_nothrow_assignable; template struct is_nothrow_copy_assignable; template struct is_nothrow_move_assignable; template<class T, class U> struct is_nothrow_swappable_with; template struct is_nothrow_swappable; template struct is_nothrow_destructible; template struct has_virtual_destructor; template struct has_unique_object_representations; template<class T, class U> struct reference_constructs_from_temporary; template<class T, class U> struct reference_converts_from_temporary; // type property queries template struct alignment_of; template 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 Base, class Derived> struct is_virtual_base_of; template<class From, class To> struct is_convertible; template<class From, class To> struct is_nothrow_convertible; template<class T, class U> struct is_layout_compatible; template<class Base, class Derived> struct is_pointer_interconvertible_base_of; template<class Fn, class... ArgTypes> struct is_invocable; template<class R, class Fn, class... ArgTypes> struct is_invocable_r; template<class Fn, class... ArgTypes> struct is_nothrow_invocable; template<class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r; // const-volatile modifications template struct remove_const; template struct remove_volatile; template struct remove_cv; template struct add_const; template struct add_volatile; template struct add_cv; template using remove_const_t = typename remove_const::type; template using remove_volatile_t = typename remove_volatile::type; template using remove_cv_t = typename remove_cv::type; template using add_const_t = typename add_const::type; template using add_volatile_t = typename add_volatile::type; template using add_cv_t = typename add_cv::type; // reference modifications template struct remove_reference; template struct add_lvalue_reference; template struct add_rvalue_reference; template using remove_reference_t = typename remove_reference::type; template using add_lvalue_reference_t = typename add_lvalue_reference::type; template using add_rvalue_reference_t = typename add_rvalue_reference::type; // sign modifications template struct make_signed; template struct make_unsigned; template using make_signed_t = typename make_signed::type; template using make_unsigned_t = typename make_unsigned::type; // array modifications template struct remove_extent; template struct remove_all_extents; template using remove_extent_t = typename remove_extent::type; template using remove_all_extents_t = typename remove_all_extents::type; // pointer modifications template struct remove_pointer; template struct add_pointer; template using remove_pointer_t = typename remove_pointer::type; template using add_pointer_t = typename add_pointer::type; // other transformations template struct type_identity; template struct remove_cvref; template 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, class U, template class TQual, template class UQual> struct basic_common_reference { }; template<class... T> struct common_reference; template struct underlying_type; template<class Fn, class... ArgTypes> struct invoke_result; template struct unwrap_reference; template struct unwrap_ref_decay; template using type_identity_t = typename type_identity::type; template using remove_cvref_t = typename remove_cvref::type; template using decay_t = typename decay::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 common_reference_t = typename common_reference<T...>::type; template using underlying_type_t = typename underlying_type::type; template<class Fn, class... ArgTypes> using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; template using unwrap_reference_t = typename unwrap_reference::type; template using unwrap_ref_decay_t = typename unwrap_ref_decay::type; template<class...> using void_t = void; // logical operator traits template<class... B> struct conjunction; template<class... B> struct disjunction; template struct negation; // primary type categories template inline constexpr bool is_void_v = is_void::value; template inline constexpr bool is_null_pointer_v = is_null_pointer::value; template inline constexpr bool is_integral_v = is_integral::value; template inline constexpr bool is_floating_point_v = is_floating_point::value; template inline constexpr bool is_array_v = is_array::value; template inline constexpr bool is_pointer_v = is_pointer::value; template inline constexpr bool is_lvalue_reference_v = is_lvalue_reference::value; template inline constexpr bool is_rvalue_reference_v = is_rvalue_reference::value; template inline constexpr bool is_member_object_pointer_v = is_member_object_pointer::value; template inline constexpr bool is_member_function_pointer_v = is_member_function_pointer::value; template inline constexpr bool is_enum_v = is_enum::value; template inline constexpr bool is_union_v = is_union::value; template inline constexpr bool is_class_v = is_class::value; template inline constexpr bool is_function_v = is_function::value; // composite type categories template inline constexpr bool is_reference_v = is_reference::value; template inline constexpr bool is_arithmetic_v = is_arithmetic::value; template inline constexpr bool is_fundamental_v = is_fundamental::value; template inline constexpr bool is_object_v = is_object::value; template inline constexpr bool is_scalar_v = is_scalar::value; template inline constexpr bool is_compound_v = is_compound::value; template inline constexpr bool is_member_pointer_v = is_member_pointer::value; // type properties template inline constexpr bool is_const_v = is_const::value; template inline constexpr bool is_volatile_v = is_volatile::value; template inline constexpr bool is_trivial_v = is_trivial::value; template inline constexpr bool is_trivially_copyable_v = is_trivially_copyable::value; template inline constexpr bool is_standard_layout_v = is_standard_layout::value; template inline constexpr bool is_empty_v = is_empty::value; template inline constexpr bool is_polymorphic_v = is_polymorphic::value; template inline constexpr bool is_abstract_v = is_abstract::value; template inline constexpr bool is_final_v = is_final::value; template inline constexpr bool is_aggregate_v = is_aggregate::value; template inline constexpr bool is_signed_v = is_signed::value; template inline constexpr bool is_unsigned_v = is_unsigned::value; template inline constexpr bool is_bounded_array_v = is_bounded_array::value; template inline constexpr bool is_unbounded_array_v = is_unbounded_array::value; template inline constexpr bool is_scoped_enum_v = is_scoped_enum::value; template<class T, class... Args> inline constexpr bool is_constructible_v = is_constructible<T, Args...>::value; template inline constexpr bool is_default_constructible_v = is_default_constructible::value; template inline constexpr bool is_copy_constructible_v = is_copy_constructible::value; template inline constexpr bool is_move_constructible_v = is_move_constructible::value; template<class T, class U> inline constexpr bool is_assignable_v = is_assignable<T, U>::value; template inline constexpr bool is_copy_assignable_v = is_copy_assignable::value; template inline constexpr bool is_move_assignable_v = is_move_assignable::value; template<class T, class U> inline constexpr bool is_swappable_with_v = is_swappable_with<T, U>::value; template inline constexpr bool is_swappable_v = is_swappable::value; template inline constexpr bool is_destructible_v = is_destructible::value; template<class T, class... Args> inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<T, Args...>::value; template inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible::value; template inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible::value; template inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible::value; template<class T, class U> inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<T, U>::value; template inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable::value; template inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable::value; template inline constexpr bool is_trivially_destructible_v = is_trivially_destructible::value; template<class T, class... Args> inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<T, Args...>::value; template inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible::value; template inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible::value; template inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible::value; template<class T, class U> inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<T, U>::value; template inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable::value; template inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable::value; template<class T, class U> inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<T, U>::value; template inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable::value; template inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible::value; template inline constexpr bool has_virtual_destructor_v = has_virtual_destructor::value; template inline constexpr bool has_unique_object_representations_v = has_unique_object_representations::value; template<class T, class U> inline constexpr bool reference_constructs_from_temporary_v = reference_constructs_from_temporary<T, U>::value; template<class T, class U> inline constexpr bool reference_converts_from_temporary_v = reference_converts_from_temporary<T, U>::value; // type property queries template inline constexpr size_t alignment_of_v = alignment_of::value; template inline constexpr size_t rank_v = rank::value; template<class T, unsigned I = 0> inline constexpr size_t extent_v = extent<T, I>::value; // type relations template<class T, class U> inline constexpr bool is_same_v = is_same<T, U>::value; template<class Base, class Derived> inline constexpr bool is_base_of_v = is_base_of<Base, Derived>::value; template<class Base, class Derived> inline constexpr bool is_virtual_base_of_v = is_virtual_base_of<Base, Derived>::value; template<class From, class To> inline constexpr bool is_convertible_v = is_convertible<From, To>::value; template<class From, class To> inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<From, To>::value; template<class T, class U> inline constexpr bool is_layout_compatible_v = is_layout_compatible<T, U>::value; template<class Base, class Derived> inline constexpr bool is_pointer_interconvertible_base_of_v = is_pointer_interconvertible_base_of<Base, Derived>::value; template<class Fn, class... ArgTypes> inline constexpr bool is_invocable_v = is_invocable<Fn, ArgTypes...>::value; template<class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v = is_invocable_r<R, Fn, ArgTypes...>::value; template<class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<Fn, ArgTypes...>::value; template<class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // logical operator traits template<class... B> inline constexpr bool conjunction_v = conjunction<B...>::value; template<class... B> inline constexpr bool disjunction_v = disjunction<B...>::value; template inline constexpr bool negation_v = negation::value; // member relationships template<class S, class M> constexpr bool is_pointer_interconvertible_with_class(M S::*m) noexcept; template<class S1, class S2, class M1, class M2> constexpr bool is_corresponding_member(M1 S1::*m1, M2 S2::m2) noexcept; // constant evaluation context constexpr bool is_constant_evaluated() noexcept; consteval bool is_within_lifetime(const auto) noexcept; }
[edit] Class template std::integral_constant
namespace std { template <class T, T v> struct integral_constant { static constexpr T value = v; using value_type = T; using type = integral_constant<T, v>; constexpr operator value_type() const noexcept { return value; } constexpr value_type operator()() const noexcept { return value; } }; }