std::experimental::ranges::Assignable

From cppreference.com
< cpp‎ | experimental‎ | ranges
Experimental
Technical Specification
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
Experimental Non-TS
Pattern Matching
Linear Algebra
std::execution
Contracts
2D Graphics
template < class T, class U >

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

} ;
(ranges TS)

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

  • t, an lvalue of type std::remove_reference_t<T> that refers to an object o
  • u, an expression such that decltype((u)) is U
  • u2, a distinct object that is equal to u,

Assignable<T, U> is satisfied only if

  • std::addressof (t = u) == std::addressof (o)
  • After evaluating t = u:
    • t is equal to u2, unless u is a non-const xvalue that refers to o (i.e., the assignment is a self-move-assignment),
    • if u is a glvalue:
      • If it is a non-const xvalue, the object to which it refers is in a valid but unspecified state;
      • Otherwise, the object it refers to is not modified;

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

Equality preservation

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

  • The inputs to an expression consist of its operands.
  • The outputs of an expression consist of its result and all operands modified by the expression (if any).

Every expression required to be equality preserving is further required to be stable

Unless noted otherwise, every expression used in a requires-expression

Notes

A deduction constraint of the form { expression } - > Same<T> && effectively requires decltype((expression))&& to be the exact same type as T&&

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 >