You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| `is >> stream_range(lr)` | reference to `is` | Each element in `lr` is overwritten by a value read from `is`. Stops immediately when `bool(is)` is `false`. |
188
-
| `is >> stream_range(rr)` | reference to `is` | Each element in `rr` is overwritten by a value read from `is`. Stops immediately when `bool(is)` is `false`. |
189
-
| `os << stream_range(cr)` | reference to `os` | Each element in `cr` is written to `os`. `cr` is not copied. Stops immediately when `bool(os)` is `false`. |
190
-
| `os << stream_range(rr)` | reference to `os` | `rr` is moved and stored internally, then each element is written to `os`. Stops immediately when `bool(os)` is `false`. |
191
-
| `os << stream_range(cr, cd)` | reference to `os` | Each element in `cr` is written to `os`, with `cd` written between each element. `cr` is not copied. Stops immediately when `bool(os)` is `false`. |
192
-
| `os << stream_range(cr, rd)` | reference to `os` | Each element in `cr` is written to `os`, with `rd` written between each element. `cr` is not copied. Stops immediately when `bool(os)` is `false`. |
193
-
| `os << stream_range(rr, cd)` | reference to `os` | `rr` is moved and stored internally, then each element is written to `os`, with `cd` written between each element. Stops immediately when `bool(os)` is `false`. |
194
-
| `os << stream_range(rr, rd)` | reference to `os` | `rr` is moved and stored internally, then each element is written to `os`, with `rd` written between each element. Stops immediately when `bool(os)` is `false`. |
195
-
196
-
This proposal focuses on ranges supplied as is, rather than the "traditional"
197
-
C++ way: as a pair of iterators. The intention is that if you *do* wish to use
198
-
a pair of iterators, you can do this (assuming something like N3350 gets
199
-
accepted):
153
+
Unlike with the copy/stream-iterator model, stream errors are detected and
154
+
handled properly. The stream's conversion to `bool` is checked after each write
155
+
(attempt), and if it is `false`, the function stops attemping to write and
156
+
returns immediately. You can query the number of elements that were written
157
+
with the `count()` function:
200
158
201
159
```C++
202
-
os << std::stream_range(std::make_range(begin, end));
203
-
os << std::stream_range(std::make_range(begin, end), delimiter);
160
+
auto p = std::stream_range(r);
161
+
out << r;
162
+
std::cout << p.count() << " items were written of " << r.size() << " in the range.";
204
163
```
205
164
206
-
However, for completeness, I have also included the following forms:
165
+
Also unlike with the copy/stream-iterator model, formatting is handled correctly.
166
+
With the following code:
207
167
208
168
```C++
209
-
os << std::stream_iterator_range(begin, end);
210
-
os << std::stream_iterator_range(begin, end, delimiter);
0 commit comments