std::meta::is_copy_assignable_type, std::meta::is_trivially_copy_assignable_type, std::meta::is_nothrow_copy_assignable_type
| Defined in header <meta>
|
||
consteval bool is_copy_assignable_type( std::meta::info r );
|
(1) | (since C++26) |
consteval bool is_trivially_copy_assignable_type( std::meta::info r );
|
(2) | (since C++26) |
consteval bool is_nothrow_copy_assignable_type( std::meta::info r );
|
(3) | (since C++26) |
Returns true if r represents a type T that is
copy assignable,
trivially copy assignable or
non-throwing copy assignable, respectively, that is, T has an appropriate copy assignment operator.
return std::is_copy_assignable_v<T>;.return std::is_trivially_copy_assignable_v<T>;.return std::is_nothrow_copy_assignable_v<T>;.If T is not a complete type, (possibly cv-qualified) void, or an array of unknown bound, the program is ill-formed.
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 program is ill-formed.
Parameters
| r | - | a reflection value to test |
Return value
true if r represents a type that is:
as described above. Otherwise, false.
Exceptions
Throws std::meta::exception if r does not represent a type or type alias.
Notes
The is_copy_assignable_type is less strict than CopyAssignable because it does not check the type of the result of the assignment (which, for a CopyAssignable type, must be an lvalue of type T) and does not check the semantic requirement that the argument expression remains unchanged. It also does not check that T satisfies MoveAssignable, which is required of all CopyAssignable types.
Example
#include <meta>
struct Foo { int n; };
static_assert(""
&& is_copy_assignable_type(^^Foo) == true
&& is_trivially_copy_assignable_type(^^Foo) == true
&& is_nothrow_copy_assignable_type(^^Foo) == true
&& is_copy_assignable_type(^^int[2]) == false
&& is_nothrow_copy_assignable_type(^^int) == true
);
int main() {}
See also
(C++26)(C++26)(C++26) |
checks if reflected type has an assignment operator for a specific argument (function) |
| checks if reflected type has a move assignment operator (function) | |
| checks if reflected type has a copy constructor (function) | |
(C++20) |
specifies that an object of a type can be copy constructed and move constructed (concept) |
(C++20) |
specifies that a type is assignable from another type (concept) |
(C++11)(C++11)(C++11) |
checks if a type has a copy assignment operator (class template) |