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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Span-based streams <a id="span.streams">[[span.streams]]</a>
|
| 2 |
+
|
| 3 |
+
### Overview <a id="span.streams.overview">[[span.streams.overview]]</a>
|
| 4 |
+
|
| 5 |
+
The header `<spanstream>` defines class templates and types that
|
| 6 |
+
associate stream buffers with objects whose types are specializations of
|
| 7 |
+
`span` as described in [[views.span]].
|
| 8 |
+
|
| 9 |
+
[*Note 1*: A user of these classes is responsible for ensuring that the
|
| 10 |
+
character sequence represented by the given `span` outlives the use of
|
| 11 |
+
the sequence by objects of the classes in subclause [[span.streams]].
|
| 12 |
+
Using multiple `basic_spanbuf` objects referring to overlapping
|
| 13 |
+
underlying sequences from different threads, where at least one
|
| 14 |
+
`basic_spanbuf` object is used for writing to the sequence, results in a
|
| 15 |
+
data race. — *end note*]
|
| 16 |
+
|
| 17 |
+
### Header `<spanstream>` synopsis <a id="spanstream.syn">[[spanstream.syn]]</a>
|
| 18 |
+
|
| 19 |
+
``` cpp
|
| 20 |
+
namespace std {
|
| 21 |
+
template<class charT, class traits = char_traits<charT>>
|
| 22 |
+
class basic_spanbuf;
|
| 23 |
+
|
| 24 |
+
template<class charT, class traits>
|
| 25 |
+
void swap(basic_spanbuf<charT, traits>& x, basic_spanbuf<charT, traits>& y);
|
| 26 |
+
|
| 27 |
+
using spanbuf = basic_spanbuf<char>;
|
| 28 |
+
using wspanbuf = basic_spanbuf<wchar_t>;
|
| 29 |
+
|
| 30 |
+
template<class charT, class traits = char_traits<charT>>
|
| 31 |
+
class basic_ispanstream;
|
| 32 |
+
|
| 33 |
+
template<class charT, class traits>
|
| 34 |
+
void swap(basic_ispanstream<charT, traits>& x, basic_ispanstream<charT, traits>& y);
|
| 35 |
+
|
| 36 |
+
using ispanstream = basic_ispanstream<char>;
|
| 37 |
+
using wispanstream = basic_ispanstream<wchar_t>;
|
| 38 |
+
|
| 39 |
+
template<class charT, class traits = char_traits<charT>>
|
| 40 |
+
class basic_ospanstream;
|
| 41 |
+
|
| 42 |
+
template<class charT, class traits>
|
| 43 |
+
void swap(basic_ospanstream<charT, traits>& x, basic_ospanstream<charT, traits>& y);
|
| 44 |
+
|
| 45 |
+
using ospanstream = basic_ospanstream<char>;
|
| 46 |
+
using wospanstream = basic_ospanstream<wchar_t>;
|
| 47 |
+
|
| 48 |
+
template<class charT, class traits = char_traits<charT>>
|
| 49 |
+
class basic_spanstream;
|
| 50 |
+
|
| 51 |
+
template<class charT, class traits>
|
| 52 |
+
void swap(basic_spanstream<charT, traits>& x, basic_spanstream<charT, traits>& y);
|
| 53 |
+
|
| 54 |
+
using spanstream = basic_spanstream<char>;
|
| 55 |
+
using wspanstream = basic_spanstream<wchar_t>;
|
| 56 |
+
}
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### Class template `basic_spanbuf` <a id="spanbuf">[[spanbuf]]</a>
|
| 60 |
+
|
| 61 |
+
#### General <a id="spanbuf.general">[[spanbuf.general]]</a>
|
| 62 |
+
|
| 63 |
+
``` cpp
|
| 64 |
+
namespace std {
|
| 65 |
+
template<class charT, class traits = char_traits<charT>>
|
| 66 |
+
class basic_spanbuf
|
| 67 |
+
: public basic_streambuf<charT, traits> {
|
| 68 |
+
public:
|
| 69 |
+
using char_type = charT;
|
| 70 |
+
using int_type = typename traits::int_type;
|
| 71 |
+
using pos_type = typename traits::pos_type;
|
| 72 |
+
using off_type = typename traits::off_type;
|
| 73 |
+
using traits_type = traits;
|
| 74 |
+
|
| 75 |
+
// [spanbuf.cons], constructors
|
| 76 |
+
basic_spanbuf() : basic_spanbuf(ios_base::in | ios_base::out) {}
|
| 77 |
+
explicit basic_spanbuf(ios_base::openmode which)
|
| 78 |
+
: basic_spanbuf(std::span<charT>(), which) {}
|
| 79 |
+
explicit basic_spanbuf(std::span<charT> s,
|
| 80 |
+
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 81 |
+
basic_spanbuf(const basic_spanbuf&) = delete;
|
| 82 |
+
basic_spanbuf(basic_spanbuf&& rhs);
|
| 83 |
+
|
| 84 |
+
// [spanbuf.assign], assignment and swap
|
| 85 |
+
basic_spanbuf& operator=(const basic_spanbuf&) = delete;
|
| 86 |
+
basic_spanbuf& operator=(basic_spanbuf&& rhs);
|
| 87 |
+
void swap(basic_spanbuf& rhs);
|
| 88 |
+
|
| 89 |
+
// [spanbuf.members], member functions
|
| 90 |
+
std::span<charT> span() const noexcept;
|
| 91 |
+
void span(std::span<charT> s) noexcept;
|
| 92 |
+
|
| 93 |
+
protected:
|
| 94 |
+
// [spanbuf.virtuals], overridden virtual functions
|
| 95 |
+
basic_streambuf<charT, traits>* setbuf(charT*, streamsize) override;
|
| 96 |
+
pos_type seekoff(off_type off, ios_base::seekdir way,
|
| 97 |
+
ios_base::openmode which = ios_base::in | ios_base::out) override;
|
| 98 |
+
pos_type seekpos(pos_type sp,
|
| 99 |
+
ios_base::openmode which = ios_base::in | ios_base::out) override;
|
| 100 |
+
|
| 101 |
+
private:
|
| 102 |
+
ios_base::openmode mode; // exposition only
|
| 103 |
+
std::span<charT> buf; // exposition only
|
| 104 |
+
};
|
| 105 |
+
}
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
The class template `basic_spanbuf` is derived from `basic_streambuf` to
|
| 109 |
+
associate possibly the input sequence and possibly the output sequence
|
| 110 |
+
with a sequence of arbitrary characters. The sequence is provided by an
|
| 111 |
+
object of class `span<charT>`.
|
| 112 |
+
|
| 113 |
+
For the sake of exposition, the maintained data is presented here as:
|
| 114 |
+
|
| 115 |
+
- `ios_base::openmode mode`, has `in` set if the input sequence can be
|
| 116 |
+
read, and `out` set if the output sequence can be written.
|
| 117 |
+
- `std::span<charT> buf` is the view to the underlying character
|
| 118 |
+
sequence.
|
| 119 |
+
|
| 120 |
+
#### Constructors <a id="spanbuf.cons">[[spanbuf.cons]]</a>
|
| 121 |
+
|
| 122 |
+
``` cpp
|
| 123 |
+
explicit basic_spanbuf(std::span<charT> s,
|
| 124 |
+
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
*Effects:* Initializes the base class with `basic_streambuf()`
|
| 128 |
+
[[streambuf.cons]], and *mode* with `which`. Initializes the internal
|
| 129 |
+
pointers as if calling `span(s)`.
|
| 130 |
+
|
| 131 |
+
``` cpp
|
| 132 |
+
basic_spanbuf(basic_spanbuf&& rhs);
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
*Effects:* Initializes the base class with `std::move(rhs)` and *mode*
|
| 136 |
+
with `std::move(rhs.`*`mode`*`)` and *buf* with
|
| 137 |
+
`std::move(rhs.`*`buf`*`)`. The sequence pointers in `*this` (`eback()`,
|
| 138 |
+
`gptr()`, `egptr()`, `pbase()`, `pptr()`, `epptr()`) obtain the values
|
| 139 |
+
which `rhs` had. It is *implementation-defined* whether
|
| 140 |
+
`rhs.`*`buf`*`.empty()` returns `true` after the move.
|
| 141 |
+
|
| 142 |
+
*Ensures:* Let `rhs_p` refer to the state of `rhs` just prior to this
|
| 143 |
+
construction.
|
| 144 |
+
|
| 145 |
+
- `span().data() == rhs_p.span().data()`
|
| 146 |
+
- `span().size() == rhs_p.span().size()`
|
| 147 |
+
- `eback() == rhs_p.eback()`
|
| 148 |
+
- `gptr() == rhs_p.gptr()`
|
| 149 |
+
- `egptr() == rhs_p.egptr()`
|
| 150 |
+
- `pbase() == rhs_p.pbase()`
|
| 151 |
+
- `pptr() == rhs_p.pptr()`
|
| 152 |
+
- `epptr() == rhs_p.epptr()`
|
| 153 |
+
- `getloc() == rhs_p.getloc()`
|
| 154 |
+
|
| 155 |
+
#### Assignment and swap <a id="spanbuf.assign">[[spanbuf.assign]]</a>
|
| 156 |
+
|
| 157 |
+
``` cpp
|
| 158 |
+
basic_spanbuf& operator=(basic_spanbuf&& rhs);
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
*Effects:* Equivalent to:
|
| 162 |
+
|
| 163 |
+
``` cpp
|
| 164 |
+
basic_spanbuf tmp{std::move(rhs)};
|
| 165 |
+
this->swap(tmp);
|
| 166 |
+
return *this;
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
``` cpp
|
| 170 |
+
void swap(basic_spanbuf& rhs);
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
*Effects:* Equivalent to:
|
| 174 |
+
|
| 175 |
+
``` cpp
|
| 176 |
+
basic_streambuf<charT, traits>::swap(rhs);
|
| 177 |
+
std::swap(mode, rhs.mode);
|
| 178 |
+
std::swap(buf, rhs.buf);
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
``` cpp
|
| 182 |
+
template<class charT, class traits>
|
| 183 |
+
void swap(basic_spanbuf<charT, traits>& x, basic_spanbuf<charT, traits>& y);
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
*Effects:* Equivalent to `x.swap(y)`.
|
| 187 |
+
|
| 188 |
+
#### Member functions <a id="spanbuf.members">[[spanbuf.members]]</a>
|
| 189 |
+
|
| 190 |
+
``` cpp
|
| 191 |
+
std::span<charT> span() const noexcept;
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
*Returns:* If `ios_base::out` is set in *mode*, returns
|
| 195 |
+
`std::span<charT>(pbase(), pptr())`, otherwise returns *buf*.
|
| 196 |
+
|
| 197 |
+
[*Note 1*: In contrast to `basic_stringbuf`, the underlying sequence
|
| 198 |
+
never grows and is not owned. An owning copy can be obtained by
|
| 199 |
+
converting the result to `basic_string<charT>`. — *end note*]
|
| 200 |
+
|
| 201 |
+
``` cpp
|
| 202 |
+
void span(std::span<charT> s) noexcept;
|
| 203 |
+
```
|
| 204 |
+
|
| 205 |
+
*Effects:* *`buf`*` = s`. Initializes the input and output sequences
|
| 206 |
+
according to *mode*.
|
| 207 |
+
|
| 208 |
+
*Ensures:*
|
| 209 |
+
|
| 210 |
+
- If `ios_base::out` is set in *mode*,
|
| 211 |
+
`pbase() == s.data() && epptr() == pbase() + s.size()` is `true`;
|
| 212 |
+
- in addition, if `ios_base::ate` is set in *mode*,
|
| 213 |
+
`pptr() == pbase() + s.size()` is `true`,
|
| 214 |
+
- otherwise `pptr() == pbase()` is `true`.
|
| 215 |
+
- If `ios_base::in` is set in *mode*,
|
| 216 |
+
`eback() == s.data() && gptr() == eback() && egptr() == eback() + s.size()`
|
| 217 |
+
is `true`.
|
| 218 |
+
|
| 219 |
+
#### Overridden virtual functions <a id="spanbuf.virtuals">[[spanbuf.virtuals]]</a>
|
| 220 |
+
|
| 221 |
+
[*Note 1*: Because the underlying buffer is of fixed size, neither
|
| 222 |
+
`overflow`, `underflow`, nor `pbackfail` can provide useful
|
| 223 |
+
behavior. — *end note*]
|
| 224 |
+
|
| 225 |
+
``` cpp
|
| 226 |
+
pos_type seekoff(off_type off, ios_base::seekdir way,
|
| 227 |
+
ios_base::openmode which = ios_base::in | ios_base::out) override;
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
*Effects:* Alters the stream position within one or both of the
|
| 231 |
+
controlled sequences, if possible, as follows:
|
| 232 |
+
|
| 233 |
+
- If `ios_base::in` is set in `which`, positions the input sequence;
|
| 234 |
+
`xnext` is `gptr()`, `xbeg` is `eback()`.
|
| 235 |
+
- If `ios_base::out` is set in `which`, positions the output sequence;
|
| 236 |
+
`xnext` is `pptr()`, `xbeg` is `pbase()`.
|
| 237 |
+
|
| 238 |
+
If both `ios_base::in` and `ios_base::out` are set in `which` and `way`
|
| 239 |
+
is `ios_base::cur`, the positioning operation fails.
|
| 240 |
+
|
| 241 |
+
For a sequence to be positioned, if its next pointer `xnext` (either
|
| 242 |
+
`gptr()` or `pptr()`) is a null pointer and the new offset `newoff` as
|
| 243 |
+
computed below is nonzero, the positioning operation fails. Otherwise,
|
| 244 |
+
the function determines `baseoff` as a value of type `off_type` as
|
| 245 |
+
follows:
|
| 246 |
+
|
| 247 |
+
- `0` when `way` is `ios_base::beg`;
|
| 248 |
+
- `(pptr() - pbase())` for the output sequence, or `(gptr() - eback())`
|
| 249 |
+
for the input sequence when `way` is `ios_base::cur`;
|
| 250 |
+
- when `way` is `ios_base::end` :
|
| 251 |
+
- `(pptr() - pbase())` if `ios_base::out` is set in *mode* and
|
| 252 |
+
`ios_base::in` is not set in *mode*,
|
| 253 |
+
- `buf.size()` otherwise.
|
| 254 |
+
|
| 255 |
+
If `baseoff` + `off` would overflow, or if `baseoff` + `off` is less
|
| 256 |
+
than zero, or if `baseoff` + `off` is greater than *`buf`*`.size()`, the
|
| 257 |
+
positioning operation fails. Otherwise, the function computes
|
| 258 |
+
|
| 259 |
+
``` cpp
|
| 260 |
+
off_type newoff = baseoff + off;
|
| 261 |
+
```
|
| 262 |
+
|
| 263 |
+
and assigns `xbeg + newoff` to the next pointer `xnext`.
|
| 264 |
+
|
| 265 |
+
*Returns:* `pos_type(off_type(-1))` if the positioning operation fails;
|
| 266 |
+
`pos_type(newoff)` otherwise.
|
| 267 |
+
|
| 268 |
+
``` cpp
|
| 269 |
+
pos_type seekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out) override;
|
| 270 |
+
```
|
| 271 |
+
|
| 272 |
+
*Effects:* Equivalent to:
|
| 273 |
+
|
| 274 |
+
``` cpp
|
| 275 |
+
return seekoff(off_type(sp), ios_base::beg, which);
|
| 276 |
+
```
|
| 277 |
+
|
| 278 |
+
``` cpp
|
| 279 |
+
basic_streambuf<charT, traits>* setbuf(charT* s, streamsize n) override;
|
| 280 |
+
```
|
| 281 |
+
|
| 282 |
+
*Effects:* Equivalent to:
|
| 283 |
+
|
| 284 |
+
``` cpp
|
| 285 |
+
this->span(std::span<charT>(s, n));
|
| 286 |
+
return this;
|
| 287 |
+
```
|
| 288 |
+
|
| 289 |
+
### Class template `basic_ispanstream` <a id="ispanstream">[[ispanstream]]</a>
|
| 290 |
+
|
| 291 |
+
#### General <a id="ispanstream.general">[[ispanstream.general]]</a>
|
| 292 |
+
|
| 293 |
+
``` cpp
|
| 294 |
+
namespace std {
|
| 295 |
+
template<class charT, class traits = char_traits<charT>>
|
| 296 |
+
class basic_ispanstream
|
| 297 |
+
: public basic_istream<charT, traits> {
|
| 298 |
+
public:
|
| 299 |
+
using char_type = charT;
|
| 300 |
+
using int_type = typename traits::int_type;
|
| 301 |
+
using pos_type = typename traits::pos_type;
|
| 302 |
+
using off_type = typename traits::off_type;
|
| 303 |
+
using traits_type = traits;
|
| 304 |
+
|
| 305 |
+
// [ispanstream.cons], constructors
|
| 306 |
+
explicit basic_ispanstream(std::span<charT> s,
|
| 307 |
+
ios_base::openmode which = ios_base::in);
|
| 308 |
+
basic_ispanstream(const basic_ispanstream&) = delete;
|
| 309 |
+
basic_ispanstream(basic_ispanstream&& rhs);
|
| 310 |
+
template<class ROS> explicit basic_ispanstream(ROS&& s);
|
| 311 |
+
|
| 312 |
+
basic_ispanstream& operator=(const basic_ispanstream&) = delete;
|
| 313 |
+
basic_ispanstream& operator=(basic_ispanstream&& rhs);
|
| 314 |
+
|
| 315 |
+
// [ispanstream.swap], swap
|
| 316 |
+
void swap(basic_ispanstream& rhs);
|
| 317 |
+
|
| 318 |
+
// [ispanstream.members], member functions
|
| 319 |
+
basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
| 320 |
+
|
| 321 |
+
std::span<const charT> span() const noexcept;
|
| 322 |
+
void span(std::span<charT> s) noexcept;
|
| 323 |
+
template<class ROS> void span(ROS&& s) noexcept;
|
| 324 |
+
|
| 325 |
+
private:
|
| 326 |
+
basic_spanbuf<charT, traits> sb; // exposition only
|
| 327 |
+
};
|
| 328 |
+
}
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
[*Note 1*: Constructing an `ispanstream` from a *string-literal*
|
| 332 |
+
includes the termination character `'\0'` in the underlying
|
| 333 |
+
`spanbuf`. — *end note*]
|
| 334 |
+
|
| 335 |
+
#### Constructors <a id="ispanstream.cons">[[ispanstream.cons]]</a>
|
| 336 |
+
|
| 337 |
+
``` cpp
|
| 338 |
+
explicit basic_ispanstream(std::span<charT> s, ios_base::openmode which = ios_base::in);
|
| 339 |
+
```
|
| 340 |
+
|
| 341 |
+
*Effects:* Initializes the base class with
|
| 342 |
+
`basic_istream<charT, traits>(addressof(sb))` and `sb` with
|
| 343 |
+
`basic_spanbuf<charT, traits>(s, which | ios_base::in)`
|
| 344 |
+
[[spanbuf.cons]].
|
| 345 |
+
|
| 346 |
+
``` cpp
|
| 347 |
+
basic_ispanstream(basic_ispanstream&& rhs);
|
| 348 |
+
```
|
| 349 |
+
|
| 350 |
+
*Effects:* Initializes the base class with `std::move(rhs)` and `sb`
|
| 351 |
+
with `std::move(rhs.sb)`. Next,
|
| 352 |
+
`basic_istream<charT, traits>::set_rdbuf(addressof(sb))` is called to
|
| 353 |
+
install the contained `basic_spanbuf`.
|
| 354 |
+
|
| 355 |
+
``` cpp
|
| 356 |
+
template<class ROS> explicit basic_ispanstream(ROS&& s)
|
| 357 |
+
```
|
| 358 |
+
|
| 359 |
+
*Constraints:* `ROS` models `ranges::borrowed_range`.
|
| 360 |
+
`!convertible_to<ROS, std::span<charT>> && convertible_to<ROS, std::span<charT const>>`
|
| 361 |
+
is `true`.
|
| 362 |
+
|
| 363 |
+
*Effects:* Let `sp` be `std::span<const charT>(std::forward<ROS>(s))`.
|
| 364 |
+
Equivalent to
|
| 365 |
+
|
| 366 |
+
``` cpp
|
| 367 |
+
basic_ispanstream(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()))
|
| 368 |
+
```
|
| 369 |
+
|
| 370 |
+
#### Swap <a id="ispanstream.swap">[[ispanstream.swap]]</a>
|
| 371 |
+
|
| 372 |
+
``` cpp
|
| 373 |
+
void swap(basic_ispanstream& rhs);
|
| 374 |
+
```
|
| 375 |
+
|
| 376 |
+
*Effects:* Equivalent to:
|
| 377 |
+
|
| 378 |
+
``` cpp
|
| 379 |
+
basic_istream<charT, traits>::swap(rhs);
|
| 380 |
+
sb.swap(rhs.sb);
|
| 381 |
+
```
|
| 382 |
+
|
| 383 |
+
``` cpp
|
| 384 |
+
template<class charT, class traits>
|
| 385 |
+
void swap(basic_ispanstream<charT, traits>& x, basic_ispanstream<charT, traits>& y);
|
| 386 |
+
```
|
| 387 |
+
|
| 388 |
+
*Effects:* Equivalent to `x.swap(y)`.
|
| 389 |
+
|
| 390 |
+
#### Member functions <a id="ispanstream.members">[[ispanstream.members]]</a>
|
| 391 |
+
|
| 392 |
+
``` cpp
|
| 393 |
+
basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
| 394 |
+
```
|
| 395 |
+
|
| 396 |
+
*Effects:* Equivalent to:
|
| 397 |
+
|
| 398 |
+
``` cpp
|
| 399 |
+
return const_cast<basic_spanbuf<charT, traits>*>(addressof(sb));
|
| 400 |
+
```
|
| 401 |
+
|
| 402 |
+
``` cpp
|
| 403 |
+
std::span<const charT> span() const noexcept;
|
| 404 |
+
```
|
| 405 |
+
|
| 406 |
+
*Effects:* Equivalent to: `return rdbuf()->span();`
|
| 407 |
+
|
| 408 |
+
``` cpp
|
| 409 |
+
void span(std::span<charT> s) noexcept;
|
| 410 |
+
```
|
| 411 |
+
|
| 412 |
+
*Effects:* Equivalent to `rdbuf()->span(s)`.
|
| 413 |
+
|
| 414 |
+
``` cpp
|
| 415 |
+
template<class ROS> void span(ROS&& s) noexcept;
|
| 416 |
+
```
|
| 417 |
+
|
| 418 |
+
*Constraints:* `ROS` models `ranges::borrowed_range`.
|
| 419 |
+
`(!convertible_to<ROS, std::span<charT>>) && convertible_to<ROS, std::span<const charT>>`
|
| 420 |
+
is `true`.
|
| 421 |
+
|
| 422 |
+
*Effects:* Let `sp` be `std::span<const charT>(std::forward<ROS>(s))`.
|
| 423 |
+
Equivalent to:
|
| 424 |
+
|
| 425 |
+
``` cpp
|
| 426 |
+
this->span(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()))
|
| 427 |
+
```
|
| 428 |
+
|
| 429 |
+
### Class template `basic_ospanstream` <a id="ospanstream">[[ospanstream]]</a>
|
| 430 |
+
|
| 431 |
+
#### General <a id="ospanstream.general">[[ospanstream.general]]</a>
|
| 432 |
+
|
| 433 |
+
``` cpp
|
| 434 |
+
namespace std {
|
| 435 |
+
template<class charT, class traits = char_traits<charT>>
|
| 436 |
+
class basic_ospanstream
|
| 437 |
+
: public basic_ostream<charT, traits> {
|
| 438 |
+
public:
|
| 439 |
+
using char_type = charT;
|
| 440 |
+
using int_type = typename traits::int_type;
|
| 441 |
+
using pos_type = typename traits::pos_type;
|
| 442 |
+
using off_type = typename traits::off_type;
|
| 443 |
+
using traits_type = traits;
|
| 444 |
+
|
| 445 |
+
// [ospanstream.cons], constructors
|
| 446 |
+
explicit basic_ospanstream(std::span<charT> s,
|
| 447 |
+
ios_base::openmode which = ios_base::out);
|
| 448 |
+
basic_ospanstream(const basic_ospanstream&) = delete;
|
| 449 |
+
basic_ospanstream(basic_ospanstream&& rhs);
|
| 450 |
+
|
| 451 |
+
basic_ospanstream& operator=(const basic_ospanstream&) = delete;
|
| 452 |
+
basic_ospanstream& operator=(basic_ospanstream&& rhs);
|
| 453 |
+
|
| 454 |
+
// [ospanstream.swap], swap
|
| 455 |
+
void swap(basic_ospanstream& rhs);
|
| 456 |
+
|
| 457 |
+
// [ospanstream.members], member functions
|
| 458 |
+
basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
| 459 |
+
|
| 460 |
+
std::span<charT> span() const noexcept;
|
| 461 |
+
void span(std::span<charT> s) noexcept;
|
| 462 |
+
|
| 463 |
+
private:
|
| 464 |
+
basic_spanbuf<charT, traits> sb; // exposition only
|
| 465 |
+
};
|
| 466 |
+
}
|
| 467 |
+
```
|
| 468 |
+
|
| 469 |
+
#### Constructors <a id="ospanstream.cons">[[ospanstream.cons]]</a>
|
| 470 |
+
|
| 471 |
+
``` cpp
|
| 472 |
+
explicit basic_ospanstream(std::span<charT> s,
|
| 473 |
+
ios_base::openmode which = ios_base::out);
|
| 474 |
+
```
|
| 475 |
+
|
| 476 |
+
*Effects:* Initializes the base class with
|
| 477 |
+
`basic_ostream<charT, traits>(addressof(sb))` and `sb` with
|
| 478 |
+
`basic_spanbuf<charT, traits>(s, which | ios_base::out)`
|
| 479 |
+
[[spanbuf.cons]].
|
| 480 |
+
|
| 481 |
+
``` cpp
|
| 482 |
+
basic_ospanstream(basic_ospanstream&& rhs) noexcept;
|
| 483 |
+
```
|
| 484 |
+
|
| 485 |
+
*Effects:* Initializes the base class with `std::move(rhs)` and `sb`
|
| 486 |
+
with `std::move(rhs.sb)`. Next,
|
| 487 |
+
`basic_ostream<charT, traits>::set_rdbuf(addressof(sb))` is called to
|
| 488 |
+
install the contained `basic_spanbuf`.
|
| 489 |
+
|
| 490 |
+
#### Swap <a id="ospanstream.swap">[[ospanstream.swap]]</a>
|
| 491 |
+
|
| 492 |
+
``` cpp
|
| 493 |
+
void swap(basic_ospanstream& rhs);
|
| 494 |
+
```
|
| 495 |
+
|
| 496 |
+
*Effects:* Equivalent to:
|
| 497 |
+
|
| 498 |
+
``` cpp
|
| 499 |
+
basic_ostream<charT, traits>::swap(rhs);
|
| 500 |
+
sb.swap(rhs.sb);
|
| 501 |
+
```
|
| 502 |
+
|
| 503 |
+
``` cpp
|
| 504 |
+
template<class charT, class traits>
|
| 505 |
+
void swap(basic_ospanstream<charT, traits>& x, basic_ospanstream<charT, traits>& y);
|
| 506 |
+
```
|
| 507 |
+
|
| 508 |
+
*Effects:* Equivalent to `x.swap(y)`.
|
| 509 |
+
|
| 510 |
+
#### Member functions <a id="ospanstream.members">[[ospanstream.members]]</a>
|
| 511 |
+
|
| 512 |
+
``` cpp
|
| 513 |
+
basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
| 514 |
+
```
|
| 515 |
+
|
| 516 |
+
*Effects:* Equivalent to:
|
| 517 |
+
|
| 518 |
+
``` cpp
|
| 519 |
+
return const_cast<basic_spanbuf<charT, traits>*>(addressof(sb));
|
| 520 |
+
```
|
| 521 |
+
|
| 522 |
+
``` cpp
|
| 523 |
+
std::span<charT> span() const noexcept;
|
| 524 |
+
```
|
| 525 |
+
|
| 526 |
+
*Effects:* Equivalent to: `return rdbuf()->span();`
|
| 527 |
+
|
| 528 |
+
``` cpp
|
| 529 |
+
void span(std::span<charT> s) noexcept;
|
| 530 |
+
```
|
| 531 |
+
|
| 532 |
+
*Effects:* Equivalent to `rdbuf()->span(s)`.
|
| 533 |
+
|
| 534 |
+
### Class template `basic_spanstream` <a id="spanstream">[[spanstream]]</a>
|
| 535 |
+
|
| 536 |
+
#### General <a id="spanstream.general">[[spanstream.general]]</a>
|
| 537 |
+
|
| 538 |
+
``` cpp
|
| 539 |
+
namespace std {
|
| 540 |
+
template<class charT, class traits = char_traits<charT>>
|
| 541 |
+
class basic_spanstream
|
| 542 |
+
: public basic_iostream<charT, traits> {
|
| 543 |
+
public:
|
| 544 |
+
using char_type = charT;
|
| 545 |
+
using int_type = typename traits::int_type;
|
| 546 |
+
using pos_type = typename traits::pos_type;
|
| 547 |
+
using off_type = typename traits::off_type;
|
| 548 |
+
using traits_type = traits;
|
| 549 |
+
|
| 550 |
+
// [spanstream.cons], constructors
|
| 551 |
+
explicit basic_spanstream(std::span<charT> s,
|
| 552 |
+
ios_base::openmode which = ios_base::out | ios_base::in);
|
| 553 |
+
basic_spanstream(const basic_spanstream&) = delete;
|
| 554 |
+
basic_spanstream(basic_spanstream&& rhs);
|
| 555 |
+
|
| 556 |
+
basic_spanstream& operator=(const basic_spanstream&) = delete;
|
| 557 |
+
basic_spanstream& operator=(basic_spanstream&& rhs);
|
| 558 |
+
|
| 559 |
+
// [spanstream.swap], swap
|
| 560 |
+
void swap(basic_spanstream& rhs);
|
| 561 |
+
|
| 562 |
+
// [spanstream.members], members
|
| 563 |
+
basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
| 564 |
+
|
| 565 |
+
std::span<charT> span() const noexcept;
|
| 566 |
+
void span(std::span<charT> s) noexcept;
|
| 567 |
+
|
| 568 |
+
private:
|
| 569 |
+
basic_spanbuf<charT, traits> sb; // exposition only
|
| 570 |
+
};
|
| 571 |
+
}
|
| 572 |
+
```
|
| 573 |
+
|
| 574 |
+
#### Constructors <a id="spanstream.cons">[[spanstream.cons]]</a>
|
| 575 |
+
|
| 576 |
+
``` cpp
|
| 577 |
+
explicit basic_spanstream(std::span<charT> s,
|
| 578 |
+
ios_base::openmode which = ios_base::out | ios_bas::in);
|
| 579 |
+
```
|
| 580 |
+
|
| 581 |
+
*Effects:* Initializes the base class with
|
| 582 |
+
`basic_iostream<charT, traits>(addressof(sb))` and `sb` with
|
| 583 |
+
`basic_spanbuf<charT, traits>(s, which)` [[spanbuf.cons]].
|
| 584 |
+
|
| 585 |
+
``` cpp
|
| 586 |
+
basic_spanstream(basic_spanstream&& rhs);
|
| 587 |
+
```
|
| 588 |
+
|
| 589 |
+
*Effects:* Initializes the base class with `std::move(rhs)` and `sb`
|
| 590 |
+
with `std::move(rhs.sb)`. Next,
|
| 591 |
+
`basic_iostream<charT, traits>::set_rdbuf(addressof(sb))` is called to
|
| 592 |
+
install the contained `basic_spanbuf`.
|
| 593 |
+
|
| 594 |
+
#### Swap <a id="spanstream.swap">[[spanstream.swap]]</a>
|
| 595 |
+
|
| 596 |
+
``` cpp
|
| 597 |
+
void swap(basic_spanstream& rhs);
|
| 598 |
+
```
|
| 599 |
+
|
| 600 |
+
*Effects:* Equivalent to:
|
| 601 |
+
|
| 602 |
+
``` cpp
|
| 603 |
+
basic_iostream<charT, traits>::swap(rhs);
|
| 604 |
+
sb.swap(rhs.sb);
|
| 605 |
+
```
|
| 606 |
+
|
| 607 |
+
``` cpp
|
| 608 |
+
template<class charT, class traits>
|
| 609 |
+
void swap(basic_spanstream<charT, traits>& x, basic_spanstream<charT, traits>& y);
|
| 610 |
+
```
|
| 611 |
+
|
| 612 |
+
*Effects:* Equivalent to `x.swap(y)`.
|
| 613 |
+
|
| 614 |
+
#### Member functions <a id="spanstream.members">[[spanstream.members]]</a>
|
| 615 |
+
|
| 616 |
+
``` cpp
|
| 617 |
+
basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
| 618 |
+
```
|
| 619 |
+
|
| 620 |
+
*Effects:* Equivalent to:
|
| 621 |
+
|
| 622 |
+
``` cpp
|
| 623 |
+
return const_cast<basic_spanbuf<charT, traits>*>(addressof(sb));
|
| 624 |
+
```
|
| 625 |
+
|
| 626 |
+
``` cpp
|
| 627 |
+
std::span<charT> span() const noexcept;
|
| 628 |
+
```
|
| 629 |
+
|
| 630 |
+
*Effects:* Equivalent to: `return rdbuf()->span();`
|
| 631 |
+
|
| 632 |
+
``` cpp
|
| 633 |
+
void span(std::span<charT> s) noexcept;
|
| 634 |
+
```
|
| 635 |
+
|
| 636 |
+
*Effects:* Equivalent to `rdbuf()->span(s)`.
|
| 637 |
+
|