From Jason Turner

[swappable.requirements]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmps_ssxpcy/{from.md → to.md} +13 -9
tmp/tmps_ssxpcy/{from.md → to.md} RENAMED
@@ -20,28 +20,30 @@ overload resolution ([[over.match]]) on a candidate set that includes:
20
  - the two `swap` function templates defined in `<utility>` (
21
  [[utility]]) and
22
  - the lookup set produced by argument-dependent lookup (
23
  [[basic.lookup.argdep]]).
24
 
25
- If `T` and `U` are both fundamental types or arrays of fundamental types
26
- and the declarations from the header `<utility>` are in scope, the
27
- overall lookup set described above is equivalent to that of the
28
- qualified name lookup applied to the expression `std::swap(t, u)` or
29
- `std::swap(u, t)` as appropriate.
30
 
31
- It is unspecified whether a library component that has a swappable
32
- requirement includes the header `<utility>` to ensure an appropriate
33
- evaluation context.
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` satisfying any of the iterator requirements (
39
  [[iterator.requirements]]) satisfies the requirements of
40
  `ValueSwappable` if, for any dereferenceable object `x` of type `X`,
41
  `*x` is swappable.
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:
45
 
46
  ``` cpp
47
  #include <utility>
@@ -54,11 +56,11 @@ void value_swap(T&& t, U&& u) {
54
  // for rvalues and lvalues
55
  }
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
62
  } // lvalues of type T
63
 
64
  namespace N {
@@ -82,5 +84,7 @@ int main() {
82
  value_swap(a1, proxy(a2));
83
  assert(a1.m == -5 && a2.m == 5);
84
  }
85
  ```
86
 
 
 
 
20
  - the two `swap` function templates defined in `<utility>` (
21
  [[utility]]) and
22
  - the lookup set produced by argument-dependent lookup (
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)`
29
+ or `std::swap(u, t)` as appropriate. — *end note*]
30
 
31
+ [*Note 2*: It is unspecified whether a library component that has a
32
+ 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` satisfying any of the iterator requirements (
39
  [[iterator.requirements]]) satisfies the requirements of
40
  `ValueSwappable` if, for any dereferenceable object `x` of type `X`,
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:
47
 
48
  ``` cpp
49
  #include <utility>
 
56
  // for rvalues and lvalues
57
  }
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
  } // lvalues of type T
65
 
66
  namespace N {
 
84
  value_swap(a1, proxy(a2));
85
  assert(a1.m == -5 && a2.m == 5);
86
  }
87
  ```
88
 
89
+ — *end example*]
90
+