tmp/tmpf2uogcj3/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Concept <a id="concept.assignable">[[concept.assignable]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
template<class LHS, class RHS>
|
| 5 |
+
concept assignable_from =
|
| 6 |
+
is_lvalue_reference_v<LHS> &&
|
| 7 |
+
common_reference_with<const remove_reference_t<LHS>&, const remove_reference_t<RHS>&> &&
|
| 8 |
+
requires(LHS lhs, RHS&& rhs) {
|
| 9 |
+
{ lhs = std::forward<RHS>(rhs) } -> same_as<LHS>;
|
| 10 |
+
};
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
Let:
|
| 14 |
+
|
| 15 |
+
- `lhs` be an lvalue that refers to an object `lcopy` such that
|
| 16 |
+
`decltype((lhs))` is `LHS`,
|
| 17 |
+
- `rhs` be an expression such that `decltype((rhs))` is `RHS`, and
|
| 18 |
+
- `rcopy` be a distinct object that is equal to `rhs`.
|
| 19 |
+
|
| 20 |
+
`LHS` and `RHS` model `assignable_from<LHS, RHS>` only if
|
| 21 |
+
|
| 22 |
+
- `addressof(lhs = rhs) == addressof(lcopy)`.
|
| 23 |
+
- After evaluating `lhs = rhs`:
|
| 24 |
+
- `lhs` is equal to `rcopy`, unless `rhs` is a non-const xvalue that
|
| 25 |
+
refers to `lcopy`.
|
| 26 |
+
- If `rhs` is a non-`const` xvalue, the resulting state of the object
|
| 27 |
+
to which it refers is valid but unspecified [[lib.types.movedfrom]].
|
| 28 |
+
- Otherwise, if `rhs` is a glvalue, the object to which it refers is
|
| 29 |
+
not modified.
|
| 30 |
+
|
| 31 |
+
[*Note 1*: Assignment need not be a total
|
| 32 |
+
function [[structure.requirements]]; in particular, if assignment to an
|
| 33 |
+
object `x` can result in a modification of some other object `y`, then
|
| 34 |
+
`x = y` is likely not in the domain of `=`. — *end note*]
|
| 35 |
+
|