From Jason Turner

[range.to.input]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2irwv4q0/{from.md → to.md} +228 -0
tmp/tmp2irwv4q0/{from.md → to.md} RENAMED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### To input view <a id="range.to.input">[[range.to.input]]</a>
2
+
3
+ #### Overview <a id="range.to.input.overview">[[range.to.input.overview]]</a>
4
+
5
+ `to_input_view` presents a view of an underlying sequence as an
6
+ input-only non-common range.
7
+
8
+ [*Note 1*: This is useful to avoid overhead that can be necessary to
9
+ provide support for the operations needed for greater iterator
10
+ strength. — *end note*]
11
+
12
+ The name `views::to_input` denotes a range adaptor object
13
+ [[range.adaptor.object]]. Let `E` be an expression and let `T` be
14
+ `decltype((E))`. The expression `views::to_input(E)` is
15
+ expression-equivalent to:
16
+
17
+ - `views::all(E)` if `T` models `input_range`, does not satisfy
18
+ `common_range`, and does not satisfy `forward_range`.
19
+ - Otherwise, `to_input_view(E)`.
20
+
21
+ #### Class template `to_input_view` <a id="range.to.input.view">[[range.to.input.view]]</a>
22
+
23
+ ``` cpp
24
+ namespace std::ranges {
25
+ template<input_range V>
26
+ requires view<V>
27
+ class to_input_view : public view_interface<to_input_view<V>> {
28
+ V base_ = V(); // exposition only
29
+
30
+ // [range.to.input.iterator], class template to_input_view::iterator
31
+ template<bool Const> class iterator; // exposition only
32
+
33
+ public:
34
+ to_input_view() requires default_initializable<V> = default;
35
+ constexpr explicit to_input_view(V base);
36
+
37
+ constexpr V base() const & requires copy_constructible<V> { return base_; }
38
+ constexpr V base() && { return std::move(base_); }
39
+
40
+ constexpr auto begin() requires (!simple-view<V>);
41
+ constexpr auto begin() const requires range<const V>;
42
+
43
+ constexpr auto end() requires (!simple-view<V>);
44
+ constexpr auto end() const requires range<const V>;
45
+
46
+ constexpr auto size() requires sized_range<V>;
47
+ constexpr auto size() const requires sized_range<const V>;
48
+
49
+ constexpr auto reserve_hint() requires approximately_sized_range<V>;
50
+ constexpr auto reserve_hint() const requires approximately_sized_range<const V>;
51
+ };
52
+
53
+ template<class R>
54
+ to_input_view(R&&) -> to_input_view<views::all_t<R>>;
55
+ }
56
+ ```
57
+
58
+ ``` cpp
59
+ constexpr explicit to_input_view(V base);
60
+ ```
61
+
62
+ *Effects:* Initializes *base\_* with `std::move(base)`.
63
+
64
+ ``` cpp
65
+ constexpr auto begin() requires (!simple-view<V>);
66
+ ```
67
+
68
+ *Effects:* Equivalent to:
69
+ `return `*`iterator`*`<false>(ranges::begin(`*`base_`*`));`
70
+
71
+ ``` cpp
72
+ constexpr auto begin() const requires range<const V>;
73
+ ```
74
+
75
+ *Effects:* Equivalent to:
76
+ `return `*`iterator`*`<true>(ranges::begin(`*`base_`*`));`
77
+
78
+ ``` cpp
79
+ constexpr auto end() requires (!simple-view<V>);
80
+ constexpr auto end() const requires range<const V>;
81
+ ```
82
+
83
+ *Effects:* Equivalent to: `return ranges::end(`*`base_`*`);`
84
+
85
+ ``` cpp
86
+ constexpr auto size() requires sized_range<V>;
87
+ constexpr auto size() const requires sized_range<const V>;
88
+ ```
89
+
90
+ *Effects:* Equivalent to: `return ranges::size(`*`base_`*`);`
91
+
92
+ ``` cpp
93
+ constexpr auto reserve_hint() requires approximately_sized_range<V>;
94
+ constexpr auto reserve_hint() const requires approximately_sized_range<const V>;
95
+ ```
96
+
97
+ *Effects:* Equivalent to: `return ranges::reserve_hint(`*`base_`*`);`
98
+
99
+ #### Class template `to_input_view::iterator` <a id="range.to.input.iterator">[[range.to.input.iterator]]</a>
100
+
101
+ ``` cpp
102
+ namespace std::ranges {
103
+ template<input_range V>
104
+ requires view<V>
105
+ template<bool Const>
106
+ class to_input_view<V>::iterator {
107
+ using Base = maybe-const<Const, V>; // exposition only
108
+
109
+ iterator_t<Base> current_ = iterator_t<Base>(); // exposition only
110
+
111
+ constexpr explicit iterator(iterator_t<Base> current); // exposition only
112
+
113
+ public:
114
+ using difference_type = range_difference_t<Base>;
115
+ using value_type = range_value_t<Base>;
116
+ using iterator_concept = input_iterator_tag;
117
+
118
+ iterator() requires default_initializable<iterator_t<Base>> = default;
119
+
120
+ iterator(iterator&&) = default;
121
+ iterator& operator=(iterator&&) = default;
122
+
123
+ constexpr iterator(iterator<!Const> i)
124
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
125
+
126
+ constexpr iterator_t<Base> base() &&;
127
+ constexpr const iterator_t<Base>& base() const & noexcept;
128
+
129
+ constexpr decltype(auto) operator*() const { return *current_; }
130
+
131
+ constexpr iterator& operator++();
132
+ constexpr void operator++(int);
133
+
134
+ friend constexpr bool operator==(const iterator& x, const sentinel_t<Base>& y);
135
+
136
+ friend constexpr difference_type operator-(const sentinel_t<Base>& y, const iterator& x)
137
+ requires sized_sentinel_for<sentinel_t<Base>, iterator_t<Base>>;
138
+ friend constexpr difference_type operator-(const iterator& x, const sentinel_t<Base>& y)
139
+ requires sized_sentinel_for<sentinel_t<Base>, iterator_t<Base>>;
140
+
141
+ friend constexpr range_rvalue_reference_t<Base> iter_move(const iterator& i)
142
+ noexcept(noexcept(ranges::iter_move(i.current_)));
143
+
144
+ friend constexpr void iter_swap(const iterator& x, const iterator& y)
145
+ noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
146
+ requires indirectly_swappable<iterator_t<Base>>;
147
+ };
148
+ }
149
+ ```
150
+
151
+ ``` cpp
152
+ constexpr explicit iterator(iterator_t<Base> current);
153
+ ```
154
+
155
+ *Effects:* Initializes *current\_* with `std::move(current)`.
156
+
157
+ ``` cpp
158
+ constexpr iterator(iterator<!Const> i)
159
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
160
+ ```
161
+
162
+ *Effects:* Initializes *current\_* with `std::move(i.`*`current_`*`)`.
163
+
164
+ ``` cpp
165
+ constexpr iterator_t<Base> base() &&;
166
+ ```
167
+
168
+ *Returns:* `std::move(`*`current_`*`)`.
169
+
170
+ ``` cpp
171
+ constexpr const iterator_t<Base>& base() const & noexcept;
172
+ ```
173
+
174
+ *Returns:* *current\_*.
175
+
176
+ ``` cpp
177
+ constexpr iterator& operator++();
178
+ ```
179
+
180
+ *Effects:* Equivalent to:
181
+
182
+ ``` cpp
183
+ ++current_;
184
+ return *this;
185
+ ```
186
+
187
+ ``` cpp
188
+ constexpr void operator++(int);
189
+ ```
190
+
191
+ *Effects:* Equivalent to: `++*this;`
192
+
193
+ ``` cpp
194
+ friend constexpr bool operator==(const iterator& x, const sentinel_t<Base>& y);
195
+ ```
196
+
197
+ *Returns:* `x.`*`current_`*` == y`.
198
+
199
+ ``` cpp
200
+ friend constexpr difference_type operator-(const sentinel_t<Base>& y, const iterator& x)
201
+ requires sized_sentinel_for<sentinel_t<Base>, iterator_t<Base>>;
202
+ ```
203
+
204
+ *Returns:* `y - x.`*`current_`*.
205
+
206
+ ``` cpp
207
+ friend constexpr difference_type operator-(const iterator& x, const sentinel_t<Base>& y)
208
+ requires sized_sentinel_for<sentinel_t<Base>, iterator_t<Base>>;
209
+ ```
210
+
211
+ *Returns:* `x.`*`current_`*` - y`.
212
+
213
+ ``` cpp
214
+ friend constexpr range_rvalue_reference_t<Base> iter_move(const iterator& i)
215
+ noexcept(noexcept(ranges::iter_move(i.current_)));
216
+ ```
217
+
218
+ *Effects:* Equivalent to: `return ranges::iter_move(i.`*`current_`*`);`
219
+
220
+ ``` cpp
221
+ friend constexpr void iter_swap(const iterator& x, const iterator& y)
222
+ noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
223
+ requires indirectly_swappable<iterator_t<Base>>;
224
+ ```
225
+
226
+ *Effects:* Equivalent to:
227
+ `ranges::iter_swap(x.`*`current_`*`, y.`*`current_`*`);`
228
+