@@ -117,53 +117,59 @@ The best way to create a `basic_istream_view` is by using the [`views::istream`]
117
117
### Example: `basic_istream_view`, `istream_view`, and `wistream_view`
118
118
119
119
```cpp
120
-
121
- ```cpp
122
- // requires /std:c++20 or later
123
120
#include <ranges>
124
121
#include <iostream>
125
122
#include <sstream>
126
123
127
124
int main()
128
125
{
129
126
// range adaptor
130
- std::istringstream doubles { "1.1 2.2 3.3 4.4 5.5" };
131
- for (const auto& elem : std::views::istream<double>(doubles ))
127
+ std::istringstream streamOfdoubles { "1.1 2.2 3.3 4.4 5.5" };
128
+ for (const auto& elem : std::views::istream<double>(streamOfdoubles ))
132
129
{
133
130
std::cout << elem << ' '; // 1.1 2.2 3.3 4.4 5.5
134
131
}
135
132
std::cout << '\n';
136
133
134
+ // range adaptor - create a wistream_view
135
+ std::wistringstream streamOfInts{ L"1 2 3 4 5" };
136
+ for (const auto& elem : std::views::istream<int>(streamOfInts))
137
+ {
138
+ std::cout << elem << ' '; // 1 2 3 4 5
139
+ }
140
+ std::cout << '\n';
141
+
137
142
// istream_view alias
138
143
std::istringstream cpu1{ "8 0 8 0" };
139
144
// equivalent std::ranges::istream_view<int, char>
140
- for (const auto& elem : std::ranges::istream_view<int>{cpu1})
145
+ for (const auto& elem : std::ranges::istream_view<int>{ cpu1 })
141
146
{
142
147
std::cout << elem; // 8080
143
148
}
144
149
std::cout << '\n';
145
-
150
+
146
151
// wistream_view alias
147
152
std::wistringstream cpu2{ L"6 5 0 2" };
148
153
// equivalent std::ranges::istream_view<int, wchar_t>
149
- for (const auto& elem : std::ranges::wistream_view<int>{cpu2})
154
+ for (const auto& elem : std::ranges::wistream_view<int>{ cpu2 })
150
155
{
151
156
std::cout << elem; // 6502
152
157
}
153
158
std::cout << '\n';
154
159
155
160
// specify all template arguments
156
161
std::wistringstream misc(L"S T L");
157
- std::ranges::basic_istream_view<wchar_t, wchar_t, std::char_traits<wchar_t>> basic{misc};
162
+ std::ranges::basic_istream_view<wchar_t, wchar_t, std::char_traits<wchar_t>> basic{ misc };
158
163
for (const auto& elem : basic)
159
164
{
160
- std::wcout << elem << ' '; // STL
165
+ std::wcout << elem << ' '; // S T L
161
166
}
162
167
}
163
168
```
164
169
165
170
``` output
166
171
1.1 2.2 3.3 4.4 5.5
172
+ 1 2 3 4 5
167
173
8080
168
174
6502
169
175
S T L
0 commit comments