std::is_assignable,std::is_trivially_assignable,std::is_nothrow_assignable (3) - Linux Manuals
std::is_assignable,std::is_trivially_assignable,std::is_nothrow_assignable: std::is_assignable,std::is_trivially_assignable,std::is_nothrow_assignable
NAME
std::is_assignable,std::is_trivially_assignable,std::is_nothrow_assignable - std::is_assignable,std::is_trivially_assignable,std::is_nothrow_assignable
Synopsis
Defined in header <type_traits>
template< class T, class U > (1) (since C++11)
struct is_assignable;
template< class T, class U > (2) (since C++11)
struct is_trivially_assignable;
template< class T, class U > (3) (since C++11)
struct is_nothrow_assignable;
1) If the expression std::declval<T>() = std::declval<U>() is well-formed in unevaluated context, provides the member constant value equal true. Otherwise, value is false. Access_checks are performed as if from a context unrelated to either type.
2) same as (1), but the evaluation of the assignment expression will not call any operation that is not trivial. For the purposes of this check, a call to std::declval is considered trivial and not considered an odr-use of std::declval.
3) same as (1), but the evaluation of the assignment expression will not call any operation that is not noexcept.
T and U shall each be a complete type, (possibly cv-qualified) void, or an array of unknown bound. Otherwise, the behavior is undefined.
If an instantiation of a template above depends, directly or indirectly, on an incomplete type, and that instantiation could yield a different result if that type were hypothetically completed, the behavior is undefined.
Helper variable templates
template< class T, class U > (since C++17)
inline constexpr bool is_assignable_v = is_assignable<T, U>::value;
template< class T, class U > (since C++17)
inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<T, U>::value;
template< class T, class U > (since C++17)
inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<T, U>::value;
Inherited from std::integral_constant
Member constants
value true if T is assignable from U , false otherwise
[static]
Member functions
operator bool (public member function)
operator() returns value
(C++14)
Member types
Type Definition
value_type bool
type std::integral_constant<bool, value>
Notes
This trait does not check anything outside the immediate context of the assignment expression: if the use of T or U would trigger template specializations, generation of implicitly-defined special member functions etc, and those have errors, the actual assignment may not compile even if std::is_assignable<T,U>::value compiles and evaluates to true.
Example
// Run this code
Output:
See also
is_copy_assignable
is_trivially_copy_assignable
is_nothrow_copy_assignable checks if a type has a copy assignment operator