A move assignment operator replaces an object’s state by transferring resources from another object, typically an rvalue. Its signature follows the special-member pattern `X& operator=(X&&)`. Alongside the destructor, copy constructor, copy assignment operator, and move constructor, it forms part of the rule of five. section 6.1.4 section 6.1.1
Use these relationships to reason about whether move assignment is available and useful:
- Defining none of the special members lets the compiler default all six, following the rule of zero. section 6.1.1
- Defining a destructor, copy operation, or resource-management behavior may require explicitly considering move assignment and the other members under the rule of five. section 6.1.4
- When a type cannot be moved, vector `push_back` may use copying instead, losing a move-based optimization opportunity. section 6.1.4
Listing 6.10 Type traits to check for special member functions
#include <type_traits>
void check_properties()
{
... #1
static_assert(
!std::is_default_constructible_v<Race::Blob>
); #2
static_assert(
std::is_destructible_v<Race::Blob>
); #2
static_assert(
!std::is_copy_constructible_v<Race::Blob>
); #2
static_assert(
!std::is_copy_assignable_v<Race::Blob>
); #2
static_assert(
!std::is_move_constructible_v<Race::Blob>
); #2
static_assert(
!std::is_move_assignable_v<Race::Blob>
); #2
static_assert(
std::has_virtual_destructor_v<Race::Blob>
); #3
}
Inspect compile-time checks that determine whether a type is move-assignable, alongside its constructibility, copyability, and destructibility. section 6.1.4
constexpr void push_back( const T& value ); constexpr void push_back( T&& value );
Compare copying and moving at a library boundary: `push_back` accepts either a const reference or an rvalue reference. section 6.1.4

