Template | Condition | Preconditions |
T is const-qualified ([basic.type.qualifier]) | ||
T is volatile-qualified ([basic.type.qualifier]) | ||
T is a trivial type ([basic.types]) | ||
T is a trivially copyable type ([basic.types]) | ||
T is a standard-layout type ([basic.types]) | ||
T is a class type, but not a union type, with no non-static data
members other than subobjects of zero size, no virtual member functions,
no virtual base classes, and no base class B for
which is_empty_v<B> is false. | ||
T is a polymorphic class ([class.virtual]) | ||
T is an abstract class ([class.abstract]) | ||
T is an aggregate type ([dcl.init.aggr]) | ||
If is_arithmetic_v<T> is true, the same result as
T(-1) < T(0);
otherwise, false | ||
If is_arithmetic_v<T> is true, the same result as
T(0) < T(-1);
otherwise, false | ||
T is an array type of known bound ([dcl.array]) | ||
T is an array type of unknown bound ([dcl.array]) | ||
For a function type T or
for a cv void type T,
is_constructible_v<T, Args...> is false,
otherwise see below | T and all types in the template parameter pack Args
shall be complete types, cv void,
or arrays of unknown bound. | |
For a referenceable type T ([defns.referenceable]), the same result as
is_constructible_v<T, const T&>, otherwise false. | ||
Only the validity of the immediate context
of the assignment expression is considered. [Note : ]The compilation of the
expression can result in side effects such as the instantiation of class template
specializations and function template specializations, the generation of
implicitly-defined functions, and so on. Such side effects are not in the “immediate
context” and can result in the program being ill-formed. — end note | ||
The expressions swap(declval<T>(), declval<U>()) and
swap(declval<U>(), declval<T>()) are each well-formed
when treated as an unevaluated operand
in an overload-resolution context
for swappable values ([swappable.requirements]). Only the validity of the immediate context
of the swap expressions is considered. [Note : ]The compilation of the expressions can result in side effects
such as the instantiation of class template specializations and
function template specializations,
the generation of implicitly-defined functions, and so on. Such side effects are not in the “immediate context” and
can result in the program being ill-formed. — end note | ||
Either T is a reference type,
or T is a complete object type
for which the expression
declval<U&>().~U()
is well-formed
when treated as an unevaluated operand,
where U is
remove_all_extents_t<T>. | ||
is_constructible_v<T, Args...> is true and the variable definition for is_constructible, as defined below, is known to call no operation that is not trivial ([basic.types], [special]). | T and all types in the template parameter pack Args shall be complete types,
cv void, or arrays of unknown bound. | |
For a referenceable type T, the same result as
is_trivially_constructible_v<T, const T&>, otherwise false. | ||
For a referenceable type T, the same result as
is_trivially_constructible_v<T, T&&>, otherwise false. | ||
is_assignable_v<T, U> is true and the assignment, as defined by
is_assignable, is known to call no operation that is not trivial
([basic.types], [special]). | ||
For a referenceable type T, the same result as
is_trivially_assignable_v<T&, const T&>, otherwise false. | ||
For a referenceable type T, the same result as
is_trivially_assignable_v<T&, T&&>, otherwise false. | ||
is_destructible_v<T> is true and
remove_all_extents_t<T> is either a non-class type or
a class type with a trivial destructor. | ||
is_constructible_v<T, Args...> is true
and the
variable definition for is_constructible, as defined below, is known not to
throw any exceptions ([expr.unary.noexcept]). | T and all types in the template parameter pack Args
shall be complete types, cv void,
or arrays of unknown bound. | |
For a referenceable type T, the same result as
is_nothrow_constructible_v<T, const T&>, otherwise false. | ||
For a referenceable type T, the same result as
is_nothrow_constructible_v<T, T&&>, otherwise false. | ||
is_assignable_v<T, U> is true and the assignment is known not to
throw any exceptions ([expr.unary.noexcept]). | ||
For a referenceable type T, the same result as
is_nothrow_assignable_v<T&, const T&>, otherwise false. | ||
For a referenceable type T, the same result as
is_nothrow_assignable_v<T&, T&&>, otherwise false. | ||
is_swappable_with_v<T, U> is true and
each swap expression of the definition of
is_swappable_with<T, U> is known not to throw
any exceptions ([expr.unary.noexcept]). | ||
For a referenceable type T,
the same result as is_nothrow_swappable_with_v<T&, T&>,
otherwise false. | ||
is_destructible_v<T> is true and the indicated destructor is known
not to throw any exceptions ([expr.unary.noexcept]). | ||
T has a virtual destructor ([class.dtor]) | ||
For an array type T, the same result as
has_unique_object_representations_v<remove_all_extents_t<T>>,
otherwise see below. |
is_const_v<const volatile int> // true is_const_v<const int*> // false is_const_v<const int&> // false is_const_v<int[3]> // false is_const_v<const int[3]> // true— end example
remove_const_t<const volatile int> // volatile int remove_const_t<const int* const> // const int* remove_const_t<const int&> // const int& remove_const_t<const int[3]> // int[3]— end example
// Given: struct P final { }; union U1 { }; union U2 final { }; // the following assertions hold: static_assert(!is_final_v<int>); static_assert(is_final_v<P>); static_assert(!is_final_v<U1>); static_assert(is_final_v<U2>);— end example
T t(declval<Args>()...);