From Jason Turner

[range.filter.iterator]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp674iwvyg/{from.md → to.md} +178 -0
tmp/tmp674iwvyg/{from.md → to.md} RENAMED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class `filter_view::iterator` <a id="range.filter.iterator">[[range.filter.iterator]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<input_range V, indirect_unary_predicate<iterator_t<V>> Pred>
6
+ requires view<V> && is_object_v<Pred>
7
+ class filter_view<V, Pred>::iterator {
8
+ private:
9
+ iterator_t<V> current_ = iterator_t<V>(); // exposition only
10
+ filter_view* parent_ = nullptr; // exposition only
11
+ public:
12
+ using iterator_concept = see below;
13
+ using iterator_category = see below;
14
+ using value_type = range_value_t<V>;
15
+ using difference_type = range_difference_t<V>;
16
+
17
+ iterator() = default;
18
+ constexpr iterator(filter_view& parent, iterator_t<V> current);
19
+
20
+ constexpr iterator_t<V> base() const &
21
+ requires copyable<iterator_t<V>>;
22
+ constexpr iterator_t<V> base() &&;
23
+ constexpr range_reference_t<V> operator*() const;
24
+ constexpr iterator_t<V> operator->() const
25
+ requires has-arrow<iterator_t<V>> && copyable<iterator_t<V>>;
26
+
27
+ constexpr iterator& operator++();
28
+ constexpr void operator++(int);
29
+ constexpr iterator operator++(int) requires forward_range<V>;
30
+
31
+ constexpr iterator& operator--() requires bidirectional_range<V>;
32
+ constexpr iterator operator--(int) requires bidirectional_range<V>;
33
+
34
+ friend constexpr bool operator==(const iterator& x, const iterator& y)
35
+ requires equality_comparable<iterator_t<V>>;
36
+
37
+ friend constexpr range_rvalue_reference_t<V> iter_move(const iterator& i)
38
+ noexcept(noexcept(ranges::iter_move(i.current_)));
39
+ friend constexpr void iter_swap(const iterator& x, const iterator& y)
40
+ noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
41
+ requires indirectly_swappable<iterator_t<V>>;
42
+ };
43
+ }
44
+ ```
45
+
46
+ Modification of the element a `filter_view::iterator` denotes is
47
+ permitted, but results in undefined behavior if the resulting value does
48
+ not satisfy the filter predicate.
49
+
50
+ `iterator::iterator_concept` is defined as follows:
51
+
52
+ - If `V` models `bidirectional_range`, then `iterator_concept` denotes
53
+ `bidirectional_iterator_tag`.
54
+ - Otherwise, if `V` models `forward_range`, then `iterator_concept`
55
+ denotes `forward_iterator_tag`.
56
+ - Otherwise, `iterator_concept` denotes `input_iterator_tag`.
57
+
58
+ `iterator::iterator_category` is defined as follows:
59
+
60
+ - Let `C` denote the type
61
+ `iterator_traits<iterator_t<V>>::iterator_category`.
62
+ - If `C` models `derived_from<bidirectional_iterator_tag>`, then
63
+ `iterator_category` denotes `bidirectional_iterator_tag`.
64
+ - Otherwise, if `C` models `derived_from<forward_iterator_tag>`, then
65
+ `iterator_category` denotes `forward_iterator_tag`.
66
+ - Otherwise, `iterator_category` denotes `C`.
67
+
68
+ ``` cpp
69
+ constexpr iterator(filter_view& parent, iterator_t<V> current);
70
+ ```
71
+
72
+ *Effects:* Initializes *current\_* with `std::move(current)` and
73
+ *parent\_* with `addressof(parent)`.
74
+
75
+ ``` cpp
76
+ constexpr iterator_t<V> base() const &
77
+ requires copyable<iterator_t<V>>;
78
+ ```
79
+
80
+ *Effects:* Equivalent to: `return `*`current_`*`;`
81
+
82
+ ``` cpp
83
+ constexpr iterator_t<V> base() &&;
84
+ ```
85
+
86
+ *Effects:* Equivalent to: `return std::move(current_);`
87
+
88
+ ``` cpp
89
+ constexpr range_reference_t<V> operator*() const;
90
+ ```
91
+
92
+ *Effects:* Equivalent to: `return *`*`current_`*`;`
93
+
94
+ ``` cpp
95
+ constexpr iterator_t<V> operator->() const
96
+ requires has-arrow<iterator_t<V>> && copyable<iterator_t<V>>;
97
+ ```
98
+
99
+ *Effects:* Equivalent to: `return `*`current_`*`;`
100
+
101
+ ``` cpp
102
+ constexpr iterator& operator++();
103
+ ```
104
+
105
+ *Effects:* Equivalent to:
106
+
107
+ ``` cpp
108
+ current_ = ranges::find_if(std::move(++current_), ranges::end(parent_->base_),
109
+ ref(*parent_->pred_));
110
+ return *this;
111
+ ```
112
+
113
+ ``` cpp
114
+ constexpr void operator++(int);
115
+ ```
116
+
117
+ *Effects:* Equivalent to `++*this`.
118
+
119
+ ``` cpp
120
+ constexpr iterator operator++(int) requires forward_range<V>;
121
+ ```
122
+
123
+ *Effects:* Equivalent to:
124
+
125
+ ``` cpp
126
+ auto tmp = *this;
127
+ ++*this;
128
+ return tmp;
129
+ ```
130
+
131
+ ``` cpp
132
+ constexpr iterator& operator--() requires bidirectional_range<V>;
133
+ ```
134
+
135
+ *Effects:* Equivalent to:
136
+
137
+ ``` cpp
138
+ do
139
+ --current_;
140
+ while (!invoke(*parent_->pred_, *current_));
141
+ return *this;
142
+ ```
143
+
144
+ ``` cpp
145
+ constexpr iterator operator--(int) requires bidirectional_range<V>;
146
+ ```
147
+
148
+ *Effects:* Equivalent to:
149
+
150
+ ``` cpp
151
+ auto tmp = *this;
152
+ --*this;
153
+ return tmp;
154
+ ```
155
+
156
+ ``` cpp
157
+ friend constexpr bool operator==(const iterator& x, const iterator& y)
158
+ requires equality_comparable<iterator_t<V>>;
159
+ ```
160
+
161
+ *Effects:* Equivalent to: `return x.`*`current_`*` == y.`*`current_`*`;`
162
+
163
+ ``` cpp
164
+ friend constexpr range_rvalue_reference_t<V> iter_move(const iterator& i)
165
+ noexcept(noexcept(ranges::iter_move(i.current_)));
166
+ ```
167
+
168
+ *Effects:* Equivalent to: `return ranges::iter_move(i.`*`current_`*`);`
169
+
170
+ ``` cpp
171
+ friend constexpr void iter_swap(const iterator& x, const iterator& y)
172
+ noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
173
+ requires indirectly_swappable<iterator_t<V>>;
174
+ ```
175
+
176
+ *Effects:* Equivalent to
177
+ `ranges::iter_swap(x.`*`current_`*`, y.`*`current_`*`)`.
178
+