tmp/tmp00wezbk_/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="spanbuf.general">[[spanbuf.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<class charT, class traits = char_traits<charT>>
|
| 6 |
+
class basic_spanbuf
|
| 7 |
+
: public basic_streambuf<charT, traits> {
|
| 8 |
+
public:
|
| 9 |
+
using char_type = charT;
|
| 10 |
+
using int_type = typename traits::int_type;
|
| 11 |
+
using pos_type = typename traits::pos_type;
|
| 12 |
+
using off_type = typename traits::off_type;
|
| 13 |
+
using traits_type = traits;
|
| 14 |
+
|
| 15 |
+
// [spanbuf.cons], constructors
|
| 16 |
+
basic_spanbuf() : basic_spanbuf(ios_base::in | ios_base::out) {}
|
| 17 |
+
explicit basic_spanbuf(ios_base::openmode which)
|
| 18 |
+
: basic_spanbuf(std::span<charT>(), which) {}
|
| 19 |
+
explicit basic_spanbuf(std::span<charT> s,
|
| 20 |
+
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 21 |
+
basic_spanbuf(const basic_spanbuf&) = delete;
|
| 22 |
+
basic_spanbuf(basic_spanbuf&& rhs);
|
| 23 |
+
|
| 24 |
+
// [spanbuf.assign], assignment and swap
|
| 25 |
+
basic_spanbuf& operator=(const basic_spanbuf&) = delete;
|
| 26 |
+
basic_spanbuf& operator=(basic_spanbuf&& rhs);
|
| 27 |
+
void swap(basic_spanbuf& rhs);
|
| 28 |
+
|
| 29 |
+
// [spanbuf.members], member functions
|
| 30 |
+
std::span<charT> span() const noexcept;
|
| 31 |
+
void span(std::span<charT> s) noexcept;
|
| 32 |
+
|
| 33 |
+
protected:
|
| 34 |
+
// [spanbuf.virtuals], overridden virtual functions
|
| 35 |
+
basic_streambuf<charT, traits>* setbuf(charT*, streamsize) override;
|
| 36 |
+
pos_type seekoff(off_type off, ios_base::seekdir way,
|
| 37 |
+
ios_base::openmode which = ios_base::in | ios_base::out) override;
|
| 38 |
+
pos_type seekpos(pos_type sp,
|
| 39 |
+
ios_base::openmode which = ios_base::in | ios_base::out) override;
|
| 40 |
+
|
| 41 |
+
private:
|
| 42 |
+
ios_base::openmode mode; // exposition only
|
| 43 |
+
std::span<charT> buf; // exposition only
|
| 44 |
+
};
|
| 45 |
+
}
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
The class template `basic_spanbuf` is derived from `basic_streambuf` to
|
| 49 |
+
associate possibly the input sequence and possibly the output sequence
|
| 50 |
+
with a sequence of arbitrary characters. The sequence is provided by an
|
| 51 |
+
object of class `span<charT>`.
|
| 52 |
+
|
| 53 |
+
For the sake of exposition, the maintained data is presented here as:
|
| 54 |
+
|
| 55 |
+
- `ios_base::openmode mode`, has `in` set if the input sequence can be
|
| 56 |
+
read, and `out` set if the output sequence can be written.
|
| 57 |
+
- `std::span<charT> buf` is the view to the underlying character
|
| 58 |
+
sequence.
|
| 59 |
+
|