tmp/tmpd39r8nrn/{from.md → to.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
####
|
| 2 |
|
| 3 |
This subclause provides definitions for swappable types and expressions.
|
| 4 |
In these definitions, let `t` denote an expression of type `T`, and let
|
| 5 |
`u` denote an expression of type `U`.
|
| 6 |
|
|
@@ -13,16 +13,15 @@ An object `t` is *swappable with* an object `u` if and only if:
|
|
| 13 |
and
|
| 14 |
- the object referred to by `u` has the value originally held by `t`.
|
| 15 |
|
| 16 |
The context in which `swap(t, u)` and `swap(u, t)` are evaluated shall
|
| 17 |
ensure that a binary non-member function named “swap” is selected via
|
| 18 |
-
overload resolution
|
| 19 |
|
| 20 |
-
- the two `swap` function templates defined in `<utility>`
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
[[basic.lookup.argdep]]).
|
| 24 |
|
| 25 |
[*Note 1*: If `T` and `U` are both fundamental types or arrays of
|
| 26 |
fundamental types and the declarations from the header `<utility>` are
|
| 27 |
in scope, the overall lookup set described above is equivalent to that
|
| 28 |
of the qualified name lookup applied to the expression `std::swap(t, u)`
|
|
@@ -33,14 +32,13 @@ swappable requirement includes the header `<utility>` to ensure an
|
|
| 33 |
appropriate evaluation context. — *end note*]
|
| 34 |
|
| 35 |
An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
|
| 36 |
with any rvalue or lvalue, respectively, of type `T`.
|
| 37 |
|
| 38 |
-
A type `X`
|
| 39 |
-
[[iterator.requirements]]
|
| 40 |
-
|
| 41 |
-
`*x` is swappable.
|
| 42 |
|
| 43 |
[*Example 1*:
|
| 44 |
|
| 45 |
User code can ensure that the evaluation of `swap` calls is performed in
|
| 46 |
an appropriate context under the various conditions as follows:
|
|
@@ -58,12 +56,12 @@ void value_swap(T&& t, U&& u) {
|
|
| 58 |
|
| 59 |
// Requires: lvalues of T shall be swappable.
|
| 60 |
template<class T>
|
| 61 |
void lv_swap(T& t1, T& t2) {
|
| 62 |
using std::swap;
|
| 63 |
-
swap(t1, t2); // OK: uses swappable conditions for
|
| 64 |
-
}
|
| 65 |
|
| 66 |
namespace N {
|
| 67 |
struct A { int m; };
|
| 68 |
struct Proxy { A* a; };
|
| 69 |
Proxy proxy(A& a) { return Proxy{ &a }; }
|
|
|
|
| 1 |
+
#### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
|
| 2 |
|
| 3 |
This subclause provides definitions for swappable types and expressions.
|
| 4 |
In these definitions, let `t` denote an expression of type `T`, and let
|
| 5 |
`u` denote an expression of type `U`.
|
| 6 |
|
|
|
|
| 13 |
and
|
| 14 |
- the object referred to by `u` has the value originally held by `t`.
|
| 15 |
|
| 16 |
The context in which `swap(t, u)` and `swap(u, t)` are evaluated shall
|
| 17 |
ensure that a binary non-member function named “swap” is selected via
|
| 18 |
+
overload resolution [[over.match]] on a candidate set that includes:
|
| 19 |
|
| 20 |
+
- the two `swap` function templates defined in `<utility>` and
|
| 21 |
+
- the lookup set produced by argument-dependent lookup
|
| 22 |
+
[[basic.lookup.argdep]].
|
|
|
|
| 23 |
|
| 24 |
[*Note 1*: If `T` and `U` are both fundamental types or arrays of
|
| 25 |
fundamental types and the declarations from the header `<utility>` are
|
| 26 |
in scope, the overall lookup set described above is equivalent to that
|
| 27 |
of the qualified name lookup applied to the expression `std::swap(t, u)`
|
|
|
|
| 32 |
appropriate evaluation context. — *end note*]
|
| 33 |
|
| 34 |
An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
|
| 35 |
with any rvalue or lvalue, respectively, of type `T`.
|
| 36 |
|
| 37 |
+
A type `X` meeting any of the iterator requirements
|
| 38 |
+
[[iterator.requirements]] meets the *Cpp17ValueSwappable* requirements
|
| 39 |
+
if, for any dereferenceable object `x` of type `X`, `*x` is swappable.
|
|
|
|
| 40 |
|
| 41 |
[*Example 1*:
|
| 42 |
|
| 43 |
User code can ensure that the evaluation of `swap` calls is performed in
|
| 44 |
an appropriate context under the various conditions as follows:
|
|
|
|
| 56 |
|
| 57 |
// Requires: lvalues of T shall be swappable.
|
| 58 |
template<class T>
|
| 59 |
void lv_swap(T& t1, T& t2) {
|
| 60 |
using std::swap;
|
| 61 |
+
swap(t1, t2); // OK: uses swappable conditions for lvalues of type T
|
| 62 |
+
}
|
| 63 |
|
| 64 |
namespace N {
|
| 65 |
struct A { int m; };
|
| 66 |
struct Proxy { A* a; };
|
| 67 |
Proxy proxy(A& a) { return Proxy{ &a }; }
|