tmp/tmpn2zyryyf/{from.md → to.md}
RENAMED
|
@@ -1,17 +1,16 @@
|
|
| 1 |
#### General <a id="stringbuf.general">[[stringbuf.general]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
-
template<class charT, class traits = char_traits<charT>,
|
| 6 |
-
class Allocator = allocator<charT>>
|
| 7 |
class basic_stringbuf : public basic_streambuf<charT, traits> {
|
| 8 |
public:
|
| 9 |
using char_type = charT;
|
| 10 |
-
using int_type =
|
| 11 |
-
using pos_type =
|
| 12 |
-
using off_type =
|
| 13 |
using traits_type = traits;
|
| 14 |
using allocator_type = Allocator;
|
| 15 |
|
| 16 |
// [stringbuf.cons], constructors
|
| 17 |
basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {}
|
|
@@ -35,10 +34,17 @@ namespace std {
|
|
| 35 |
ios_base::openmode which, const Allocator& a);
|
| 36 |
template<class SAlloc>
|
| 37 |
explicit basic_stringbuf(
|
| 38 |
const basic_string<charT, traits, SAlloc>& s,
|
| 39 |
ios_base::openmode which = ios_base::in | ios_base::out);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
basic_stringbuf(const basic_stringbuf&) = delete;
|
| 41 |
basic_stringbuf(basic_stringbuf&& rhs);
|
| 42 |
basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
|
| 43 |
|
| 44 |
// [stringbuf.assign], assignment and swap
|
|
@@ -57,10 +63,12 @@ namespace std {
|
|
| 57 |
|
| 58 |
void str(const basic_string<charT, traits, Allocator>& s);
|
| 59 |
template<class SAlloc>
|
| 60 |
void str(const basic_string<charT, traits, SAlloc>& s);
|
| 61 |
void str(basic_string<charT, traits, Allocator>&& s);
|
|
|
|
|
|
|
| 62 |
|
| 63 |
protected:
|
| 64 |
// [stringbuf.virtuals], overridden virtual functions
|
| 65 |
int_type underflow() override;
|
| 66 |
int_type pbackfail(int_type c = traits::eof()) override;
|
|
@@ -75,11 +83,11 @@ namespace std {
|
|
| 75 |
= ios_base::in | ios_base::out) override;
|
| 76 |
|
| 77 |
private:
|
| 78 |
ios_base::openmode mode; // exposition only
|
| 79 |
basic_string<charT, traits, Allocator> buf; // exposition only
|
| 80 |
-
void
|
| 81 |
};
|
| 82 |
}
|
| 83 |
```
|
| 84 |
|
| 85 |
The class `basic_stringbuf` is derived from `basic_streambuf` to
|
|
@@ -93,9 +101,9 @@ initialization is presented here as:
|
|
| 93 |
|
| 94 |
- `ios_base::openmode mode`, has `in` set if the input sequence can be
|
| 95 |
read, and `out` set if the output sequence can be written.
|
| 96 |
- `basic_string<charT, traits, Allocator> buf` contains the underlying
|
| 97 |
character sequence.
|
| 98 |
-
- `
|
| 99 |
and put area [[streambuf.put.area]] pointers after initializing,
|
| 100 |
-
moving from, or assigning to `buf` accordingly.
|
| 101 |
|
|
|
|
| 1 |
#### General <a id="stringbuf.general">[[stringbuf.general]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
+
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
|
|
|
|
| 6 |
class basic_stringbuf : public basic_streambuf<charT, traits> {
|
| 7 |
public:
|
| 8 |
using char_type = charT;
|
| 9 |
+
using int_type = traits::int_type;
|
| 10 |
+
using pos_type = traits::pos_type;
|
| 11 |
+
using off_type = traits::off_type;
|
| 12 |
using traits_type = traits;
|
| 13 |
using allocator_type = Allocator;
|
| 14 |
|
| 15 |
// [stringbuf.cons], constructors
|
| 16 |
basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {}
|
|
|
|
| 34 |
ios_base::openmode which, const Allocator& a);
|
| 35 |
template<class SAlloc>
|
| 36 |
explicit basic_stringbuf(
|
| 37 |
const basic_string<charT, traits, SAlloc>& s,
|
| 38 |
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 39 |
+
template<class T>
|
| 40 |
+
explicit basic_stringbuf(const T& t,
|
| 41 |
+
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 42 |
+
template<class T>
|
| 43 |
+
basic_stringbuf(const T& t, const Allocator& a);
|
| 44 |
+
template<class T>
|
| 45 |
+
basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a);
|
| 46 |
basic_stringbuf(const basic_stringbuf&) = delete;
|
| 47 |
basic_stringbuf(basic_stringbuf&& rhs);
|
| 48 |
basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
|
| 49 |
|
| 50 |
// [stringbuf.assign], assignment and swap
|
|
|
|
| 63 |
|
| 64 |
void str(const basic_string<charT, traits, Allocator>& s);
|
| 65 |
template<class SAlloc>
|
| 66 |
void str(const basic_string<charT, traits, SAlloc>& s);
|
| 67 |
void str(basic_string<charT, traits, Allocator>&& s);
|
| 68 |
+
template<class T>
|
| 69 |
+
void str(const T& t);
|
| 70 |
|
| 71 |
protected:
|
| 72 |
// [stringbuf.virtuals], overridden virtual functions
|
| 73 |
int_type underflow() override;
|
| 74 |
int_type pbackfail(int_type c = traits::eof()) override;
|
|
|
|
| 83 |
= ios_base::in | ios_base::out) override;
|
| 84 |
|
| 85 |
private:
|
| 86 |
ios_base::openmode mode; // exposition only
|
| 87 |
basic_string<charT, traits, Allocator> buf; // exposition only
|
| 88 |
+
void init-buf-ptrs(); // exposition only
|
| 89 |
};
|
| 90 |
}
|
| 91 |
```
|
| 92 |
|
| 93 |
The class `basic_stringbuf` is derived from `basic_streambuf` to
|
|
|
|
| 101 |
|
| 102 |
- `ios_base::openmode mode`, has `in` set if the input sequence can be
|
| 103 |
read, and `out` set if the output sequence can be written.
|
| 104 |
- `basic_string<charT, traits, Allocator> buf` contains the underlying
|
| 105 |
character sequence.
|
| 106 |
+
- `init-buf-ptrs()` sets the base class’ get area [[streambuf.get.area]]
|
| 107 |
and put area [[streambuf.put.area]] pointers after initializing,
|
| 108 |
+
moving from, or assigning to *`buf`* accordingly.
|
| 109 |
|