Namespaces
Variants

std::meta::is_move_assignable_type, std::meta::is_trivially_move_assignable_type, std::meta::is_nothrow_move_assignable_type

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Type properties
Type property queries
 
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.

1) Equivalent to return std::is_move_assignable_v<T>;.
2) Equivalent to return std::is_trivially_move_assignable_v<T>;.
3) Equivalent to 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:

1) move assignable,
2) trivially move assignable or
3) non-throwing move assignable,

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

checks if reflected type has an assignment operator for a specific argument
(function) [edit]
checks if reflected type has a copy assignment operator
(function) [edit]
checks if reflected type can be constructed from an rvalue reference
(function) [edit]
specifies that an object of a type can be move constructed
(concept) [edit]
specifies that a type is assignable from another type
(concept) [edit]
(C++11)
converts the argument to an xvalue
(function template) [edit]
converts the argument to an xvalue if the move constructor does not throw
(function template) [edit]
checks if a type has a move assignment operator
(class template) [edit]