C++ named requirements: MoveAssignable (since C++11)
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
C++ named requirements
(C++11)
MoveAssignable
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++17)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++17)
(C++20)
(C++20)
(C++20)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++14)
(C++14)
(C++11)
(C++11)
(C++17)
(C++14)
(C++20)
(C++20)
(C++23)
(C++23)
(C++23)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Specifies that an instance of the type can be assigned from an rvalue argument.
[edit] Requirements
The type T
satisfies MoveAssignable if
Given
-
t
, a modifiable lvalue expression of typeT
, -
rv
, an rvalue expression of typeT
.
The following expressions must be valid and have their specified effects.
Expression | Return type | Return value | Post-conditions |
---|---|---|---|
t = rv | T&
|
t
|
If t and rv do not refer to the same object, the value of t is equivalent to the value of rv before the assignment.
The new value of |
[edit] Notes
The type does not have to implement move assignment operator in order to satisfy this type requirement: a copy assignment operator that takes its parameter by value or as a const Type&
, will bind to rvalue argument.
If a MoveAssignable class implements a move assignment operator, it may also implement move semantics to take advantage of the fact that the value of rv
after assignment is unspecified.
[edit] See also
Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/MoveAssignable&oldid=156435"