tmp/tmpyuqr8vhb/{from.md → to.md}
RENAMED
|
@@ -7,25 +7,28 @@ expression’s result and all operands modified by the expression. For the
|
|
| 7 |
purposes of this subclause, the operands of an expression are the
|
| 8 |
largest subexpressions that include only:
|
| 9 |
|
| 10 |
- an *id-expression* [[expr.prim.id]], and
|
| 11 |
- invocations of the library function templates `std::move`,
|
| 12 |
-
`std::forward`, and `std::declval`
|
| 13 |
|
| 14 |
[*Example 1*: The operands of the expression `a = std::move(b)` are `a`
|
| 15 |
and `std::move(b)`. — *end example*]
|
| 16 |
|
| 17 |
-
Not all input values need be valid for a given expression
|
| 18 |
-
integers `a` and `b`, the expression `a / b` is not well-defined when
|
| 19 |
-
`b` is `0`. This does not preclude the expression `a / b` being
|
| 20 |
-
equality-preserving. The *domain* of an expression is the set of input
|
| 21 |
-
values for which the expression is required to be well-defined.
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
[*Note 1*: This requirement allows generic code to reason about the
|
| 29 |
current values of objects based on knowledge of the prior values as
|
| 30 |
observed via equality-preserving expressions. It effectively forbids
|
| 31 |
spontaneous changes to an object, changes to an object from another
|
|
@@ -33,18 +36,18 @@ thread of execution, changes to an object as side effects of
|
|
| 33 |
non-modifying expressions, and changes to an object as side effects of
|
| 34 |
modifying a distinct object if those changes could be observable to a
|
| 35 |
library function via an equality-preserving expression that is required
|
| 36 |
to be valid for that object. — *end note*]
|
| 37 |
|
| 38 |
-
Expressions declared in a *requires-expression* in
|
| 39 |
-
required to be equality-preserving, except for those annotated with
|
| 40 |
-
comment “not required to be equality-preserving.” An expression so
|
| 41 |
annotated may be equality-preserving, but is not required to be so.
|
| 42 |
|
| 43 |
An expression that may alter the value of one or more of its inputs in a
|
| 44 |
manner observable to equality-preserving expressions is said to modify
|
| 45 |
-
those inputs.
|
| 46 |
which expressions declared in a *requires-expression* modify which
|
| 47 |
inputs: except where otherwise specified, an expression operand that is
|
| 48 |
a non-constant lvalue or rvalue may be modified. Operands that are
|
| 49 |
constant lvalues or rvalues are required to not be modified. For the
|
| 50 |
purposes of this subclause, the cv-qualification and value category of
|
|
@@ -58,11 +61,11 @@ rvalue for the given operand are also required except where such an
|
|
| 58 |
expression variation is explicitly required with differing semantics.
|
| 59 |
These *implicit expression variations* are required to meet the semantic
|
| 60 |
requirements of the declared expression. The extent to which an
|
| 61 |
implementation validates the syntax of the variations is unspecified.
|
| 62 |
|
| 63 |
-
[*Example
|
| 64 |
|
| 65 |
``` cpp
|
| 66 |
template<class T> concept C = requires(T a, T b, const T c, const T d) {
|
| 67 |
c == d; // #1
|
| 68 |
a = std::move(b); // #2
|
|
@@ -98,11 +101,11 @@ For the above example:
|
|
| 98 |
second operand, since expression \#2 already specifies exactly such an
|
| 99 |
expression explicitly.
|
| 100 |
|
| 101 |
— *end example*]
|
| 102 |
|
| 103 |
-
[*Example
|
| 104 |
|
| 105 |
The following type `T` meets the explicitly stated syntactic
|
| 106 |
requirements of concept `C` above but does not meet the additional
|
| 107 |
implicit requirements:
|
| 108 |
|
|
|
|
| 7 |
purposes of this subclause, the operands of an expression are the
|
| 8 |
largest subexpressions that include only:
|
| 9 |
|
| 10 |
- an *id-expression* [[expr.prim.id]], and
|
| 11 |
- invocations of the library function templates `std::move`,
|
| 12 |
+
`std::forward`, and `std::declval` [[forward]], [[declval]].
|
| 13 |
|
| 14 |
[*Example 1*: The operands of the expression `a = std::move(b)` are `a`
|
| 15 |
and `std::move(b)`. — *end example*]
|
| 16 |
|
| 17 |
+
Not all input values need be valid for a given expression.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
[*Example 2*: For integers `a` and `b`, the expression `a / b` is not
|
| 20 |
+
well-defined when `b` is `0`. This does not preclude the expression
|
| 21 |
+
`a / b` being equality-preserving. — *end example*]
|
| 22 |
+
|
| 23 |
+
The *domain* of an expression is the set of input values for which the
|
| 24 |
+
expression is required to be well-defined.
|
| 25 |
+
|
| 26 |
+
Expressions required to be equality-preserving are further required to
|
| 27 |
+
be stable: two evaluations of such an expression with the same input
|
| 28 |
+
objects are required to have equal outputs absent any explicit
|
| 29 |
+
intervening modification of those input objects.
|
| 30 |
|
| 31 |
[*Note 1*: This requirement allows generic code to reason about the
|
| 32 |
current values of objects based on knowledge of the prior values as
|
| 33 |
observed via equality-preserving expressions. It effectively forbids
|
| 34 |
spontaneous changes to an object, changes to an object from another
|
|
|
|
| 36 |
non-modifying expressions, and changes to an object as side effects of
|
| 37 |
modifying a distinct object if those changes could be observable to a
|
| 38 |
library function via an equality-preserving expression that is required
|
| 39 |
to be valid for that object. — *end note*]
|
| 40 |
|
| 41 |
+
Expressions declared in a *requires-expression* in the library clauses
|
| 42 |
+
are required to be equality-preserving, except for those annotated with
|
| 43 |
+
the comment “not required to be equality-preserving.” An expression so
|
| 44 |
annotated may be equality-preserving, but is not required to be so.
|
| 45 |
|
| 46 |
An expression that may alter the value of one or more of its inputs in a
|
| 47 |
manner observable to equality-preserving expressions is said to modify
|
| 48 |
+
those inputs. The library clauses use a notational convention to specify
|
| 49 |
which expressions declared in a *requires-expression* modify which
|
| 50 |
inputs: except where otherwise specified, an expression operand that is
|
| 51 |
a non-constant lvalue or rvalue may be modified. Operands that are
|
| 52 |
constant lvalues or rvalues are required to not be modified. For the
|
| 53 |
purposes of this subclause, the cv-qualification and value category of
|
|
|
|
| 61 |
expression variation is explicitly required with differing semantics.
|
| 62 |
These *implicit expression variations* are required to meet the semantic
|
| 63 |
requirements of the declared expression. The extent to which an
|
| 64 |
implementation validates the syntax of the variations is unspecified.
|
| 65 |
|
| 66 |
+
[*Example 3*:
|
| 67 |
|
| 68 |
``` cpp
|
| 69 |
template<class T> concept C = requires(T a, T b, const T c, const T d) {
|
| 70 |
c == d; // #1
|
| 71 |
a = std::move(b); // #2
|
|
|
|
| 101 |
second operand, since expression \#2 already specifies exactly such an
|
| 102 |
expression explicitly.
|
| 103 |
|
| 104 |
— *end example*]
|
| 105 |
|
| 106 |
+
[*Example 4*:
|
| 107 |
|
| 108 |
The following type `T` meets the explicitly stated syntactic
|
| 109 |
requirements of concept `C` above but does not meet the additional
|
| 110 |
implicit requirements:
|
| 111 |
|