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.overview">[[range.istream.overview]]</a>
|
| 4 |
+
|
| 5 |
+
`basic_istream_view` models `input_range` and reads (using `operator>>`)
|
| 6 |
+
successive elements from its corresponding input stream.
|
| 7 |
+
|
| 8 |
+
[*Example 1*:
|
| 9 |
+
|
| 10 |
+
``` cpp
|
| 11 |
+
auto ints = istringstream{"0 1 2 3 4"};
|
| 12 |
+
ranges::copy(istream_view<int>(ints), ostream_iterator<int>{cout, "-"});
|
| 13 |
+
// prints 0-1-2-3-4-
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
— *end example*]
|
| 17 |
+
|
| 18 |
+
#### Class template `basic_istream_view` <a id="range.istream.view">[[range.istream.view]]</a>
|
| 19 |
+
|
| 20 |
+
``` cpp
|
| 21 |
+
namespace std::ranges {
|
| 22 |
+
template<class Val, class CharT, class Traits>
|
| 23 |
+
concept stream-extractable = // exposition only
|
| 24 |
+
requires(basic_istream<CharT, Traits>& is, Val& t) {
|
| 25 |
+
is >> t;
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
template<movable Val, class CharT, class Traits>
|
| 29 |
+
requires default_initializable<Val> &&
|
| 30 |
+
stream-extractable<Val, CharT, Traits>
|
| 31 |
+
class basic_istream_view : public view_interface<basic_istream_view<Val, CharT, Traits>> {
|
| 32 |
+
public:
|
| 33 |
+
basic_istream_view() = default;
|
| 34 |
+
constexpr explicit basic_istream_view(basic_istream<CharT, Traits>& stream);
|
| 35 |
+
|
| 36 |
+
constexpr auto begin()
|
| 37 |
+
{
|
| 38 |
+
if (stream_) {
|
| 39 |
+
*stream_ >> object_;
|
| 40 |
+
}
|
| 41 |
+
return iterator{*this};
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
constexpr default_sentinel_t end() const noexcept;
|
| 45 |
+
|
| 46 |
+
private:
|
| 47 |
+
struct iterator; // exposition only
|
| 48 |
+
basic_istream<CharT, Traits>* stream_ = nullptr; // exposition only
|
| 49 |
+
Val object_ = Val(); // exposition only
|
| 50 |
+
};
|
| 51 |
+
}
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
``` cpp
|
| 55 |
+
constexpr explicit basic_istream_view(basic_istream<CharT, Traits>& stream);
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
*Effects:* Initializes *stream\_* with `addressof(stream)`.
|
| 59 |
+
|
| 60 |
+
``` cpp
|
| 61 |
+
constexpr default_sentinel_t end() const noexcept;
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
*Effects:* Equivalent to: `return default_sentinel;`
|
| 65 |
+
|
| 66 |
+
``` cpp
|
| 67 |
+
template<class Val, class CharT, class Traits>
|
| 68 |
+
basic_istream_view<Val, CharT, Traits> istream_view(basic_istream<CharT, Traits>& s);
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
*Effects:* Equivalent to:
|
| 72 |
+
`return basic_istream_view<Val, CharT, Traits>{s};`
|
| 73 |
+
|
| 74 |
+
#### Class template `basic_istream_view::iterator` <a id="range.istream.iterator">[[range.istream.iterator]]</a>
|
| 75 |
+
|
| 76 |
+
``` cpp
|
| 77 |
+
namespace std::ranges {
|
| 78 |
+
template<movable Val, class CharT, class Traits>
|
| 79 |
+
requires default_initializable<Val> &&
|
| 80 |
+
stream-extractable<Val, CharT, Traits>
|
| 81 |
+
class basic_istream_view<Val, CharT, Traits>::iterator { // exposition only
|
| 82 |
+
public:
|
| 83 |
+
using iterator_concept = input_iterator_tag;
|
| 84 |
+
using difference_type = ptrdiff_t;
|
| 85 |
+
using value_type = Val;
|
| 86 |
+
|
| 87 |
+
iterator() = default;
|
| 88 |
+
constexpr explicit iterator(basic_istream_view& parent) noexcept;
|
| 89 |
+
|
| 90 |
+
iterator(const iterator&) = delete;
|
| 91 |
+
iterator(iterator&&) = default;
|
| 92 |
+
|
| 93 |
+
iterator& operator=(const iterator&) = delete;
|
| 94 |
+
iterator& operator=(iterator&&) = default;
|
| 95 |
+
|
| 96 |
+
iterator& operator++();
|
| 97 |
+
void operator++(int);
|
| 98 |
+
|
| 99 |
+
Val& operator*() const;
|
| 100 |
+
|
| 101 |
+
friend bool operator==(const iterator& x, default_sentinel_t);
|
| 102 |
+
|
| 103 |
+
private:
|
| 104 |
+
basic_istream_view* parent_ = nullptr; // exposition only
|
| 105 |
+
};
|
| 106 |
+
}
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
``` cpp
|
| 110 |
+
constexpr explicit iterator(basic_istream_view& parent) noexcept;
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
*Effects:* Initializes *parent\_* with `addressof(parent)`.
|
| 114 |
+
|
| 115 |
+
``` cpp
|
| 116 |
+
iterator& operator++();
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
*Preconditions:* *`parent_`*`->`*`stream_`*` != nullptr` is `true`.
|
| 120 |
+
|
| 121 |
+
*Effects:* Equivalent to:
|
| 122 |
+
|
| 123 |
+
``` cpp
|
| 124 |
+
*parent_->stream_>> parent_->object_;
|
| 125 |
+
return *this;
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
``` cpp
|
| 129 |
+
void operator++(int);
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
*Preconditions:* *`parent_`*`->`*`stream_`*` != nullptr` is `true`.
|
| 133 |
+
|
| 134 |
+
*Effects:* Equivalent to `++*this`.
|
| 135 |
+
|
| 136 |
+
``` cpp
|
| 137 |
+
Val& operator*() const;
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
*Preconditions:* *`parent_`*`->`*`stream_`*` != nullptr` is `true`.
|
| 141 |
+
|
| 142 |
+
*Effects:* Equivalent to: `return `*`parent_`*`->`*`object_`*`;`
|
| 143 |
+
|
| 144 |
+
``` cpp
|
| 145 |
+
friend bool operator==(const iterator& x, default_sentinel_t);
|
| 146 |
+
```
|
| 147 |
+
|
| 148 |
+
*Effects:* Equivalent to:
|
| 149 |
+
`return x.`*`parent_`*` == nullptr || !*x.`*`parent_`*`->`*`stream_`*`;`
|
| 150 |
+
|