119 lines
5.4 KiB
Markdown
119 lines
5.4 KiB
Markdown
[iterator.cust]
|
||
|
||
# 24 Iterators library [[iterators]](./#iterators)
|
||
|
||
## 24.3 Iterator requirements [[iterator.requirements]](iterator.requirements#iterator.cust)
|
||
|
||
### 24.3.3 Customization point objects [iterator.cust]
|
||
|
||
#### [24.3.3.1](#move) ranges::iter_move [[iterator.cust.move]](iterator.cust.move)
|
||
|
||
[1](#move-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1149)
|
||
|
||
The name ranges::iter_move denotes
|
||
a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#move-1.sentence-1)
|
||
|
||
The expression ranges::iter_move(E) for a subexpression E is
|
||
expression-equivalent to:
|
||
|
||
- [(1.1)](#move-1.1)
|
||
|
||
iter_move(E), ifE has class or enumeration type anditer_move(E) is a well-formed expression when treated as an unevaluated operand,
|
||
where the meaning of iter_move is established as-if by performing
|
||
argument-dependent lookup only ([[basic.lookup.argdep]](basic.lookup.argdep "6.5.4 Argument-dependent name lookup"))[.](#move-1.1.sentence-1)
|
||
|
||
- [(1.2)](#move-1.2)
|
||
|
||
Otherwise, if the expression *E is well-formed:
|
||
* [(1.2.1)](#move-1.2.1)
|
||
|
||
if *E is an lvalue, std::move(*E);
|
||
|
||
* [(1.2.2)](#move-1.2.2)
|
||
|
||
otherwise, *E[.](#move-1.2.sentence-1)
|
||
|
||
- [(1.3)](#move-1.3)
|
||
|
||
Otherwise, ranges::iter_move(E) is ill-formed[.](#move-1.3.sentence-1)
|
||
[*Note [1](#move-note-1)*:
|
||
This case can result in substitution failure when ranges::iter_move(E) appears in the immediate context of a template instantiation[.](#move-1.3.sentence-2)
|
||
â *end note*]
|
||
|
||
[2](#move-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1175)
|
||
|
||
If ranges::iter_move(E) is not equal to *E,
|
||
the program is ill-formed, no diagnostic required[.](#move-2.sentence-1)
|
||
|
||
#### [24.3.3.2](#swap) ranges::iter_swap [[iterator.cust.swap]](iterator.cust.swap)
|
||
|
||
[1](#swap-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1182)
|
||
|
||
The name ranges::iter_swap denotes
|
||
a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))
|
||
that exchanges the values ([[concept.swappable]](concept.swappable "18.4.9 Concept swappable")) denoted by its
|
||
arguments[.](#swap-1.sentence-1)
|
||
|
||
[2](#swap-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1188)
|
||
|
||
Let *iter-exchange-move* be the exposition-only function template:
|
||
|
||
[ð](#swap-itemdecl:1)
|
||
|
||
`template<class X, class Y>
|
||
constexpr iter_value_t<X> iter-exchange-move(X&& x, Y&& y)
|
||
noexcept(noexcept(iter_value_t<X>(iter_move(x))) &&
|
||
noexcept(*x = iter_move(y)));
|
||
`
|
||
|
||
[3](#swap-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1198)
|
||
|
||
*Effects*: Equivalent to:iter_value_t<X> old_value(iter_move(x));*x = iter_move(y);return old_value;
|
||
|
||
[4](#swap-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1208)
|
||
|
||
The expression ranges::iter_swap(E1, E2) for subexpressionsE1 and E2 is expression-equivalent to:
|
||
|
||
- [(4.1)](#swap-4.1)
|
||
|
||
(void)iter_swap(E1, E2), if eitherE1 or E2 has class or enumeration type anditer_swap(E1, E2) is a well-formed expression
|
||
with overload resolution performed in a context that includes the declarationtemplate<class I1, class I2>void iter_swap(I1, I2) = delete; and does not include a declaration of ranges::iter_swap[.](#swap-4.1.sentence-1)
|
||
If the function selected by overload resolution does not exchange the values
|
||
denoted by E1 and E2,
|
||
the program is ill-formed, no diagnostic required[.](#swap-4.1.sentence-2)
|
||
[*Note [1](#swap-note-1)*:
|
||
This precludes calling unconstrained std::iter_swap[.](#swap-4.1.sentence-3)
|
||
When the deleted
|
||
overload is viable, program-defined overloads need to be more
|
||
specialized ([[temp.func.order]](temp.func.order "13.7.7.3 Partial ordering of function templates")) to be selected[.](#swap-4.1.sentence-4)
|
||
â *end note*]
|
||
|
||
- [(4.2)](#swap-4.2)
|
||
|
||
Otherwise, if the types of E1 and E2 each model[indirectly_readable](iterator.concept.readable#concept:indirectly_readable "24.3.4.2 Concept indirectly_readable [iterator.concept.readable]"), and if the reference types of E1 and E2 model [swappable_with](concept.swappable#concept:swappable_with "18.4.9 Concept swappable [concept.swappable]") ([[concept.swappable]](concept.swappable "18.4.9 Concept swappable")),
|
||
then ranges::swap(*E1, *E2)[.](#swap-4.2.sentence-1)
|
||
|
||
- [(4.3)](#swap-4.3)
|
||
|
||
Otherwise, if the types T1 and T2 of E1 andE2 model [indirectly_movable_storable](alg.req.ind.move#concept:indirectly_movable_storable "24.3.7.2 Concept indirectly_movable [alg.req.ind.move]")<T1, T2> and[indirectly_movable_storable](alg.req.ind.move#concept:indirectly_movable_storable "24.3.7.2 Concept indirectly_movable [alg.req.ind.move]")<T2, T1>, then(void)(*E1 = *iter-exchange-move*(E2, E1)),
|
||
except that E1 is evaluated only once[.](#swap-4.3.sentence-1)
|
||
|
||
- [(4.4)](#swap-4.4)
|
||
|
||
Otherwise, ranges::iter_swap(E1, E2) is ill-formed[.](#swap-4.4.sentence-1)
|
||
[*Note [2](#swap-note-2)*:
|
||
This case can result in substitution failure when ranges::iter_swap(E1, E2) appears in the immediate context of a template instantiation[.](#swap-4.4.sentence-2)
|
||
â *end note*]
|