From Jason Turner

[iterator.cust.swap]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_cqnj6aw/{from.md → to.md} +53 -0
tmp/tmp_cqnj6aw/{from.md → to.md} RENAMED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### `ranges::iter_swap` <a id="iterator.cust.swap">[[iterator.cust.swap]]</a>
2
+
3
+ The name `ranges::iter_swap` denotes a customization point object
4
+ [[customization.point.object]] that exchanges the values
5
+ [[concept.swappable]] denoted by its arguments.
6
+
7
+ Let *`iter-exchange-move`* be the exposition-only function:
8
+
9
+ ``` cpp
10
+ template<class X, class Y>
11
+ constexpr iter_value_t<X> iter-exchange-move(X&& x, Y&& y)
12
+ noexcept(noexcept(iter_value_t<X>(iter_move(x))) &&
13
+ noexcept(*x = iter_move(y)));
14
+ ```
15
+
16
+ *Effects:* Equivalent to:
17
+
18
+ ``` cpp
19
+ iter_value_t<X> old_value(iter_move(x));
20
+ *x = iter_move(y);
21
+ return old_value;
22
+ ```
23
+
24
+ The expression `ranges::iter_swap(E1, E2)` for subexpressions `E1` and
25
+ `E2` is expression-equivalent to:
26
+
27
+ - `(void)iter_swap(E1, E2)`, if either `E1` or `E2` has class or
28
+ enumeration type and `iter_swap(E1, E2)` is a well-formed expression
29
+ with overload resolution performed in a context that includes the
30
+ declaration
31
+ ``` cpp
32
+ template<class I1, class I2>
33
+ void iter_swap(I1, I2) = delete;
34
+ ```
35
+
36
+ and does not include a declaration of `ranges::iter_swap`. If the
37
+ function selected by overload resolution does not exchange the values
38
+ denoted by `E1` and `E2`, the program is ill-formed, no diagnostic
39
+ required.
40
+ - Otherwise, if the types of `E1` and `E2` each model
41
+ `indirectly_readable`, and if the reference types of `E1` and `E2`
42
+ model `swappable_with` [[concept.swappable]], then
43
+ `ranges::swap(*E1, *E2)`.
44
+ - Otherwise, if the types `T1` and `T2` of `E1` and `E2` model
45
+ `indirectly_movable_storable<T1, T2>` and
46
+ `indirectly_movable_storable<T2, T1>`, then
47
+ `(void)(*E1 = iter-exchange-move(E2, E1))`, except that `E1` is
48
+ evaluated only once.
49
+ - Otherwise, `ranges::iter_swap(E1, E2)` is ill-formed. \[*Note 1*: This
50
+ case can result in substitution failure when
51
+ `ranges::iter_swap(E1, E2)` appears in the immediate context of a
52
+ template instantiation. — *end note*]
53
+