From Jason Turner

[stringbuf]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmporjlzkiq/{from.md → to.md} +15 -17
tmp/tmporjlzkiq/{from.md → to.md} RENAMED
@@ -1,7 +1,9 @@
1
  ### Class template `basic_stringbuf` <a id="stringbuf">[[stringbuf]]</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> {
@@ -39,11 +41,11 @@ namespace std {
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], assign and swap
45
  basic_stringbuf& operator=(const basic_stringbuf&) = delete;
46
  basic_stringbuf& operator=(basic_stringbuf&& rhs);
47
  void swap(basic_stringbuf& rhs) noexcept(see below);
48
 
49
  // [stringbuf.members], getters and setters
@@ -77,14 +79,10 @@ namespace std {
77
  private:
78
  ios_base::openmode mode; // exposition only
79
  basic_string<charT, traits, Allocator> buf; // exposition only
80
  void init_buf_ptrs(); // exposition only
81
  };
82
-
83
- template<class charT, class traits, class Allocator>
84
- void swap(basic_stringbuf<charT, traits, Allocator>& x,
85
- basic_stringbuf<charT, traits, Allocator>& y) noexcept(noexcept(x.swap(y)));
86
  }
87
  ```
88
 
89
  The class `basic_stringbuf` is derived from `basic_streambuf` to
90
  associate possibly the input sequence and possibly the output sequence
@@ -217,15 +215,15 @@ would have had if it had been move constructed from `rhs`
217
  void swap(basic_stringbuf& rhs) noexcept(see below);
218
  ```
219
 
220
  *Preconditions:*
221
  `allocator_traits<Allocator>::propagate_on_container_swap::value` is
222
- `true` or `get_allocator() == s.get_allocator()` is `true`.
223
 
224
  *Effects:* Exchanges the state of `*this` and `rhs`.
225
 
226
- *Remarks:* The expression inside `noexcept` is equivalent to:
227
  `allocator_traits<Allocator>::propagate_on_container_swap::value ||`
228
  `allocator_traits<Allocator>::is_always_equal::value`.
229
 
230
  ``` cpp
231
  template<class charT, class traits, class Allocator>
@@ -263,12 +261,12 @@ according to `mode`.
263
  - otherwise `pptr() == pbase()` is `true`.
264
  - If `ios_base::in` is set in `mode`, `eback()` points to `buf.front()`,
265
  and `(gptr() == eback() && egptr() == eback() + buf.size())` is
266
  `true`.
267
 
268
- [*Note 1*: For efficiency reasons, stream buffer operations might
269
- violate invariants of `buf` while it is held encapsulated in the
270
  `basic_stringbuf`, e.g., by writing to characters in the range
271
  \[`buf.data() + buf.size()`, `buf.data() + buf.capacity()`). All
272
  operations retrieving a `basic_string` from `buf` ensure that the
273
  `basic_string` invariants hold on the returned value. — *end note*]
274
 
@@ -304,19 +302,19 @@ return basic_string<charT, traits, SAlloc>(view(), sa);
304
 
305
  ``` cpp
306
  basic_string<charT, traits, Allocator> str() &&;
307
  ```
308
 
 
 
 
 
309
  *Returns:* A `basic_string<charT, traits, Allocator>` object move
310
  constructed from the `basic_stringbuf`’s underlying character sequence
311
  in `buf`. This can be achieved by first adjusting `buf` to have the same
312
  content as `view()`.
313
 
314
- *Ensures:* The underlying character sequence `buf` is empty and
315
- `pbase()`, `pptr()`, `epptr()`, `eback()`, `gptr()`, and `egptr()` are
316
- initialized as if by calling `init_buf_ptrs()` with an empty `buf`.
317
-
318
  ``` cpp
319
  basic_string_view<charT, traits> view() const noexcept;
320
  ```
321
 
322
  Let `sv` be `basic_string_view<charT, traits>`.
@@ -392,11 +390,11 @@ sequence, if possible, in one of three ways:
392
  input sequence has a putback position available, and if
393
  `traits::eq(to_char_type(c), gptr()[-1])` returns `true`, assigns
394
  `gptr() - 1` to `gptr()`. Returns: `c`.
395
  - If `traits::eq_int_type(c, traits::eof())` returns `false` and if the
396
  input sequence has a putback position available, and if `mode` `&`
397
- `ios_base::out` is nonzero, assigns `c` to `*``gptr()`. Returns: `c`.
398
  - If `traits::eq_int_type(c, traits::eof())` returns `true` and if the
399
  input sequence has a putback position available, assigns `gptr() - 1`
400
  to `gptr()`. Returns: `traits::not_eof(c)`.
401
 
402
  *Returns:* As specified above, or `traits::eof()` to indicate failure.
@@ -417,15 +415,15 @@ sequence, if possible, in one of two ways:
417
  function calls `sputc(c)`. Signals success by returning `c`.
418
  - If `traits::eq_int_type(c, traits::eof())` returns `true`, there is no
419
  character to append. Signals success by returning a value other than
420
  `traits::eof()`.
421
 
 
 
422
  *Remarks:* The function can alter the number of write positions
423
  available as a result of any call.
424
 
425
- *Returns:* As specified above, or `traits::eof()` to indicate failure.
426
-
427
  The function can make a write position available only if `ios_base::out`
428
  is set in `mode`. To make a write position available, the function
429
  reallocates (or initially allocates) an array object with a sufficient
430
  number of elements to hold the current array object (if any), plus at
431
  least one additional write position. If `ios_base::in` is set in `mode`,
@@ -486,11 +484,11 @@ pos_type seekpos(pos_type sp,
486
 
487
  *Returns:* `sp` to indicate success, or `pos_type(off_type(-1))` to
488
  indicate failure.
489
 
490
  ``` cpp
491
- basic_streambuf<charT, traits>* setbuf(charT* s, streamsize n);
492
  ```
493
 
494
  *Effects:* *implementation-defined*, except that `setbuf(0, 0)` has no
495
  effect.
496
 
 
1
  ### Class template `basic_stringbuf` <a id="stringbuf">[[stringbuf]]</a>
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> {
 
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
47
  basic_stringbuf& operator=(const basic_stringbuf&) = delete;
48
  basic_stringbuf& operator=(basic_stringbuf&& rhs);
49
  void swap(basic_stringbuf& rhs) noexcept(see below);
50
 
51
  // [stringbuf.members], getters and setters
 
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
88
  associate possibly the input sequence and possibly the output sequence
 
215
  void swap(basic_stringbuf& rhs) noexcept(see below);
216
  ```
217
 
218
  *Preconditions:*
219
  `allocator_traits<Allocator>::propagate_on_container_swap::value` is
220
+ `true` or `get_allocator() == rhs.get_allocator()` is `true`.
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>
 
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
 
 
302
 
303
  ``` cpp
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()`.
315
 
 
 
 
 
316
  ``` cpp
317
  basic_string_view<charT, traits> view() const noexcept;
318
  ```
319
 
320
  Let `sv` be `basic_string_view<charT, traits>`.
 
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
 
400
  *Returns:* As specified above, or `traits::eof()` to indicate failure.
 
415
  function calls `sputc(c)`. Signals success by returning `c`.
416
  - If `traits::eq_int_type(c, traits::eof())` returns `true`, there is no
417
  character to append. Signals success by returning a value other than
418
  `traits::eof()`.
419
 
420
+ *Returns:* As specified above, or `traits::eof()` to indicate failure.
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`,
 
484
 
485
  *Returns:* `sp` to indicate success, or `pos_type(off_type(-1))` to
486
  indicate failure.
487
 
488
  ``` cpp
489
+ basic_streambuf<charT, traits>* setbuf(charT* s, streamsize n) override;
490
  ```
491
 
492
  *Effects:* *implementation-defined*, except that `setbuf(0, 0)` has no
493
  effect.
494