std::meta::is_move_assignable_type, std::meta::is_trivially_move_assignable_type, std::meta::is_nothrow_move_assignable_type
| Defined in header <meta>
|
||
consteval bool is_move_assignable_type( std::meta::info r );
|
(1) | (since C++26) |
consteval bool is_trivially_move_assignable_type( std::meta::info r );
|
(2) | (since C++26) |
consteval bool is_nothrow_move_assignable_type( std::meta::info r );
|
(3) | (since C++26) |
Returns true if r represents a type T that is
move assignable,
trivially move assignable or
non-throwing move assignable, respectively, that is, T has an appropriate move assignment operator.
return std::is_move_assignable_v<T>;.return std::is_trivially_move_assignable_v<T>;.return std::is_nothrow_move_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_move_assignable_type is less strict than MoveAssignable because it does not check the type of the result of the assignment (which, for a MoveAssignable type, must be T&), nor the semantic requirement that the target's value after the assignment is equivalent to the source's value before the assignment.
The type does not have to implement a move assignment operator in order to satisfy this trait; see MoveAssignable for details.
Example
#include <meta>
#include <string>
struct Foo { int n; };
struct NoMove
{
// Prevents implicit declaration of default move assignment operator.
// However, the class is still move-assignable because its
// copy assignment operator can bind to an rvalue argument.
NoMove& operator=(const NoMove&) { return *this; }
};
static_assert(
is_nothrow_move_assignable_type(^^std::string) == true and
is_move_assignable_type(^^int[2]) == false and
is_trivially_move_assignable_type(^^Foo) == true and
is_move_assignable_type(^^NoMove) == true and
is_nothrow_move_assignable_type(^^NoMove) == false
);
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 copy assignment operator (function) | |
| checks if reflected type can be constructed from an rvalue reference (function) | |
(C++20) |
specifies that an object of a type can be move constructed (concept) |
(C++20) |
specifies that a type is assignable from another type (concept) |
(C++11) |
converts the argument to an xvalue (function template) |
(C++11) |
converts the argument to an xvalue if the move constructor does not throw (function template) |
(C++11)(C++11)(C++11) |
checks if a type has a move assignment operator (class template) |