std::experimental::ranges::Assignable - cppreference.com (original) (raw)

The concept Assignable<T, U> specifies that an expression of the type and value category specified by U can be assigned to an lvalue expression whose type is specified by T.

Given

Assignable<T, U> is satisfied only if

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

[edit] Equality preservation

An expression is equality preserving if it results in equal outputs given equal inputs.

Every expression required to be equality preserving is further required to be stable: two evaluations of such an expression with the same input objects must have equal outputs absent any explicit intervening modification of those input objects.

Unless noted otherwise, every expression used in a requires-expression is required to be equality preserving and stable, and the evaluation of the expression may only modify its non-constant operands. Operands that are constant must not be modified.

[edit] Notes

A deduction constraint of the form { expression } -> Same<T>&& effectively requires decltype((expression))&& to be the exact same type as T&&. This constrains both the expression's type and its value category.

Assignment need not be a total function. In particular, if assigning to some object x can cause some other object y to be modified, then x = y is likely not in the domain of =. This typically happens if the right operand is owned directly or indirectly by the left operand (e.g., with smart pointers to nodes in a node-based data structure, or with something like std::vector<std::any>).