17 Concepts library [concepts]

17.4 Language-related concepts [concepts.lang]

17.4.8 Concept Assignable [concept.assignable]

template<class LHS, class RHS> concept Assignable = is_lvalue_reference_v<LHS> && CommonReference<const remove_reference_t<LHS>&, const remove_reference_t<RHS>&> && requires(LHS lhs, RHS&& rhs) { lhs = std::forward<RHS>(rhs); requires Same<decltype(lhs = std::forward<RHS>(rhs)), LHS>; };
  • lhs be an lvalue that refers to an object lcopy such that decltype((lhs)) is LHS,
  • rhs be an expression such that decltype((rhs)) is RHS, and
  • rcopy be a distinct object that is equal to rhs.
Assignable<LHS, RHS> is satisfied only if
  • addressof(lhs = rhs) == addressof(lcopy).
  • After evaluating lhs = rhs:
    • lhs is equal to rcopy, unless rhs is a non-const xvalue that refers to lcopy.
    • If rhs is a non-const xvalue, the resulting state of the object to which it refers is valid but unspecified ([lib.types.movedfrom]).
    • Otherwise, if rhs is a glvalue, the object to which it refers is not modified.
Assignment need not be a total function ([structure.requirements]); in particular, if assignment to an object x can result in a modification of some other object y, then x = y is likely not in the domain of =.
end note