liveBook · Manning

Is_move_assignable

As explained in Learn C++ by Example

is_move_assignable is a C++ type trait that determines whether an object of a type can be assigned from an rvalue of that type.

is_move_assignable is a C++ type trait that checks whether a type can be assigned from an rvalue of that type. section 6.1.4

Interpret the result carefully:

  • The trait tests whether assignment from an rvalue is possible; it does not prove that a move-assignment operator exists. section 6.1.4
  • A const lvalue-reference assignment function can accept an rvalue, so a reported positive result may represent copying rather than moving. section 6.1.4
  • A user-declared destructor can block implicit move operations, making a type appear assignable from a temporary without providing an actual move assignment operator. section 6.1.4

Checking Blob

A compile-time check can write static_assert(!std::is_move_assignable_v<Race::Blob>);. For Blob, disabled copy operations and missing move operations make assignment from an rvalue unavailable. section 6.1.4

How Learn C++ by Example covers it

How deep it goes
Distinguishes assignability from the presence of a move-assignment operator and explains misleading results caused by copying.
Examples
Uses Race::Blob and static_assert checks covering default construction, destruction, copying, move construction, and move assignment.
What it assumes
Assumes familiarity with C++ special member functions and rvalues while clarifying the trait’s behavior from its practical consequences.
What you can do after
Evaluate whether rvalue assignment is available while avoiding assumptions that the operation performs an actual move.
How it connects
Connects move assignment with rvalue references, copy assignment, special member functions, destructors, and the rule of five.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn C++ by Example. The section links point to the parts of the book it draws on.