7 Concepts library [concepts.lib]

7.3 Core language concepts [concepts.lib.corelang]

7.3.10 Concept Assignable [concepts.lib.corelang.assignable]

template <class T, class U> concept bool Assignable = is_lvalue_reference<T>::value && // see below CommonReference< const remove_reference_t<T>&, const remove_reference_t<U>&> && requires(T t, U&& u) { { t = std::forward<U>(u) } -> Same<T>&&; };

Let t be an lvalue that refers to an object o such that decltype((t)) is T, and u an expression such that decltype((u)) is U. Let u2 be a distinct object that is equal to u. Assignable<T, U> is satisfied only if

  • addressof(t = u) == addressof(o).

  • After evaluating t = u:

    • t is equal to u2, unless u is a non-const xvalue that refers to o.

    • If u is a non-const xvalue, the resulting state of the object to which it refers is valid but unspecified ( ISO/IEC 14882:2014 §[lib.types.movedfrom]).

    • Otherwise, if u is a glvalue, the object to which it refers is not modified.

There need not be any subsumption relationship between Assignable<T, U> and is_lvalue_reference<T>::value.

Note: 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 ]