From Jason Turner

[stringbuf]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptviagl13/{from.md → to.md} +98 -47
tmp/tmptviagl13/{from.md → to.md} RENAMED
@@ -2,18 +2,17 @@
2
 
3
  #### General <a id="stringbuf.general">[[stringbuf.general]]</a>
4
 
5
  ``` cpp
6
  namespace std {
7
- template<class charT, class traits = char_traits<charT>,
8
- class Allocator = allocator<charT>>
9
  class basic_stringbuf : public basic_streambuf<charT, traits> {
10
  public:
11
  using char_type = charT;
12
- using int_type = typename traits::int_type;
13
- using pos_type = typename traits::pos_type;
14
- using off_type = typename traits::off_type;
15
  using traits_type = traits;
16
  using allocator_type = Allocator;
17
 
18
  // [stringbuf.cons], constructors
19
  basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {}
@@ -37,10 +36,17 @@ namespace std {
37
  ios_base::openmode which, const Allocator& a);
38
  template<class SAlloc>
39
  explicit basic_stringbuf(
40
  const basic_string<charT, traits, SAlloc>& s,
41
  ios_base::openmode which = ios_base::in | ios_base::out);
 
 
 
 
 
 
 
42
  basic_stringbuf(const basic_stringbuf&) = delete;
43
  basic_stringbuf(basic_stringbuf&& rhs);
44
  basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
45
 
46
  // [stringbuf.assign], assignment and swap
@@ -59,10 +65,12 @@ namespace std {
59
 
60
  void str(const basic_string<charT, traits, Allocator>& s);
61
  template<class SAlloc>
62
  void str(const basic_string<charT, traits, SAlloc>& s);
63
  void str(basic_string<charT, traits, Allocator>&& s);
 
 
64
 
65
  protected:
66
  // [stringbuf.virtuals], overridden virtual functions
67
  int_type underflow() override;
68
  int_type pbackfail(int_type c = traits::eof()) override;
@@ -77,11 +85,11 @@ namespace std {
77
  = ios_base::in | ios_base::out) override;
78
 
79
  private:
80
  ios_base::openmode mode; // exposition only
81
  basic_string<charT, traits, Allocator> buf; // exposition only
82
- void init_buf_ptrs(); // exposition only
83
  };
84
  }
85
  ```
86
 
87
  The class `basic_stringbuf` is derived from `basic_streambuf` to
@@ -95,22 +103,22 @@ initialization is presented here as:
95
 
96
  - `ios_base::openmode mode`, has `in` set if the input sequence can be
97
  read, and `out` set if the output sequence can be written.
98
  - `basic_string<charT, traits, Allocator> buf` contains the underlying
99
  character sequence.
100
- - `init_buf_ptrs()` sets the base class’ get area [[streambuf.get.area]]
101
  and put area [[streambuf.put.area]] pointers after initializing,
102
- moving from, or assigning to `buf` accordingly.
103
 
104
  #### Constructors <a id="stringbuf.cons">[[stringbuf.cons]]</a>
105
 
106
  ``` cpp
107
  explicit basic_stringbuf(ios_base::openmode which);
108
  ```
109
 
110
  *Effects:* Initializes the base class with `basic_streambuf()`
111
- [[streambuf.cons]], and `mode` with `which`. It is
112
  *implementation-defined* whether the sequence pointers (`eback()`,
113
  `gptr()`, `egptr()`, `pbase()`, `pptr()`, `epptr()`) are initialized to
114
  null pointers.
115
 
116
  *Ensures:* `str().empty()` is `true`.
@@ -120,43 +128,43 @@ explicit basic_stringbuf(
120
  const basic_string<charT, traits, Allocator>& s,
121
  ios_base::openmode which = ios_base::in | ios_base::out);
122
  ```
123
 
124
  *Effects:* Initializes the base class with `basic_streambuf()`
125
- [[streambuf.cons]], `mode` with `which`, and `buf` with `s`, then calls
126
- `init_buf_ptrs()`.
127
 
128
  ``` cpp
129
  basic_stringbuf(ios_base::openmode which, const Allocator& a);
130
  ```
131
 
132
  *Effects:* Initializes the base class with `basic_streambuf()`
133
- [[streambuf.cons]], `mode` with `which`, and `buf` with `a`, then calls
134
- `init_buf_ptrs()`.
135
 
136
  *Ensures:* `str().empty()` is `true`.
137
 
138
  ``` cpp
139
  explicit basic_stringbuf(
140
  basic_string<charT, traits, Allocator>&& s,
141
  ios_base::openmode which = ios_base::in | ios_base::out);
142
  ```
143
 
144
  *Effects:* Initializes the base class with `basic_streambuf()`
145
- [[streambuf.cons]], `mode` with `which`, and `buf` with `std::move(s)`,
146
- then calls `init_buf_ptrs()`.
147
 
148
  ``` cpp
149
  template<class SAlloc>
150
  basic_stringbuf(
151
  const basic_string<charT, traits, SAlloc>& s,
152
  ios_base::openmode which, const Allocator& a);
153
  ```
154
 
155
  *Effects:* Initializes the base class with `basic_streambuf()`
156
- [[streambuf.cons]], `mode` with `which`, and `buf` with `{s,a}`, then
157
- calls `init_buf_ptrs()`.
158
 
159
  ``` cpp
160
  template<class SAlloc>
161
  explicit basic_stringbuf(
162
  const basic_string<charT, traits, SAlloc>& s,
@@ -164,21 +172,44 @@ template<class SAlloc>
164
  ```
165
 
166
  *Constraints:* `is_same_v<SAlloc, Allocator>` is `false`.
167
 
168
  *Effects:* Initializes the base class with `basic_streambuf()`
169
- [[streambuf.cons]], `mode` with `which`, and `buf` with `s`, then calls
170
- `init_buf_ptrs()`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  ``` cpp
173
  basic_stringbuf(basic_stringbuf&& rhs);
174
  basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
175
  ```
176
 
177
  *Effects:* Copy constructs the base class from `rhs` and initializes
178
- `mode` with `rhs.mode`. In the first form `buf` is initialized from
179
- `std::move(rhs).str()`. In the second form `buf` is initialized from
180
  `{std::move(rhs).str(), a}`. It is *implementation-defined* whether the
181
  sequence pointers in `*this` (`eback()`, `gptr()`, `egptr()`, `pbase()`,
182
  `pptr()`, `epptr()`) obtain the values which `rhs` had.
183
 
184
  *Ensures:* Let `rhs_p` refer to the state of `rhs` just prior to this
@@ -221,19 +252,19 @@ void swap(basic_stringbuf& rhs) noexcept(see below);
221
 
222
  *Effects:* Exchanges the state of `*this` and `rhs`.
223
 
224
  *Remarks:* The exception specification is equivalent to:
225
  `allocator_traits<Allocator>::propagate_on_container_swap::value ||`
226
- `allocator_traits<Allocator>::is_always_equal::value`.
227
 
228
  ``` cpp
229
  template<class charT, class traits, class Allocator>
230
  void swap(basic_stringbuf<charT, traits, Allocator>& x,
231
  basic_stringbuf<charT, traits, Allocator>& y) noexcept(noexcept(x.swap(y)));
232
  ```
233
 
234
- *Effects:* Equivalent to: `x.swap(y)`.
235
 
236
  #### Member functions <a id="stringbuf.members">[[stringbuf.members]]</a>
237
 
238
  The member functions getting the underlying character sequence all refer
239
  to a `high_mark` value, where `high_mark` represents the position one
@@ -244,39 +275,42 @@ of the `str` member functions passing a `basic_string` as an argument.
244
  In the latter case, all characters initialized prior to the call are now
245
  considered uninitialized (except for those characters re-initialized by
246
  the new `basic_string`).
247
 
248
  ``` cpp
249
- void init_buf_ptrs(); // exposition only
250
  ```
251
 
252
- *Effects:* Initializes the input and output sequences from `buf`
253
- according to `mode`.
254
 
255
  *Ensures:*
256
 
257
- - If `ios_base::out` is set in `mode`, `pbase()` points to `buf.front()`
258
- and `epptr() >= pbase() + buf.size()` is `true`;
259
- - in addition, if `ios_base::ate` is set in `mode`,
260
- `pptr() == pbase() + buf.size()` is `true`,
 
261
  - otherwise `pptr() == pbase()` is `true`.
262
- - If `ios_base::in` is set in `mode`, `eback()` points to `buf.front()`,
263
- and `(gptr() == eback() && egptr() == eback() + buf.size())` is
 
264
  `true`.
265
 
266
  [*Note 1*: For efficiency reasons, stream buffer operations can violate
267
- invariants of `buf` while it is held encapsulated in the
268
  `basic_stringbuf`, e.g., by writing to characters in the range
269
- \[`buf.data() + buf.size()`, `buf.data() + buf.capacity()`). All
270
- operations retrieving a `basic_string` from `buf` ensure that the
271
- `basic_string` invariants hold on the returned value. — *end note*]
 
272
 
273
  ``` cpp
274
  allocator_type get_allocator() const noexcept;
275
  ```
276
 
277
- *Returns:* `buf.get_allocator()`.
278
 
279
  ``` cpp
280
  basic_string<charT, traits, Allocator> str() const &;
281
  ```
282
 
@@ -290,11 +324,11 @@ return basic_string<charT, traits, Allocator>(view(), get_allocator());
290
  template<class SAlloc>
291
  basic_string<charT, traits, SAlloc> str(const SAlloc& sa) const;
292
  ```
293
 
294
  *Constraints:* `SAlloc` is a type that qualifies as an
295
- allocator [[container.requirements.general]].
296
 
297
  *Effects:* Equivalent to:
298
 
299
  ``` cpp
300
  return basic_string<charT, traits, SAlloc>(view(), sa);
@@ -304,11 +338,11 @@ return basic_string<charT, traits, SAlloc>(view(), sa);
304
  basic_string<charT, traits, Allocator> str() &&;
305
  ```
306
 
307
  *Ensures:* The underlying character sequence `buf` is empty and
308
  `pbase()`, `pptr()`, `epptr()`, `eback()`, `gptr()`, and `egptr()` are
309
- initialized as if by calling `init_buf_ptrs()` with an empty `buf`.
310
 
311
  *Returns:* A `basic_string<charT, traits, Allocator>` object move
312
  constructed from the `basic_stringbuf`’s underlying character sequence
313
  in `buf`. This can be achieved by first adjusting `buf` to have the same
314
  content as `view()`.
@@ -320,13 +354,13 @@ basic_string_view<charT, traits> view() const noexcept;
320
  Let `sv` be `basic_string_view<charT, traits>`.
321
 
322
  *Returns:* A `sv` object referring to the `basic_stringbuf`’s underlying
323
  character sequence in `buf`:
324
 
325
- - If `ios_base::out` is set in `mode`, then
326
  `sv(pbase(), high_mark - pbase())` is returned.
327
- - Otherwise, if `ios_base::in` is set in `mode`, then
328
  `sv(eback(), egptr() - eback())` is returned.
329
  - Otherwise, `sv()` is returned.
330
 
331
  [*Note 2*: Using the returned `sv` object after destruction or
332
  invalidation of the character sequence underlying `*this` is undefined
@@ -338,11 +372,11 @@ void str(const basic_string<charT, traits, Allocator>& s);
338
 
339
  *Effects:* Equivalent to:
340
 
341
  ``` cpp
342
  buf = s;
343
- init_buf_ptrs();
344
  ```
345
 
346
  ``` cpp
347
  template<class SAlloc>
348
  void str(const basic_string<charT, traits, SAlloc>& s);
@@ -352,22 +386,39 @@ template<class SAlloc>
352
 
353
  *Effects:* Equivalent to:
354
 
355
  ``` cpp
356
  buf = s;
357
- init_buf_ptrs();
358
  ```
359
 
360
  ``` cpp
361
  void str(basic_string<charT, traits, Allocator>&& s);
362
  ```
363
 
364
  *Effects:* Equivalent to:
365
 
366
  ``` cpp
367
  buf = std::move(s);
368
- init_buf_ptrs();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
  ```
370
 
371
  #### Overridden virtual functions <a id="stringbuf.virtuals">[[stringbuf.virtuals]]</a>
372
 
373
  ``` cpp
@@ -389,11 +440,11 @@ sequence, if possible, in one of three ways:
389
  - If `traits::eq_int_type(c, traits::eof())` returns `false` and if the
390
  input sequence has a putback position available, and if
391
  `traits::eq(to_char_type(c), gptr()[-1])` returns `true`, assigns
392
  `gptr() - 1` to `gptr()`. Returns: `c`.
393
  - If `traits::eq_int_type(c, traits::eof())` returns `false` and if the
394
- input sequence has a putback position available, and if `mode` `&`
395
  `ios_base::out` is nonzero, assigns `c` to `*–gptr()`. Returns: `c`.
396
  - If `traits::eq_int_type(c, traits::eof())` returns `true` and if the
397
  input sequence has a putback position available, assigns `gptr() - 1`
398
  to `gptr()`. Returns: `traits::not_eof(c)`.
399
 
@@ -421,14 +472,14 @@ sequence, if possible, in one of two ways:
421
 
422
  *Remarks:* The function can alter the number of write positions
423
  available as a result of any call.
424
 
425
  The function can make a write position available only if `ios_base::out`
426
- is set in `mode`. To make a write position available, the function
427
  reallocates (or initially allocates) an array object with a sufficient
428
  number of elements to hold the current array object (if any), plus at
429
- least one additional write position. If `ios_base::in` is set in `mode`,
430
  the function alters the read end pointer `egptr()` to point just past
431
  the new write position.
432
 
433
  ``` cpp
434
  pos_type seekoff(off_type off, ios_base::seekdir way,
 
2
 
3
  #### General <a id="stringbuf.general">[[stringbuf.general]]</a>
4
 
5
  ``` cpp
6
  namespace std {
7
+ template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
 
8
  class basic_stringbuf : public basic_streambuf<charT, traits> {
9
  public:
10
  using char_type = charT;
11
+ using int_type = traits::int_type;
12
+ using pos_type = traits::pos_type;
13
+ using off_type = traits::off_type;
14
  using traits_type = traits;
15
  using allocator_type = Allocator;
16
 
17
  // [stringbuf.cons], constructors
18
  basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {}
 
36
  ios_base::openmode which, const Allocator& a);
37
  template<class SAlloc>
38
  explicit basic_stringbuf(
39
  const basic_string<charT, traits, SAlloc>& s,
40
  ios_base::openmode which = ios_base::in | ios_base::out);
41
+ template<class T>
42
+ explicit basic_stringbuf(const T& t,
43
+ ios_base::openmode which = ios_base::in | ios_base::out);
44
+ template<class T>
45
+ basic_stringbuf(const T& t, const Allocator& a);
46
+ template<class T>
47
+ basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a);
48
  basic_stringbuf(const basic_stringbuf&) = delete;
49
  basic_stringbuf(basic_stringbuf&& rhs);
50
  basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
51
 
52
  // [stringbuf.assign], assignment and swap
 
65
 
66
  void str(const basic_string<charT, traits, Allocator>& s);
67
  template<class SAlloc>
68
  void str(const basic_string<charT, traits, SAlloc>& s);
69
  void str(basic_string<charT, traits, Allocator>&& s);
70
+ template<class T>
71
+ void str(const T& t);
72
 
73
  protected:
74
  // [stringbuf.virtuals], overridden virtual functions
75
  int_type underflow() override;
76
  int_type pbackfail(int_type c = traits::eof()) override;
 
85
  = ios_base::in | ios_base::out) override;
86
 
87
  private:
88
  ios_base::openmode mode; // exposition only
89
  basic_string<charT, traits, Allocator> buf; // exposition only
90
+ void init-buf-ptrs(); // exposition only
91
  };
92
  }
93
  ```
94
 
95
  The class `basic_stringbuf` is derived from `basic_streambuf` to
 
103
 
104
  - `ios_base::openmode mode`, has `in` set if the input sequence can be
105
  read, and `out` set if the output sequence can be written.
106
  - `basic_string<charT, traits, Allocator> buf` contains the underlying
107
  character sequence.
108
+ - `init-buf-ptrs()` sets the base class’ get area [[streambuf.get.area]]
109
  and put area [[streambuf.put.area]] pointers after initializing,
110
+ moving from, or assigning to *`buf`* accordingly.
111
 
112
  #### Constructors <a id="stringbuf.cons">[[stringbuf.cons]]</a>
113
 
114
  ``` cpp
115
  explicit basic_stringbuf(ios_base::openmode which);
116
  ```
117
 
118
  *Effects:* Initializes the base class with `basic_streambuf()`
119
+ [[streambuf.cons]], and *mode* with `which`. It is
120
  *implementation-defined* whether the sequence pointers (`eback()`,
121
  `gptr()`, `egptr()`, `pbase()`, `pptr()`, `epptr()`) are initialized to
122
  null pointers.
123
 
124
  *Ensures:* `str().empty()` is `true`.
 
128
  const basic_string<charT, traits, Allocator>& s,
129
  ios_base::openmode which = ios_base::in | ios_base::out);
130
  ```
131
 
132
  *Effects:* Initializes the base class with `basic_streambuf()`
133
+ [[streambuf.cons]], *mode* with `which`, and *buf* with `s`, then calls
134
+ *`init-buf-ptrs`*`()`.
135
 
136
  ``` cpp
137
  basic_stringbuf(ios_base::openmode which, const Allocator& a);
138
  ```
139
 
140
  *Effects:* Initializes the base class with `basic_streambuf()`
141
+ [[streambuf.cons]], *mode* with `which`, and *buf* with `a`, then calls
142
+ *`init-buf-ptrs`*`()`.
143
 
144
  *Ensures:* `str().empty()` is `true`.
145
 
146
  ``` cpp
147
  explicit basic_stringbuf(
148
  basic_string<charT, traits, Allocator>&& s,
149
  ios_base::openmode which = ios_base::in | ios_base::out);
150
  ```
151
 
152
  *Effects:* Initializes the base class with `basic_streambuf()`
153
+ [[streambuf.cons]], *mode* with `which`, and *buf* with `std::move(s)`,
154
+ then calls *`init-buf-ptrs`*`()`.
155
 
156
  ``` cpp
157
  template<class SAlloc>
158
  basic_stringbuf(
159
  const basic_string<charT, traits, SAlloc>& s,
160
  ios_base::openmode which, const Allocator& a);
161
  ```
162
 
163
  *Effects:* Initializes the base class with `basic_streambuf()`
164
+ [[streambuf.cons]], *mode* with `which`, and *buf* with `{s,a}`, then
165
+ calls *`init-buf-ptrs`*`()`.
166
 
167
  ``` cpp
168
  template<class SAlloc>
169
  explicit basic_stringbuf(
170
  const basic_string<charT, traits, SAlloc>& s,
 
172
  ```
173
 
174
  *Constraints:* `is_same_v<SAlloc, Allocator>` is `false`.
175
 
176
  *Effects:* Initializes the base class with `basic_streambuf()`
177
+ [[streambuf.cons]], *mode* with `which`, and *buf* with `s`, then calls
178
+ *`init-buf-ptrs`*`()`.
179
+
180
+ ``` cpp
181
+ template<class T>
182
+ explicit basic_stringbuf(const T& t, ios_base::openmode which = ios_base::in | ios_base::out);
183
+ template<class T>
184
+ basic_stringbuf(const T& t, const Allocator& a);
185
+ template<class T>
186
+ basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a);
187
+ ```
188
+
189
+ Let `which` be `ios_base::in | ios_base::out` for the overload with no
190
+ parameter `which`, and `a` be `Allocator()` for the overload with no
191
+ parameter `a`.
192
+
193
+ *Constraints:*
194
+ `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
195
+ `true`.
196
+
197
+ *Effects:* Creates a variable `sv` as if by
198
+ `basic_string_view<charT, traits> sv = t`, then value-initializes the
199
+ base class, initializes *mode* with `which`, and
200
+ direct-non-list-initializes *buf* with `sv, a`, then calls
201
+ *`init-buf-ptrs`*`()`.
202
 
203
  ``` cpp
204
  basic_stringbuf(basic_stringbuf&& rhs);
205
  basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
206
  ```
207
 
208
  *Effects:* Copy constructs the base class from `rhs` and initializes
209
+ *mode* with `rhs.mode`. In the first form `buf` is initialized from
210
+ `std::move(rhs).str()`. In the second form *buf* is initialized from
211
  `{std::move(rhs).str(), a}`. It is *implementation-defined* whether the
212
  sequence pointers in `*this` (`eback()`, `gptr()`, `egptr()`, `pbase()`,
213
  `pptr()`, `epptr()`) obtain the values which `rhs` had.
214
 
215
  *Ensures:* Let `rhs_p` refer to the state of `rhs` just prior to this
 
252
 
253
  *Effects:* Exchanges the state of `*this` and `rhs`.
254
 
255
  *Remarks:* The exception specification is equivalent to:
256
  `allocator_traits<Allocator>::propagate_on_container_swap::value ||`
257
+ `allocator_traits<Allocator>::is_always_equal::value`
258
 
259
  ``` cpp
260
  template<class charT, class traits, class Allocator>
261
  void swap(basic_stringbuf<charT, traits, Allocator>& x,
262
  basic_stringbuf<charT, traits, Allocator>& y) noexcept(noexcept(x.swap(y)));
263
  ```
264
 
265
+ *Effects:* Equivalent to `x.swap(y)`.
266
 
267
  #### Member functions <a id="stringbuf.members">[[stringbuf.members]]</a>
268
 
269
  The member functions getting the underlying character sequence all refer
270
  to a `high_mark` value, where `high_mark` represents the position one
 
275
  In the latter case, all characters initialized prior to the call are now
276
  considered uninitialized (except for those characters re-initialized by
277
  the new `basic_string`).
278
 
279
  ``` cpp
280
+ void init-buf-ptrs();
281
  ```
282
 
283
+ *Effects:* Initializes the input and output sequences from *buf*
284
+ according to *mode*.
285
 
286
  *Ensures:*
287
 
288
+ - If `ios_base::out` is set in *mode*, `pbase()` points to
289
+ *`buf`*`.front()` and `epptr() >= pbase() + `*`buf`*`.size()` is
290
+ `true`;
291
+ - in addition, if `ios_base::ate` is set in *mode*,
292
+ `pptr() == pbase() + `*`buf`*`.size()` is `true`,
293
  - otherwise `pptr() == pbase()` is `true`.
294
+ - If `ios_base::in` is set in *mode*, `eback()` points to
295
+ *`buf`*`.front()`, and
296
+ `(gptr() == eback() && egptr() == eback() + `*`buf`*`.size())` is
297
  `true`.
298
 
299
  [*Note 1*: For efficiency reasons, stream buffer operations can violate
300
+ invariants of *buf* while it is held encapsulated in the
301
  `basic_stringbuf`, e.g., by writing to characters in the range
302
+ [*`buf`*`.data() + `*`buf`*`.size()`,
303
+ *`buf`*`.data() + `*`buf`*`.capacity()`). All operations retrieving a
304
+ `basic_string` from `buf` ensure that the `basic_string` invariants hold
305
+ on the returned value. — *end note*]
306
 
307
  ``` cpp
308
  allocator_type get_allocator() const noexcept;
309
  ```
310
 
311
+ *Returns:* *`buf`*`.get_allocator()`.
312
 
313
  ``` cpp
314
  basic_string<charT, traits, Allocator> str() const &;
315
  ```
316
 
 
324
  template<class SAlloc>
325
  basic_string<charT, traits, SAlloc> str(const SAlloc& sa) const;
326
  ```
327
 
328
  *Constraints:* `SAlloc` is a type that qualifies as an
329
+ allocator [[container.reqmts]].
330
 
331
  *Effects:* Equivalent to:
332
 
333
  ``` cpp
334
  return basic_string<charT, traits, SAlloc>(view(), sa);
 
338
  basic_string<charT, traits, Allocator> str() &&;
339
  ```
340
 
341
  *Ensures:* The underlying character sequence `buf` is empty and
342
  `pbase()`, `pptr()`, `epptr()`, `eback()`, `gptr()`, and `egptr()` are
343
+ initialized as if by calling *`init-buf-ptrs`*`()` with an empty `buf`.
344
 
345
  *Returns:* A `basic_string<charT, traits, Allocator>` object move
346
  constructed from the `basic_stringbuf`’s underlying character sequence
347
  in `buf`. This can be achieved by first adjusting `buf` to have the same
348
  content as `view()`.
 
354
  Let `sv` be `basic_string_view<charT, traits>`.
355
 
356
  *Returns:* A `sv` object referring to the `basic_stringbuf`’s underlying
357
  character sequence in `buf`:
358
 
359
+ - If `ios_base::out` is set in *mode*, then
360
  `sv(pbase(), high_mark - pbase())` is returned.
361
+ - Otherwise, if `ios_base::in` is set in *mode*, then
362
  `sv(eback(), egptr() - eback())` is returned.
363
  - Otherwise, `sv()` is returned.
364
 
365
  [*Note 2*: Using the returned `sv` object after destruction or
366
  invalidation of the character sequence underlying `*this` is undefined
 
372
 
373
  *Effects:* Equivalent to:
374
 
375
  ``` cpp
376
  buf = s;
377
+ init-buf-ptrs();
378
  ```
379
 
380
  ``` cpp
381
  template<class SAlloc>
382
  void str(const basic_string<charT, traits, SAlloc>& s);
 
386
 
387
  *Effects:* Equivalent to:
388
 
389
  ``` cpp
390
  buf = s;
391
+ init-buf-ptrs();
392
  ```
393
 
394
  ``` cpp
395
  void str(basic_string<charT, traits, Allocator>&& s);
396
  ```
397
 
398
  *Effects:* Equivalent to:
399
 
400
  ``` cpp
401
  buf = std::move(s);
402
+ init-buf-ptrs();
403
+ ```
404
+
405
+ ``` cpp
406
+ template<class T>
407
+ void str(const T& t);
408
+ ```
409
+
410
+ *Constraints:*
411
+ `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
412
+ `true`.
413
+
414
+ *Effects:* Equivalent to:
415
+
416
+ ``` cpp
417
+ basic_string_view<charT, traits> sv = t;
418
+ buf = sv;
419
+ init-buf-ptrs();
420
  ```
421
 
422
  #### Overridden virtual functions <a id="stringbuf.virtuals">[[stringbuf.virtuals]]</a>
423
 
424
  ``` cpp
 
440
  - If `traits::eq_int_type(c, traits::eof())` returns `false` and if the
441
  input sequence has a putback position available, and if
442
  `traits::eq(to_char_type(c), gptr()[-1])` returns `true`, assigns
443
  `gptr() - 1` to `gptr()`. Returns: `c`.
444
  - If `traits::eq_int_type(c, traits::eof())` returns `false` and if the
445
+ input sequence has a putback position available, and if *mode* `&`
446
  `ios_base::out` is nonzero, assigns `c` to `*–gptr()`. Returns: `c`.
447
  - If `traits::eq_int_type(c, traits::eof())` returns `true` and if the
448
  input sequence has a putback position available, assigns `gptr() - 1`
449
  to `gptr()`. Returns: `traits::not_eof(c)`.
450
 
 
472
 
473
  *Remarks:* The function can alter the number of write positions
474
  available as a result of any call.
475
 
476
  The function can make a write position available only if `ios_base::out`
477
+ is set in *mode*. To make a write position available, the function
478
  reallocates (or initially allocates) an array object with a sufficient
479
  number of elements to hold the current array object (if any), plus at
480
+ least one additional write position. If `ios_base::in` is set in *mode*,
481
  the function alters the read end pointer `egptr()` to point just past
482
  the new write position.
483
 
484
  ``` cpp
485
  pos_type seekoff(off_type off, ios_base::seekdir way,