tmp/tmp4mopoafl/{from.md → to.md}
RENAMED
|
@@ -2,91 +2,71 @@
|
|
| 2 |
|
| 3 |
`ostream_iterator` writes (using `operator<<`) successive elements onto
|
| 4 |
the output stream from which it was constructed. If it was constructed
|
| 5 |
with `charT*` as a constructor argument, this string, called a
|
| 6 |
*delimiter string*, is written to the stream after every `T` is written.
|
| 7 |
-
It is not possible to get a value out of the output iterator. Its only
|
| 8 |
-
use is as an output iterator in situations like
|
| 9 |
-
|
| 10 |
-
``` cpp
|
| 11 |
-
while (first != last)
|
| 12 |
-
*result++ = *first++;
|
| 13 |
-
```
|
| 14 |
-
|
| 15 |
-
`ostream_iterator`
|
| 16 |
-
|
| 17 |
-
is defined as:
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
namespace std {
|
| 21 |
template<class T, class charT = char, class traits = char_traits<charT>>
|
| 22 |
class ostream_iterator {
|
| 23 |
public:
|
| 24 |
using iterator_category = output_iterator_tag;
|
| 25 |
using value_type = void;
|
| 26 |
-
using difference_type =
|
| 27 |
using pointer = void;
|
| 28 |
using reference = void;
|
| 29 |
using char_type = charT;
|
| 30 |
using traits_type = traits;
|
| 31 |
using ostream_type = basic_ostream<charT,traits>;
|
| 32 |
|
|
|
|
| 33 |
ostream_iterator(ostream_type& s);
|
| 34 |
ostream_iterator(ostream_type& s, const charT* delimiter);
|
| 35 |
ostream_iterator(const ostream_iterator& x);
|
| 36 |
~ostream_iterator();
|
|
|
|
| 37 |
ostream_iterator& operator=(const T& value);
|
| 38 |
|
| 39 |
ostream_iterator& operator*();
|
| 40 |
ostream_iterator& operator++();
|
| 41 |
ostream_iterator& operator++(int);
|
|
|
|
| 42 |
private:
|
| 43 |
-
basic_ostream<charT,traits>* out_stream;
|
| 44 |
-
const charT* delim;
|
| 45 |
};
|
| 46 |
}
|
| 47 |
```
|
| 48 |
|
| 49 |
-
####
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
ostream_iterator(ostream_type& s);
|
| 53 |
```
|
| 54 |
|
| 55 |
*Effects:* Initializes `out_stream` with `addressof(s)` and `delim` with
|
| 56 |
-
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
ostream_iterator(ostream_type& s, const charT* delimiter);
|
| 60 |
```
|
| 61 |
|
| 62 |
*Effects:* Initializes `out_stream` with `addressof(s)` and `delim` with
|
| 63 |
`delimiter`.
|
| 64 |
|
| 65 |
-
|
| 66 |
-
ostream_iterator(const ostream_iterator& x);
|
| 67 |
-
```
|
| 68 |
-
|
| 69 |
-
*Effects:* Constructs a copy of `x`.
|
| 70 |
-
|
| 71 |
-
``` cpp
|
| 72 |
-
~ostream_iterator();
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
*Effects:* The iterator is destroyed.
|
| 76 |
-
|
| 77 |
-
#### `ostream_iterator` operations <a id="ostream.iterator.ops">[[ostream.iterator.ops]]</a>
|
| 78 |
|
| 79 |
``` cpp
|
| 80 |
ostream_iterator& operator=(const T& value);
|
| 81 |
```
|
| 82 |
|
| 83 |
*Effects:* As if by:
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
*out_stream << value;
|
| 87 |
-
if (delim
|
| 88 |
*out_stream << delim;
|
| 89 |
return *this;
|
| 90 |
```
|
| 91 |
|
| 92 |
``` cpp
|
|
|
|
| 2 |
|
| 3 |
`ostream_iterator` writes (using `operator<<`) successive elements onto
|
| 4 |
the output stream from which it was constructed. If it was constructed
|
| 5 |
with `charT*` as a constructor argument, this string, called a
|
| 6 |
*delimiter string*, is written to the stream after every `T` is written.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
``` cpp
|
| 9 |
namespace std {
|
| 10 |
template<class T, class charT = char, class traits = char_traits<charT>>
|
| 11 |
class ostream_iterator {
|
| 12 |
public:
|
| 13 |
using iterator_category = output_iterator_tag;
|
| 14 |
using value_type = void;
|
| 15 |
+
using difference_type = ptrdiff_t;
|
| 16 |
using pointer = void;
|
| 17 |
using reference = void;
|
| 18 |
using char_type = charT;
|
| 19 |
using traits_type = traits;
|
| 20 |
using ostream_type = basic_ostream<charT,traits>;
|
| 21 |
|
| 22 |
+
constexpr ostream_iterator() noexcept = default;
|
| 23 |
ostream_iterator(ostream_type& s);
|
| 24 |
ostream_iterator(ostream_type& s, const charT* delimiter);
|
| 25 |
ostream_iterator(const ostream_iterator& x);
|
| 26 |
~ostream_iterator();
|
| 27 |
+
ostream_iterator& operator=(const ostream_iterator&) = default;
|
| 28 |
ostream_iterator& operator=(const T& value);
|
| 29 |
|
| 30 |
ostream_iterator& operator*();
|
| 31 |
ostream_iterator& operator++();
|
| 32 |
ostream_iterator& operator++(int);
|
| 33 |
+
|
| 34 |
private:
|
| 35 |
+
basic_ostream<charT,traits>* out_stream = nullptr; // exposition only
|
| 36 |
+
const charT* delim = nullptr; // exposition only
|
| 37 |
};
|
| 38 |
}
|
| 39 |
```
|
| 40 |
|
| 41 |
+
#### Constructors and destructor <a id="ostream.iterator.cons.des">[[ostream.iterator.cons.des]]</a>
|
| 42 |
|
| 43 |
``` cpp
|
| 44 |
ostream_iterator(ostream_type& s);
|
| 45 |
```
|
| 46 |
|
| 47 |
*Effects:* Initializes `out_stream` with `addressof(s)` and `delim` with
|
| 48 |
+
`nullptr`.
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
ostream_iterator(ostream_type& s, const charT* delimiter);
|
| 52 |
```
|
| 53 |
|
| 54 |
*Effects:* Initializes `out_stream` with `addressof(s)` and `delim` with
|
| 55 |
`delimiter`.
|
| 56 |
|
| 57 |
+
#### Operations <a id="ostream.iterator.ops">[[ostream.iterator.ops]]</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
ostream_iterator& operator=(const T& value);
|
| 61 |
```
|
| 62 |
|
| 63 |
*Effects:* As if by:
|
| 64 |
|
| 65 |
``` cpp
|
| 66 |
*out_stream << value;
|
| 67 |
+
if (delim)
|
| 68 |
*out_stream << delim;
|
| 69 |
return *this;
|
| 70 |
```
|
| 71 |
|
| 72 |
``` cpp
|