tmp/tmp49fsfqp_/{from.md → to.md}
RENAMED
|
@@ -12,35 +12,42 @@ object, which is the only legitimate iterator to be used for the end
|
|
| 12 |
condition. The result of `operator*` on an end-of-stream iterator is not
|
| 13 |
defined. For any other iterator value a `const T&` is returned. The
|
| 14 |
result of `operator->` on an end-of-stream iterator is not defined. For
|
| 15 |
any other iterator value a `const T*` is returned. The behavior of a
|
| 16 |
program that applies `operator++()` to an end-of-stream iterator is
|
| 17 |
-
undefined. It is impossible to store things into istream iterators.
|
|
|
|
|
|
|
| 18 |
|
| 19 |
Two end-of-stream iterators are always equal. An end-of-stream iterator
|
| 20 |
is not equal to a non-end-of-stream iterator. Two non-end-of-stream
|
| 21 |
iterators are equal when they are constructed from the same stream.
|
| 22 |
|
| 23 |
``` cpp
|
| 24 |
namespace std {
|
| 25 |
template <class T, class charT = char, class traits = char_traits<charT>,
|
| 26 |
class Distance = ptrdiff_t>
|
| 27 |
-
class istream_iterator
|
| 28 |
-
public iterator<input_iterator_tag, T, Distance, const T*, const T&> {
|
| 29 |
public:
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
istream_iterator(istream_type& s);
|
| 35 |
istream_iterator(const istream_iterator& x) = default;
|
| 36 |
~istream_iterator() = default;
|
| 37 |
|
| 38 |
const T& operator*() const;
|
| 39 |
const T* operator->() const;
|
| 40 |
-
istream_iterator
|
| 41 |
-
istream_iterator
|
| 42 |
private:
|
| 43 |
basic_istream<charT,traits>* in_stream; // exposition only
|
| 44 |
T value; // exposition only
|
| 45 |
};
|
| 46 |
|
|
@@ -54,77 +61,80 @@ namespace std {
|
|
| 54 |
```
|
| 55 |
|
| 56 |
#### `istream_iterator` constructors and destructor <a id="istream.iterator.cons">[[istream.iterator.cons]]</a>
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
-
|
| 60 |
```
|
| 61 |
|
| 62 |
-
*Effects:* Constructs the end-of-stream iterator. If
|
| 63 |
-
|
|
|
|
| 64 |
|
| 65 |
-
`in_stream == 0`.
|
| 66 |
|
| 67 |
``` cpp
|
| 68 |
istream_iterator(istream_type& s);
|
| 69 |
```
|
| 70 |
|
| 71 |
-
*Effects:* Initializes
|
| 72 |
-
during construction or the first time it is referenced.
|
| 73 |
|
| 74 |
-
`in_stream ==
|
| 75 |
|
| 76 |
``` cpp
|
| 77 |
istream_iterator(const istream_iterator& x) = default;
|
| 78 |
```
|
| 79 |
|
| 80 |
-
*Effects:* Constructs a copy of `x`. If
|
| 81 |
-
|
|
|
|
| 82 |
|
| 83 |
-
`in_stream == x.in_stream`.
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
~istream_iterator() = default;
|
| 87 |
```
|
| 88 |
|
| 89 |
-
*Effects:* The iterator is destroyed. If
|
| 90 |
-
|
|
|
|
| 91 |
|
| 92 |
#### `istream_iterator` operations <a id="istream.iterator.ops">[[istream.iterator.ops]]</a>
|
| 93 |
|
| 94 |
``` cpp
|
| 95 |
const T& operator*() const;
|
| 96 |
```
|
| 97 |
|
| 98 |
-
*Returns:*
|
| 99 |
|
| 100 |
``` cpp
|
| 101 |
const T* operator->() const;
|
| 102 |
```
|
| 103 |
|
| 104 |
-
*Returns:* `
|
| 105 |
|
| 106 |
``` cpp
|
| 107 |
-
istream_iterator
|
| 108 |
```
|
| 109 |
|
| 110 |
*Requires:* `in_stream != 0`.
|
| 111 |
|
| 112 |
-
*Effects:* `*in_stream >>value`
|
| 113 |
|
| 114 |
*Returns:* `*this`.
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
-
istream_iterator
|
| 118 |
```
|
| 119 |
|
| 120 |
*Requires:* `in_stream != 0`.
|
| 121 |
|
| 122 |
-
*Effects:*
|
| 123 |
|
| 124 |
``` cpp
|
| 125 |
-
istream_iterator
|
| 126 |
*in_stream >> value;
|
| 127 |
return (tmp);
|
| 128 |
```
|
| 129 |
|
| 130 |
``` cpp
|
|
|
|
| 12 |
condition. The result of `operator*` on an end-of-stream iterator is not
|
| 13 |
defined. For any other iterator value a `const T&` is returned. The
|
| 14 |
result of `operator->` on an end-of-stream iterator is not defined. For
|
| 15 |
any other iterator value a `const T*` is returned. The behavior of a
|
| 16 |
program that applies `operator++()` to an end-of-stream iterator is
|
| 17 |
+
undefined. It is impossible to store things into istream iterators. The
|
| 18 |
+
type `T` shall meet the `DefaultConstructible`, `CopyConstructible`, and
|
| 19 |
+
`CopyAssignable` requirements.
|
| 20 |
|
| 21 |
Two end-of-stream iterators are always equal. An end-of-stream iterator
|
| 22 |
is not equal to a non-end-of-stream iterator. Two non-end-of-stream
|
| 23 |
iterators are equal when they are constructed from the same stream.
|
| 24 |
|
| 25 |
``` cpp
|
| 26 |
namespace std {
|
| 27 |
template <class T, class charT = char, class traits = char_traits<charT>,
|
| 28 |
class Distance = ptrdiff_t>
|
| 29 |
+
class istream_iterator {
|
|
|
|
| 30 |
public:
|
| 31 |
+
using iterator_category = input_iterator_tag;
|
| 32 |
+
using value_type = T;
|
| 33 |
+
using difference_type = Distance;
|
| 34 |
+
using pointer = const T*;
|
| 35 |
+
using reference = const T&;
|
| 36 |
+
using char_type = charT;
|
| 37 |
+
using traits_type = traits;
|
| 38 |
+
using istream_type = basic_istream<charT,traits>;
|
| 39 |
+
|
| 40 |
+
constexpr istream_iterator();
|
| 41 |
istream_iterator(istream_type& s);
|
| 42 |
istream_iterator(const istream_iterator& x) = default;
|
| 43 |
~istream_iterator() = default;
|
| 44 |
|
| 45 |
const T& operator*() const;
|
| 46 |
const T* operator->() const;
|
| 47 |
+
istream_iterator& operator++();
|
| 48 |
+
istream_iterator operator++(int);
|
| 49 |
private:
|
| 50 |
basic_istream<charT,traits>* in_stream; // exposition only
|
| 51 |
T value; // exposition only
|
| 52 |
};
|
| 53 |
|
|
|
|
| 61 |
```
|
| 62 |
|
| 63 |
#### `istream_iterator` constructors and destructor <a id="istream.iterator.cons">[[istream.iterator.cons]]</a>
|
| 64 |
|
| 65 |
``` cpp
|
| 66 |
+
constexpr istream_iterator();
|
| 67 |
```
|
| 68 |
|
| 69 |
+
*Effects:* Constructs the end-of-stream iterator. If
|
| 70 |
+
`is_trivially_default_constructible_v<T>` is `true`, then this
|
| 71 |
+
constructor is a constexpr constructor.
|
| 72 |
|
| 73 |
+
*Postconditions:* `in_stream == 0`.
|
| 74 |
|
| 75 |
``` cpp
|
| 76 |
istream_iterator(istream_type& s);
|
| 77 |
```
|
| 78 |
|
| 79 |
+
*Effects:* Initializes `in_stream` with `addressof(s)`. `value` may be
|
| 80 |
+
initialized during construction or the first time it is referenced.
|
| 81 |
|
| 82 |
+
*Postconditions:* `in_stream == addressof(s)`.
|
| 83 |
|
| 84 |
``` cpp
|
| 85 |
istream_iterator(const istream_iterator& x) = default;
|
| 86 |
```
|
| 87 |
|
| 88 |
+
*Effects:* Constructs a copy of `x`. If
|
| 89 |
+
`is_trivially_copy_constructible_v<T>` is `true`, then this constructor
|
| 90 |
+
is a trivial copy constructor.
|
| 91 |
|
| 92 |
+
*Postconditions:* `in_stream == x.in_stream`.
|
| 93 |
|
| 94 |
``` cpp
|
| 95 |
~istream_iterator() = default;
|
| 96 |
```
|
| 97 |
|
| 98 |
+
*Effects:* The iterator is destroyed. If
|
| 99 |
+
`is_trivially_destructible_v<T>` is `true`, then this destructor is a
|
| 100 |
+
trivial destructor.
|
| 101 |
|
| 102 |
#### `istream_iterator` operations <a id="istream.iterator.ops">[[istream.iterator.ops]]</a>
|
| 103 |
|
| 104 |
``` cpp
|
| 105 |
const T& operator*() const;
|
| 106 |
```
|
| 107 |
|
| 108 |
+
*Returns:* `value`.
|
| 109 |
|
| 110 |
``` cpp
|
| 111 |
const T* operator->() const;
|
| 112 |
```
|
| 113 |
|
| 114 |
+
*Returns:* `addressof(operator*())`.
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
+
istream_iterator& operator++();
|
| 118 |
```
|
| 119 |
|
| 120 |
*Requires:* `in_stream != 0`.
|
| 121 |
|
| 122 |
+
*Effects:* As if by: `*in_stream >> value;`
|
| 123 |
|
| 124 |
*Returns:* `*this`.
|
| 125 |
|
| 126 |
``` cpp
|
| 127 |
+
istream_iterator operator++(int);
|
| 128 |
```
|
| 129 |
|
| 130 |
*Requires:* `in_stream != 0`.
|
| 131 |
|
| 132 |
+
*Effects:* As if by:
|
| 133 |
|
| 134 |
``` cpp
|
| 135 |
+
istream_iterator tmp = *this;
|
| 136 |
*in_stream >> value;
|
| 137 |
return (tmp);
|
| 138 |
```
|
| 139 |
|
| 140 |
``` cpp
|