tmp/tmpk7tt2nfq/{from.md → to.md}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
## Stream iterators <a id="stream.iterators">[[stream.iterators]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
To make it possible for algorithmic templates to work directly with
|
| 4 |
input/output streams, appropriate iterator-like class templates are
|
| 5 |
provided.
|
| 6 |
|
| 7 |
[*Example 1*:
|
|
@@ -17,10 +19,12 @@ the partial sums onto `cout`.
|
|
| 17 |
|
| 18 |
— *end example*]
|
| 19 |
|
| 20 |
### Class template `istream_iterator` <a id="istream.iterator">[[istream.iterator]]</a>
|
| 21 |
|
|
|
|
|
|
|
| 22 |
The class template `istream_iterator` is an input iterator
|
| 23 |
[[input.iterators]] that reads successive elements from the input stream
|
| 24 |
for which it was constructed.
|
| 25 |
|
| 26 |
``` cpp
|
|
@@ -39,11 +43,11 @@ namespace std {
|
|
| 39 |
using istream_type = basic_istream<charT,traits>;
|
| 40 |
|
| 41 |
constexpr istream_iterator();
|
| 42 |
constexpr istream_iterator(default_sentinel_t);
|
| 43 |
istream_iterator(istream_type& s);
|
| 44 |
-
istream_iterator(const istream_iterator& x)
|
| 45 |
~istream_iterator() = default;
|
| 46 |
istream_iterator& operator=(const istream_iterator&) = default;
|
| 47 |
|
| 48 |
const T& operator*() const;
|
| 49 |
const T* operator->() const;
|
|
@@ -84,17 +88,21 @@ istream_iterator(istream_type& s);
|
|
| 84 |
|
| 85 |
*Effects:* Initializes `in_stream` with `addressof(s)`,
|
| 86 |
value-initializes `value`, and then calls `operator++()`.
|
| 87 |
|
| 88 |
``` cpp
|
| 89 |
-
istream_iterator(const istream_iterator& x)
|
| 90 |
```
|
| 91 |
|
| 92 |
-
*
|
|
|
|
| 93 |
|
| 94 |
-
*Remarks:*
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
``` cpp
|
| 98 |
~istream_iterator() = default;
|
| 99 |
```
|
| 100 |
|
|
@@ -162,10 +170,12 @@ friend bool operator==(const istream_iterator& i, default_sentinel_t);
|
|
| 162 |
|
| 163 |
*Returns:* `!i.in_stream`.
|
| 164 |
|
| 165 |
### Class template `ostream_iterator` <a id="ostream.iterator">[[ostream.iterator]]</a>
|
| 166 |
|
|
|
|
|
|
|
| 167 |
`ostream_iterator` writes (using `operator<<`) successive elements onto
|
| 168 |
the output stream from which it was constructed. If it was constructed
|
| 169 |
with `charT*` as a constructor argument, this string, called a
|
| 170 |
*delimiter string*, is written to the stream after every `T` is written.
|
| 171 |
|
|
@@ -181,11 +191,10 @@ namespace std {
|
|
| 181 |
using reference = void;
|
| 182 |
using char_type = charT;
|
| 183 |
using traits_type = traits;
|
| 184 |
using ostream_type = basic_ostream<charT,traits>;
|
| 185 |
|
| 186 |
-
constexpr ostream_iterator() noexcept = default;
|
| 187 |
ostream_iterator(ostream_type& s);
|
| 188 |
ostream_iterator(ostream_type& s, const charT* delimiter);
|
| 189 |
ostream_iterator(const ostream_iterator& x);
|
| 190 |
~ostream_iterator();
|
| 191 |
ostream_iterator& operator=(const ostream_iterator&) = default;
|
|
@@ -194,12 +203,12 @@ namespace std {
|
|
| 194 |
ostream_iterator& operator*();
|
| 195 |
ostream_iterator& operator++();
|
| 196 |
ostream_iterator& operator++(int);
|
| 197 |
|
| 198 |
private:
|
| 199 |
-
basic_ostream<charT,traits>* out_stream
|
| 200 |
-
const charT* delim
|
| 201 |
};
|
| 202 |
}
|
| 203 |
```
|
| 204 |
|
| 205 |
#### Constructors and destructor <a id="ostream.iterator.cons.des">[[ostream.iterator.cons.des]]</a>
|
|
@@ -246,10 +255,12 @@ ostream_iterator& operator++(int);
|
|
| 246 |
|
| 247 |
*Returns:* `*this`.
|
| 248 |
|
| 249 |
### Class template `istreambuf_iterator` <a id="istreambuf.iterator">[[istreambuf.iterator]]</a>
|
| 250 |
|
|
|
|
|
|
|
| 251 |
The class template `istreambuf_iterator` defines an input iterator
|
| 252 |
[[input.iterators]] that reads successive *characters* from the
|
| 253 |
streambuf for which it was constructed. `operator*` provides access to
|
| 254 |
the current input character, if any. Each time `operator++` is
|
| 255 |
evaluated, the iterator advances to the next input character. If the end
|
|
@@ -280,10 +291,11 @@ namespace std {
|
|
| 280 |
using traits_type = traits;
|
| 281 |
using int_type = typename traits::int_type;
|
| 282 |
using streambuf_type = basic_streambuf<charT,traits>;
|
| 283 |
using istream_type = basic_istream<charT,traits>;
|
| 284 |
|
|
|
|
| 285 |
class proxy; // exposition only
|
| 286 |
|
| 287 |
constexpr istreambuf_iterator() noexcept;
|
| 288 |
constexpr istreambuf_iterator(default_sentinel_t) noexcept;
|
| 289 |
istreambuf_iterator(const istreambuf_iterator&) noexcept = default;
|
|
@@ -405,10 +417,12 @@ friend bool operator==(const istreambuf_iterator& i, default_sentinel_t s);
|
|
| 405 |
|
| 406 |
*Returns:* `i.equal(s)`.
|
| 407 |
|
| 408 |
### Class template `ostreambuf_iterator` <a id="ostreambuf.iterator">[[ostreambuf.iterator]]</a>
|
| 409 |
|
|
|
|
|
|
|
| 410 |
The class template `ostreambuf_iterator` writes successive *characters*
|
| 411 |
onto the output stream from which it was constructed.
|
| 412 |
|
| 413 |
``` cpp
|
| 414 |
namespace std {
|
|
@@ -423,22 +437,21 @@ namespace std {
|
|
| 423 |
using char_type = charT;
|
| 424 |
using traits_type = traits;
|
| 425 |
using streambuf_type = basic_streambuf<charT,traits>;
|
| 426 |
using ostream_type = basic_ostream<charT,traits>;
|
| 427 |
|
| 428 |
-
constexpr ostreambuf_iterator() noexcept = default;
|
| 429 |
ostreambuf_iterator(ostream_type& s) noexcept;
|
| 430 |
ostreambuf_iterator(streambuf_type* s) noexcept;
|
| 431 |
ostreambuf_iterator& operator=(charT c);
|
| 432 |
|
| 433 |
ostreambuf_iterator& operator*();
|
| 434 |
ostreambuf_iterator& operator++();
|
| 435 |
ostreambuf_iterator& operator++(int);
|
| 436 |
bool failed() const noexcept;
|
| 437 |
|
| 438 |
private:
|
| 439 |
-
streambuf_type* sbuf_
|
| 440 |
};
|
| 441 |
}
|
| 442 |
```
|
| 443 |
|
| 444 |
#### Constructors <a id="ostreambuf.iter.cons">[[ostreambuf.iter.cons]]</a>
|
|
|
|
| 1 |
## Stream iterators <a id="stream.iterators">[[stream.iterators]]</a>
|
| 2 |
|
| 3 |
+
### General <a id="stream.iterators.general">[[stream.iterators.general]]</a>
|
| 4 |
+
|
| 5 |
To make it possible for algorithmic templates to work directly with
|
| 6 |
input/output streams, appropriate iterator-like class templates are
|
| 7 |
provided.
|
| 8 |
|
| 9 |
[*Example 1*:
|
|
|
|
| 19 |
|
| 20 |
— *end example*]
|
| 21 |
|
| 22 |
### Class template `istream_iterator` <a id="istream.iterator">[[istream.iterator]]</a>
|
| 23 |
|
| 24 |
+
#### General <a id="istream.iterator.general">[[istream.iterator.general]]</a>
|
| 25 |
+
|
| 26 |
The class template `istream_iterator` is an input iterator
|
| 27 |
[[input.iterators]] that reads successive elements from the input stream
|
| 28 |
for which it was constructed.
|
| 29 |
|
| 30 |
``` cpp
|
|
|
|
| 43 |
using istream_type = basic_istream<charT,traits>;
|
| 44 |
|
| 45 |
constexpr istream_iterator();
|
| 46 |
constexpr istream_iterator(default_sentinel_t);
|
| 47 |
istream_iterator(istream_type& s);
|
| 48 |
+
constexpr istream_iterator(const istream_iterator& x) noexcept(see below);
|
| 49 |
~istream_iterator() = default;
|
| 50 |
istream_iterator& operator=(const istream_iterator&) = default;
|
| 51 |
|
| 52 |
const T& operator*() const;
|
| 53 |
const T* operator->() const;
|
|
|
|
| 88 |
|
| 89 |
*Effects:* Initializes `in_stream` with `addressof(s)`,
|
| 90 |
value-initializes `value`, and then calls `operator++()`.
|
| 91 |
|
| 92 |
``` cpp
|
| 93 |
+
constexpr istream_iterator(const istream_iterator& x) noexcept(see below);
|
| 94 |
```
|
| 95 |
|
| 96 |
+
*Effects:* Initializes `in_stream` with `x.in_stream` and initializes
|
| 97 |
+
`value` with `x.value`.
|
| 98 |
|
| 99 |
+
*Remarks:* An invocation of this constructor may be used in a core
|
| 100 |
+
constant expression if and only if the initialization of `value` from
|
| 101 |
+
`x.value` is a constant subexpression [[defns.const.subexpr]]. The
|
| 102 |
+
exception specification is equivalent to
|
| 103 |
+
`is_nothrow_copy_constructible_v<T>`.
|
| 104 |
|
| 105 |
``` cpp
|
| 106 |
~istream_iterator() = default;
|
| 107 |
```
|
| 108 |
|
|
|
|
| 170 |
|
| 171 |
*Returns:* `!i.in_stream`.
|
| 172 |
|
| 173 |
### Class template `ostream_iterator` <a id="ostream.iterator">[[ostream.iterator]]</a>
|
| 174 |
|
| 175 |
+
#### General <a id="ostream.iterator.general">[[ostream.iterator.general]]</a>
|
| 176 |
+
|
| 177 |
`ostream_iterator` writes (using `operator<<`) successive elements onto
|
| 178 |
the output stream from which it was constructed. If it was constructed
|
| 179 |
with `charT*` as a constructor argument, this string, called a
|
| 180 |
*delimiter string*, is written to the stream after every `T` is written.
|
| 181 |
|
|
|
|
| 191 |
using reference = void;
|
| 192 |
using char_type = charT;
|
| 193 |
using traits_type = traits;
|
| 194 |
using ostream_type = basic_ostream<charT,traits>;
|
| 195 |
|
|
|
|
| 196 |
ostream_iterator(ostream_type& s);
|
| 197 |
ostream_iterator(ostream_type& s, const charT* delimiter);
|
| 198 |
ostream_iterator(const ostream_iterator& x);
|
| 199 |
~ostream_iterator();
|
| 200 |
ostream_iterator& operator=(const ostream_iterator&) = default;
|
|
|
|
| 203 |
ostream_iterator& operator*();
|
| 204 |
ostream_iterator& operator++();
|
| 205 |
ostream_iterator& operator++(int);
|
| 206 |
|
| 207 |
private:
|
| 208 |
+
basic_ostream<charT,traits>* out_stream; // exposition only
|
| 209 |
+
const charT* delim; // exposition only
|
| 210 |
};
|
| 211 |
}
|
| 212 |
```
|
| 213 |
|
| 214 |
#### Constructors and destructor <a id="ostream.iterator.cons.des">[[ostream.iterator.cons.des]]</a>
|
|
|
|
| 255 |
|
| 256 |
*Returns:* `*this`.
|
| 257 |
|
| 258 |
### Class template `istreambuf_iterator` <a id="istreambuf.iterator">[[istreambuf.iterator]]</a>
|
| 259 |
|
| 260 |
+
#### General <a id="istreambuf.iterator.general">[[istreambuf.iterator.general]]</a>
|
| 261 |
+
|
| 262 |
The class template `istreambuf_iterator` defines an input iterator
|
| 263 |
[[input.iterators]] that reads successive *characters* from the
|
| 264 |
streambuf for which it was constructed. `operator*` provides access to
|
| 265 |
the current input character, if any. Each time `operator++` is
|
| 266 |
evaluated, the iterator advances to the next input character. If the end
|
|
|
|
| 291 |
using traits_type = traits;
|
| 292 |
using int_type = typename traits::int_type;
|
| 293 |
using streambuf_type = basic_streambuf<charT,traits>;
|
| 294 |
using istream_type = basic_istream<charT,traits>;
|
| 295 |
|
| 296 |
+
// [istreambuf.iterator.proxy], class istreambuf_iterator::proxy
|
| 297 |
class proxy; // exposition only
|
| 298 |
|
| 299 |
constexpr istreambuf_iterator() noexcept;
|
| 300 |
constexpr istreambuf_iterator(default_sentinel_t) noexcept;
|
| 301 |
istreambuf_iterator(const istreambuf_iterator&) noexcept = default;
|
|
|
|
| 417 |
|
| 418 |
*Returns:* `i.equal(s)`.
|
| 419 |
|
| 420 |
### Class template `ostreambuf_iterator` <a id="ostreambuf.iterator">[[ostreambuf.iterator]]</a>
|
| 421 |
|
| 422 |
+
#### General <a id="ostreambuf.iterator.general">[[ostreambuf.iterator.general]]</a>
|
| 423 |
+
|
| 424 |
The class template `ostreambuf_iterator` writes successive *characters*
|
| 425 |
onto the output stream from which it was constructed.
|
| 426 |
|
| 427 |
``` cpp
|
| 428 |
namespace std {
|
|
|
|
| 437 |
using char_type = charT;
|
| 438 |
using traits_type = traits;
|
| 439 |
using streambuf_type = basic_streambuf<charT,traits>;
|
| 440 |
using ostream_type = basic_ostream<charT,traits>;
|
| 441 |
|
|
|
|
| 442 |
ostreambuf_iterator(ostream_type& s) noexcept;
|
| 443 |
ostreambuf_iterator(streambuf_type* s) noexcept;
|
| 444 |
ostreambuf_iterator& operator=(charT c);
|
| 445 |
|
| 446 |
ostreambuf_iterator& operator*();
|
| 447 |
ostreambuf_iterator& operator++();
|
| 448 |
ostreambuf_iterator& operator++(int);
|
| 449 |
bool failed() const noexcept;
|
| 450 |
|
| 451 |
private:
|
| 452 |
+
streambuf_type* sbuf_; // exposition only
|
| 453 |
};
|
| 454 |
}
|
| 455 |
```
|
| 456 |
|
| 457 |
#### Constructors <a id="ostreambuf.iter.cons">[[ostreambuf.iter.cons]]</a>
|