From Jason Turner

[string.streams]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0gypmgni/{from.md → to.md} +60 -41
tmp/tmp0gypmgni/{from.md → to.md} RENAMED
@@ -6,29 +6,47 @@
6
  namespace std {
7
  template<class charT, class traits = char_traits<charT>,
8
  class Allocator = allocator<charT>>
9
  class basic_stringbuf;
10
 
 
 
 
 
11
  using stringbuf = basic_stringbuf<char>;
12
  using wstringbuf = basic_stringbuf<wchar_t>;
13
 
14
  template<class charT, class traits = char_traits<charT>,
15
  class Allocator = allocator<charT>>
16
  class basic_istringstream;
17
 
 
 
 
 
18
  using istringstream = basic_istringstream<char>;
19
  using wistringstream = basic_istringstream<wchar_t>;
20
 
21
  template<class charT, class traits = char_traits<charT>,
22
  class Allocator = allocator<charT>>
23
  class basic_ostringstream;
 
 
 
 
 
24
  using ostringstream = basic_ostringstream<char>;
25
  using wostringstream = basic_ostringstream<wchar_t>;
26
 
27
  template<class charT, class traits = char_traits<charT>,
28
  class Allocator = allocator<charT>>
29
  class basic_stringstream;
 
 
 
 
 
30
  using stringstream = basic_stringstream<char>;
31
  using wstringstream = basic_stringstream<wchar_t>;
32
  }
33
  ```
34
 
@@ -36,10 +54,12 @@ The header `<sstream>` defines four class templates and eight types that
36
  associate stream buffers with objects of class `basic_string`, as
37
  described in  [[string.classes]].
38
 
39
  ### Class template `basic_stringbuf` <a id="stringbuf">[[stringbuf]]</a>
40
 
 
 
41
  ``` cpp
42
  namespace std {
43
  template<class charT, class traits = char_traits<charT>,
44
  class Allocator = allocator<charT>>
45
  class basic_stringbuf : public basic_streambuf<charT, traits> {
@@ -77,11 +97,11 @@ namespace std {
77
  ios_base::openmode which = ios_base::in | ios_base::out);
78
  basic_stringbuf(const basic_stringbuf&) = delete;
79
  basic_stringbuf(basic_stringbuf&& rhs);
80
  basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
81
 
82
- // [stringbuf.assign], assign and swap
83
  basic_stringbuf& operator=(const basic_stringbuf&) = delete;
84
  basic_stringbuf& operator=(basic_stringbuf&& rhs);
85
  void swap(basic_stringbuf& rhs) noexcept(see below);
86
 
87
  // [stringbuf.members], getters and setters
@@ -115,14 +135,10 @@ namespace std {
115
  private:
116
  ios_base::openmode mode; // exposition only
117
  basic_string<charT, traits, Allocator> buf; // exposition only
118
  void init_buf_ptrs(); // exposition only
119
  };
120
-
121
- template<class charT, class traits, class Allocator>
122
- void swap(basic_stringbuf<charT, traits, Allocator>& x,
123
- basic_stringbuf<charT, traits, Allocator>& y) noexcept(noexcept(x.swap(y)));
124
  }
125
  ```
126
 
127
  The class `basic_stringbuf` is derived from `basic_streambuf` to
128
  associate possibly the input sequence and possibly the output sequence
@@ -255,15 +271,15 @@ would have had if it had been move constructed from `rhs`
255
  void swap(basic_stringbuf& rhs) noexcept(see below);
256
  ```
257
 
258
  *Preconditions:*
259
  `allocator_traits<Allocator>::propagate_on_container_swap::value` is
260
- `true` or `get_allocator() == s.get_allocator()` is `true`.
261
 
262
  *Effects:* Exchanges the state of `*this` and `rhs`.
263
 
264
- *Remarks:* The expression inside `noexcept` is equivalent to:
265
  `allocator_traits<Allocator>::propagate_on_container_swap::value ||`
266
  `allocator_traits<Allocator>::is_always_equal::value`.
267
 
268
  ``` cpp
269
  template<class charT, class traits, class Allocator>
@@ -301,12 +317,12 @@ according to `mode`.
301
  - otherwise `pptr() == pbase()` is `true`.
302
  - If `ios_base::in` is set in `mode`, `eback()` points to `buf.front()`,
303
  and `(gptr() == eback() && egptr() == eback() + buf.size())` is
304
  `true`.
305
 
306
- [*Note 1*: For efficiency reasons, stream buffer operations might
307
- violate invariants of `buf` while it is held encapsulated in the
308
  `basic_stringbuf`, e.g., by writing to characters in the range
309
  \[`buf.data() + buf.size()`, `buf.data() + buf.capacity()`). All
310
  operations retrieving a `basic_string` from `buf` ensure that the
311
  `basic_string` invariants hold on the returned value. — *end note*]
312
 
@@ -342,19 +358,19 @@ return basic_string<charT, traits, SAlloc>(view(), sa);
342
 
343
  ``` cpp
344
  basic_string<charT, traits, Allocator> str() &&;
345
  ```
346
 
 
 
 
 
347
  *Returns:* A `basic_string<charT, traits, Allocator>` object move
348
  constructed from the `basic_stringbuf`’s underlying character sequence
349
  in `buf`. This can be achieved by first adjusting `buf` to have the same
350
  content as `view()`.
351
 
352
- *Ensures:* The underlying character sequence `buf` is empty and
353
- `pbase()`, `pptr()`, `epptr()`, `eback()`, `gptr()`, and `egptr()` are
354
- initialized as if by calling `init_buf_ptrs()` with an empty `buf`.
355
-
356
  ``` cpp
357
  basic_string_view<charT, traits> view() const noexcept;
358
  ```
359
 
360
  Let `sv` be `basic_string_view<charT, traits>`.
@@ -430,11 +446,11 @@ sequence, if possible, in one of three ways:
430
  input sequence has a putback position available, and if
431
  `traits::eq(to_char_type(c), gptr()[-1])` returns `true`, assigns
432
  `gptr() - 1` to `gptr()`. Returns: `c`.
433
  - If `traits::eq_int_type(c, traits::eof())` returns `false` and if the
434
  input sequence has a putback position available, and if `mode` `&`
435
- `ios_base::out` is nonzero, assigns `c` to `*``gptr()`. Returns: `c`.
436
  - If `traits::eq_int_type(c, traits::eof())` returns `true` and if the
437
  input sequence has a putback position available, assigns `gptr() - 1`
438
  to `gptr()`. Returns: `traits::not_eof(c)`.
439
 
440
  *Returns:* As specified above, or `traits::eof()` to indicate failure.
@@ -455,15 +471,15 @@ sequence, if possible, in one of two ways:
455
  function calls `sputc(c)`. Signals success by returning `c`.
456
  - If `traits::eq_int_type(c, traits::eof())` returns `true`, there is no
457
  character to append. Signals success by returning a value other than
458
  `traits::eof()`.
459
 
 
 
460
  *Remarks:* The function can alter the number of write positions
461
  available as a result of any call.
462
 
463
- *Returns:* As specified above, or `traits::eof()` to indicate failure.
464
-
465
  The function can make a write position available only if `ios_base::out`
466
  is set in `mode`. To make a write position available, the function
467
  reallocates (or initially allocates) an array object with a sufficient
468
  number of elements to hold the current array object (if any), plus at
469
  least one additional write position. If `ios_base::in` is set in `mode`,
@@ -524,20 +540,22 @@ pos_type seekpos(pos_type sp,
524
 
525
  *Returns:* `sp` to indicate success, or `pos_type(off_type(-1))` to
526
  indicate failure.
527
 
528
  ``` cpp
529
- basic_streambuf<charT, traits>* setbuf(charT* s, streamsize n);
530
  ```
531
 
532
  *Effects:* *implementation-defined*, except that `setbuf(0, 0)` has no
533
  effect.
534
 
535
  *Returns:* `this`.
536
 
537
  ### Class template `basic_istringstream` <a id="istringstream">[[istringstream]]</a>
538
 
 
 
539
  ``` cpp
540
  namespace std {
541
  template<class charT, class traits = char_traits<charT>,
542
  class Allocator = allocator<charT>>
543
  class basic_istringstream : public basic_istream<charT, traits> {
@@ -572,13 +590,14 @@ namespace std {
572
  const basic_string<charT, traits, SAlloc>& s,
573
  ios_base::openmode which = ios_base::in);
574
  basic_istringstream(const basic_istringstream&) = delete;
575
  basic_istringstream(basic_istringstream&& rhs);
576
 
577
- // [istringstream.assign], assign and swap
578
  basic_istringstream& operator=(const basic_istringstream&) = delete;
579
  basic_istringstream& operator=(basic_istringstream&& rhs);
 
 
580
  void swap(basic_istringstream& rhs);
581
 
582
  // [istringstream.members], members
583
  basic_stringbuf<charT, traits, Allocator>* rdbuf() const;
584
  basic_string<charT, traits, Allocator> str() const &;
@@ -593,14 +612,10 @@ namespace std {
593
  void str(basic_string<charT, traits, Allocator>&& s);
594
 
595
  private:
596
  basic_stringbuf<charT, traits, Allocator> sb; // exposition only
597
  };
598
-
599
- template<class charT, class traits, class Allocator>
600
- void swap(basic_istringstream<charT, traits, Allocator>& x,
601
- basic_istringstream<charT, traits, Allocator>& y);
602
  }
603
  ```
604
 
605
  The class `basic_istringstream<charT, traits, Allocator>` supports
606
  reading objects of class `basic_string<{}charT, traits, Allocator>`. It
@@ -627,11 +642,12 @@ explicit basic_istringstream(
627
  ios_base::openmode which = ios_base::in);
628
  ```
629
 
630
  *Effects:* Initializes the base class with
631
  `basic_istream<charT, traits>(addressof(sb))` [[istream]] and `sb` with
632
- `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::in)`([[stringbuf.cons]]).
 
633
 
634
  ``` cpp
635
  basic_istringstream(ios_base::openmode which, const Allocator& a);
636
  ```
637
 
@@ -658,11 +674,12 @@ template<class SAlloc>
658
  ios_base::openmode which, const Allocator& a);
659
  ```
660
 
661
  *Effects:* Initializes the base class with
662
  `basic_istream<charT, traits>(addressof(sb))` [[istream]] and `sb` with
663
- `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::in, a)`([[stringbuf.cons]]).
 
664
 
665
  ``` cpp
666
  template<class SAlloc>
667
  explicit basic_istringstream(
668
  const basic_string<charT, traits, SAlloc>& s,
@@ -682,11 +699,11 @@ basic_istringstream(basic_istringstream&& rhs);
682
  by move constructing the base class, and the contained
683
  `basic_stringbuf`. Then calls
684
  `basic_istream<charT, traits>::set_rdbuf(addressof(sb))` to install the
685
  contained `basic_stringbuf`.
686
 
687
- #### Assignment and swap <a id="istringstream.assign">[[istringstream.assign]]</a>
688
 
689
  ``` cpp
690
  void swap(basic_istringstream& rhs);
691
  ```
692
 
@@ -758,10 +775,12 @@ void str(basic_string<charT, traits, Allocator>&& s);
758
 
759
  *Effects:* Equivalent to: `rdbuf()->str(std::move(s));`
760
 
761
  ### Class template `basic_ostringstream` <a id="ostringstream">[[ostringstream]]</a>
762
 
 
 
763
  ``` cpp
764
  namespace std {
765
  template<class charT, class traits = char_traits<charT>,
766
  class Allocator = allocator<charT>>
767
  class basic_ostringstream : public basic_ostream<charT, traits> {
@@ -796,13 +815,14 @@ namespace std {
796
  const basic_string<charT, traits, SAlloc>& s,
797
  ios_base::openmode which = ios_base::out);
798
  basic_ostringstream(const basic_ostringstream&) = delete;
799
  basic_ostringstream(basic_ostringstream&& rhs);
800
 
801
- // [ostringstream.assign], assign and swap
802
  basic_ostringstream& operator=(const basic_ostringstream&) = delete;
803
  basic_ostringstream& operator=(basic_ostringstream&& rhs);
 
 
804
  void swap(basic_ostringstream& rhs);
805
 
806
  // [ostringstream.members], members
807
  basic_stringbuf<charT, traits, Allocator>* rdbuf() const;
808
 
@@ -818,14 +838,10 @@ namespace std {
818
  void str(basic_string<charT, traits, Allocator>&& s);
819
 
820
  private:
821
  basic_stringbuf<charT, traits, Allocator> sb; // exposition only
822
  };
823
-
824
- template<class charT, class traits, class Allocator>
825
- void swap(basic_ostringstream<charT, traits, Allocator>& x,
826
- basic_ostringstream<charT, traits, Allocator>& y);
827
  }
828
  ```
829
 
830
  The class `basic_ostringstream<charT, traits, Allocator>` supports
831
  writing objects of class `basic_string<{}charT, traits, Allocator>`. It
@@ -851,19 +867,21 @@ explicit basic_ostringstream(
851
  ios_base::openmode which = ios_base::out);
852
  ```
853
 
854
  *Effects:* Initializes the base class with
855
  `basic_ostream<charT, traits>(addressof(sb))` [[ostream]] and `sb` with
856
- `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::out)`([[stringbuf.cons]]).
 
857
 
858
  ``` cpp
859
  basic_ostringstream(ios_base::openmode which, const Allocator& a);
860
  ```
861
 
862
  *Effects:* Initializes the base class with
863
  `basic_ostream<charT, traits>(addressof(sb))` [[ostream]] and `sb` with
864
- `basic_stringbuf<charT, traits, Allocator>(which | ios_base::out, a)`([[stringbuf.cons]]).
 
865
 
866
  ``` cpp
867
  explicit basic_ostringstream(
868
  basic_string<charT, traits, Allocator>&& s,
869
  ios_base::openmode which = ios_base::out);
@@ -881,11 +899,12 @@ template<class SAlloc>
881
  ios_base::openmode which, const Allocator& a);
882
  ```
883
 
884
  *Effects:* Initializes the base class with
885
  `basic_ostream<charT, traits>(addressof(sb))` [[ostream]] and `sb` with
886
- `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::out, a)`([[stringbuf.cons]]).
 
887
 
888
  ``` cpp
889
  template<class SAlloc>
890
  explicit basic_ostringstream(
891
  const basic_string<charT, traits, SAlloc>& s,
@@ -894,11 +913,12 @@ template<class SAlloc>
894
 
895
  *Constraints:* `is_same_v<SAlloc,Allocator>` is `false`.
896
 
897
  *Effects:* Initializes the base class with
898
  `basic_ostream<charT, traits>(addressof(sb))` [[ostream]] and `sb` with
899
- `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::out)`([[stringbuf.cons]]).
 
900
 
901
  ``` cpp
902
  basic_ostringstream(basic_ostringstream&& rhs);
903
  ```
904
 
@@ -906,11 +926,11 @@ basic_ostringstream(basic_ostringstream&& rhs);
906
  by move constructing the base class, and the contained
907
  `basic_stringbuf`. Then calls
908
  `basic_ostream<charT, traits>::set_rdbuf(addressof(sb))` to install the
909
  contained `basic_stringbuf`.
910
 
911
- #### Assignment and swap <a id="ostringstream.assign">[[ostringstream.assign]]</a>
912
 
913
  ``` cpp
914
  void swap(basic_ostringstream& rhs);
915
  ```
916
 
@@ -982,10 +1002,12 @@ void str(basic_string<charT, traits, Allocator>&& s);
982
 
983
  *Effects:* Equivalent to: `rdbuf()->str(std::move(s));`
984
 
985
  ### Class template `basic_stringstream` <a id="stringstream">[[stringstream]]</a>
986
 
 
 
987
  ``` cpp
988
  namespace std {
989
  template<class charT, class traits = char_traits<charT>,
990
  class Allocator = allocator<charT>>
991
  class basic_stringstream : public basic_iostream<charT, traits> {
@@ -1020,13 +1042,14 @@ namespace std {
1020
  const basic_string<charT, traits, SAlloc>& s,
1021
  ios_base::openmode which = ios_base::out | ios_base::in);
1022
  basic_stringstream(const basic_stringstream&) = delete;
1023
  basic_stringstream(basic_stringstream&& rhs);
1024
 
1025
- // [stringstream.assign], assign and swap
1026
  basic_stringstream& operator=(const basic_stringstream&) = delete;
1027
  basic_stringstream& operator=(basic_stringstream&& rhs);
 
 
1028
  void swap(basic_stringstream& rhs);
1029
 
1030
  // [stringstream.members], members
1031
  basic_stringbuf<charT, traits, Allocator>* rdbuf() const;
1032
 
@@ -1042,14 +1065,10 @@ namespace std {
1042
  void str(basic_string<charT, traits, Allocator>&& s);
1043
 
1044
  private:
1045
  basic_stringbuf<charT, traits> sb; // exposition only
1046
  };
1047
-
1048
- template<class charT, class traits, class Allocator>
1049
- void swap(basic_stringstream<charT, traits, Allocator>& x,
1050
- basic_stringstream<charT, traits, Allocator>& y);
1051
  }
1052
  ```
1053
 
1054
  The class template `basic_stringstream<charT, traits>` supports reading
1055
  and writing from objects of class
@@ -1135,11 +1154,11 @@ basic_stringstream(basic_stringstream&& rhs);
1135
  by move constructing the base class, and the contained
1136
  `basic_stringbuf`. Then calls
1137
  `basic_istream<charT, traits>::set_rdbuf(addressof(sb))` to install the
1138
  contained `basic_stringbuf`.
1139
 
1140
- #### Assignment and swap <a id="stringstream.assign">[[stringstream.assign]]</a>
1141
 
1142
  ``` cpp
1143
  void swap(basic_stringstream& rhs);
1144
  ```
1145
 
 
6
  namespace std {
7
  template<class charT, class traits = char_traits<charT>,
8
  class Allocator = allocator<charT>>
9
  class basic_stringbuf;
10
 
11
+ template<class charT, class traits, class Allocator>
12
+ void swap(basic_stringbuf<charT, traits, Allocator>& x,
13
+ basic_stringbuf<charT, traits, Allocator>& y) noexcept(noexcept(x.swap(y)));
14
+
15
  using stringbuf = basic_stringbuf<char>;
16
  using wstringbuf = basic_stringbuf<wchar_t>;
17
 
18
  template<class charT, class traits = char_traits<charT>,
19
  class Allocator = allocator<charT>>
20
  class basic_istringstream;
21
 
22
+ template<class charT, class traits, class Allocator>
23
+ void swap(basic_istringstream<charT, traits, Allocator>& x,
24
+ basic_istringstream<charT, traits, Allocator>& y);
25
+
26
  using istringstream = basic_istringstream<char>;
27
  using wistringstream = basic_istringstream<wchar_t>;
28
 
29
  template<class charT, class traits = char_traits<charT>,
30
  class Allocator = allocator<charT>>
31
  class basic_ostringstream;
32
+
33
+ template<class charT, class traits, class Allocator>
34
+ void swap(basic_ostringstream<charT, traits, Allocator>& x,
35
+ basic_ostringstream<charT, traits, Allocator>& y);
36
+
37
  using ostringstream = basic_ostringstream<char>;
38
  using wostringstream = basic_ostringstream<wchar_t>;
39
 
40
  template<class charT, class traits = char_traits<charT>,
41
  class Allocator = allocator<charT>>
42
  class basic_stringstream;
43
+
44
+ template<class charT, class traits, class Allocator>
45
+ void swap(basic_stringstream<charT, traits, Allocator>& x,
46
+ basic_stringstream<charT, traits, Allocator>& y);
47
+
48
  using stringstream = basic_stringstream<char>;
49
  using wstringstream = basic_stringstream<wchar_t>;
50
  }
51
  ```
52
 
 
54
  associate stream buffers with objects of class `basic_string`, as
55
  described in  [[string.classes]].
56
 
57
  ### Class template `basic_stringbuf` <a id="stringbuf">[[stringbuf]]</a>
58
 
59
+ #### General <a id="stringbuf.general">[[stringbuf.general]]</a>
60
+
61
  ``` cpp
62
  namespace std {
63
  template<class charT, class traits = char_traits<charT>,
64
  class Allocator = allocator<charT>>
65
  class basic_stringbuf : public basic_streambuf<charT, traits> {
 
97
  ios_base::openmode which = ios_base::in | ios_base::out);
98
  basic_stringbuf(const basic_stringbuf&) = delete;
99
  basic_stringbuf(basic_stringbuf&& rhs);
100
  basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
101
 
102
+ // [stringbuf.assign], assignment and swap
103
  basic_stringbuf& operator=(const basic_stringbuf&) = delete;
104
  basic_stringbuf& operator=(basic_stringbuf&& rhs);
105
  void swap(basic_stringbuf& rhs) noexcept(see below);
106
 
107
  // [stringbuf.members], getters and setters
 
135
  private:
136
  ios_base::openmode mode; // exposition only
137
  basic_string<charT, traits, Allocator> buf; // exposition only
138
  void init_buf_ptrs(); // exposition only
139
  };
 
 
 
 
140
  }
141
  ```
142
 
143
  The class `basic_stringbuf` is derived from `basic_streambuf` to
144
  associate possibly the input sequence and possibly the output sequence
 
271
  void swap(basic_stringbuf& rhs) noexcept(see below);
272
  ```
273
 
274
  *Preconditions:*
275
  `allocator_traits<Allocator>::propagate_on_container_swap::value` is
276
+ `true` or `get_allocator() == rhs.get_allocator()` is `true`.
277
 
278
  *Effects:* Exchanges the state of `*this` and `rhs`.
279
 
280
+ *Remarks:* The exception specification is equivalent to:
281
  `allocator_traits<Allocator>::propagate_on_container_swap::value ||`
282
  `allocator_traits<Allocator>::is_always_equal::value`.
283
 
284
  ``` cpp
285
  template<class charT, class traits, class Allocator>
 
317
  - otherwise `pptr() == pbase()` is `true`.
318
  - If `ios_base::in` is set in `mode`, `eback()` points to `buf.front()`,
319
  and `(gptr() == eback() && egptr() == eback() + buf.size())` is
320
  `true`.
321
 
322
+ [*Note 1*: For efficiency reasons, stream buffer operations can violate
323
+ invariants of `buf` while it is held encapsulated in the
324
  `basic_stringbuf`, e.g., by writing to characters in the range
325
  \[`buf.data() + buf.size()`, `buf.data() + buf.capacity()`). All
326
  operations retrieving a `basic_string` from `buf` ensure that the
327
  `basic_string` invariants hold on the returned value. — *end note*]
328
 
 
358
 
359
  ``` cpp
360
  basic_string<charT, traits, Allocator> str() &&;
361
  ```
362
 
363
+ *Ensures:* The underlying character sequence `buf` is empty and
364
+ `pbase()`, `pptr()`, `epptr()`, `eback()`, `gptr()`, and `egptr()` are
365
+ initialized as if by calling `init_buf_ptrs()` with an empty `buf`.
366
+
367
  *Returns:* A `basic_string<charT, traits, Allocator>` object move
368
  constructed from the `basic_stringbuf`’s underlying character sequence
369
  in `buf`. This can be achieved by first adjusting `buf` to have the same
370
  content as `view()`.
371
 
 
 
 
 
372
  ``` cpp
373
  basic_string_view<charT, traits> view() const noexcept;
374
  ```
375
 
376
  Let `sv` be `basic_string_view<charT, traits>`.
 
446
  input sequence has a putback position available, and if
447
  `traits::eq(to_char_type(c), gptr()[-1])` returns `true`, assigns
448
  `gptr() - 1` to `gptr()`. Returns: `c`.
449
  - If `traits::eq_int_type(c, traits::eof())` returns `false` and if the
450
  input sequence has a putback position available, and if `mode` `&`
451
+ `ios_base::out` is nonzero, assigns `c` to `*gptr()`. Returns: `c`.
452
  - If `traits::eq_int_type(c, traits::eof())` returns `true` and if the
453
  input sequence has a putback position available, assigns `gptr() - 1`
454
  to `gptr()`. Returns: `traits::not_eof(c)`.
455
 
456
  *Returns:* As specified above, or `traits::eof()` to indicate failure.
 
471
  function calls `sputc(c)`. Signals success by returning `c`.
472
  - If `traits::eq_int_type(c, traits::eof())` returns `true`, there is no
473
  character to append. Signals success by returning a value other than
474
  `traits::eof()`.
475
 
476
+ *Returns:* As specified above, or `traits::eof()` to indicate failure.
477
+
478
  *Remarks:* The function can alter the number of write positions
479
  available as a result of any call.
480
 
 
 
481
  The function can make a write position available only if `ios_base::out`
482
  is set in `mode`. To make a write position available, the function
483
  reallocates (or initially allocates) an array object with a sufficient
484
  number of elements to hold the current array object (if any), plus at
485
  least one additional write position. If `ios_base::in` is set in `mode`,
 
540
 
541
  *Returns:* `sp` to indicate success, or `pos_type(off_type(-1))` to
542
  indicate failure.
543
 
544
  ``` cpp
545
+ basic_streambuf<charT, traits>* setbuf(charT* s, streamsize n) override;
546
  ```
547
 
548
  *Effects:* *implementation-defined*, except that `setbuf(0, 0)` has no
549
  effect.
550
 
551
  *Returns:* `this`.
552
 
553
  ### Class template `basic_istringstream` <a id="istringstream">[[istringstream]]</a>
554
 
555
+ #### General <a id="istringstream.general">[[istringstream.general]]</a>
556
+
557
  ``` cpp
558
  namespace std {
559
  template<class charT, class traits = char_traits<charT>,
560
  class Allocator = allocator<charT>>
561
  class basic_istringstream : public basic_istream<charT, traits> {
 
590
  const basic_string<charT, traits, SAlloc>& s,
591
  ios_base::openmode which = ios_base::in);
592
  basic_istringstream(const basic_istringstream&) = delete;
593
  basic_istringstream(basic_istringstream&& rhs);
594
 
 
595
  basic_istringstream& operator=(const basic_istringstream&) = delete;
596
  basic_istringstream& operator=(basic_istringstream&& rhs);
597
+
598
+ // [istringstream.swap], swap
599
  void swap(basic_istringstream& rhs);
600
 
601
  // [istringstream.members], members
602
  basic_stringbuf<charT, traits, Allocator>* rdbuf() const;
603
  basic_string<charT, traits, Allocator> str() const &;
 
612
  void str(basic_string<charT, traits, Allocator>&& s);
613
 
614
  private:
615
  basic_stringbuf<charT, traits, Allocator> sb; // exposition only
616
  };
 
 
 
 
617
  }
618
  ```
619
 
620
  The class `basic_istringstream<charT, traits, Allocator>` supports
621
  reading objects of class `basic_string<{}charT, traits, Allocator>`. It
 
642
  ios_base::openmode which = ios_base::in);
643
  ```
644
 
645
  *Effects:* Initializes the base class with
646
  `basic_istream<charT, traits>(addressof(sb))` [[istream]] and `sb` with
647
+ `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::in)`
648
+ [[stringbuf.cons]].
649
 
650
  ``` cpp
651
  basic_istringstream(ios_base::openmode which, const Allocator& a);
652
  ```
653
 
 
674
  ios_base::openmode which, const Allocator& a);
675
  ```
676
 
677
  *Effects:* Initializes the base class with
678
  `basic_istream<charT, traits>(addressof(sb))` [[istream]] and `sb` with
679
+ `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::in, a)`
680
+ [[stringbuf.cons]].
681
 
682
  ``` cpp
683
  template<class SAlloc>
684
  explicit basic_istringstream(
685
  const basic_string<charT, traits, SAlloc>& s,
 
699
  by move constructing the base class, and the contained
700
  `basic_stringbuf`. Then calls
701
  `basic_istream<charT, traits>::set_rdbuf(addressof(sb))` to install the
702
  contained `basic_stringbuf`.
703
 
704
+ #### Swap <a id="istringstream.swap">[[istringstream.swap]]</a>
705
 
706
  ``` cpp
707
  void swap(basic_istringstream& rhs);
708
  ```
709
 
 
775
 
776
  *Effects:* Equivalent to: `rdbuf()->str(std::move(s));`
777
 
778
  ### Class template `basic_ostringstream` <a id="ostringstream">[[ostringstream]]</a>
779
 
780
+ #### General <a id="ostringstream.general">[[ostringstream.general]]</a>
781
+
782
  ``` cpp
783
  namespace std {
784
  template<class charT, class traits = char_traits<charT>,
785
  class Allocator = allocator<charT>>
786
  class basic_ostringstream : public basic_ostream<charT, traits> {
 
815
  const basic_string<charT, traits, SAlloc>& s,
816
  ios_base::openmode which = ios_base::out);
817
  basic_ostringstream(const basic_ostringstream&) = delete;
818
  basic_ostringstream(basic_ostringstream&& rhs);
819
 
 
820
  basic_ostringstream& operator=(const basic_ostringstream&) = delete;
821
  basic_ostringstream& operator=(basic_ostringstream&& rhs);
822
+
823
+ // [ostringstream.swap], swap
824
  void swap(basic_ostringstream& rhs);
825
 
826
  // [ostringstream.members], members
827
  basic_stringbuf<charT, traits, Allocator>* rdbuf() const;
828
 
 
838
  void str(basic_string<charT, traits, Allocator>&& s);
839
 
840
  private:
841
  basic_stringbuf<charT, traits, Allocator> sb; // exposition only
842
  };
 
 
 
 
843
  }
844
  ```
845
 
846
  The class `basic_ostringstream<charT, traits, Allocator>` supports
847
  writing objects of class `basic_string<{}charT, traits, Allocator>`. It
 
867
  ios_base::openmode which = ios_base::out);
868
  ```
869
 
870
  *Effects:* Initializes the base class with
871
  `basic_ostream<charT, traits>(addressof(sb))` [[ostream]] and `sb` with
872
+ `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::out)`
873
+ [[stringbuf.cons]].
874
 
875
  ``` cpp
876
  basic_ostringstream(ios_base::openmode which, const Allocator& a);
877
  ```
878
 
879
  *Effects:* Initializes the base class with
880
  `basic_ostream<charT, traits>(addressof(sb))` [[ostream]] and `sb` with
881
+ `basic_stringbuf<charT, traits, Allocator>(which | ios_base::out, a)`
882
+ [[stringbuf.cons]].
883
 
884
  ``` cpp
885
  explicit basic_ostringstream(
886
  basic_string<charT, traits, Allocator>&& s,
887
  ios_base::openmode which = ios_base::out);
 
899
  ios_base::openmode which, const Allocator& a);
900
  ```
901
 
902
  *Effects:* Initializes the base class with
903
  `basic_ostream<charT, traits>(addressof(sb))` [[ostream]] and `sb` with
904
+ `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::out, a)`
905
+ [[stringbuf.cons]].
906
 
907
  ``` cpp
908
  template<class SAlloc>
909
  explicit basic_ostringstream(
910
  const basic_string<charT, traits, SAlloc>& s,
 
913
 
914
  *Constraints:* `is_same_v<SAlloc,Allocator>` is `false`.
915
 
916
  *Effects:* Initializes the base class with
917
  `basic_ostream<charT, traits>(addressof(sb))` [[ostream]] and `sb` with
918
+ `basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::out)`
919
+ [[stringbuf.cons]].
920
 
921
  ``` cpp
922
  basic_ostringstream(basic_ostringstream&& rhs);
923
  ```
924
 
 
926
  by move constructing the base class, and the contained
927
  `basic_stringbuf`. Then calls
928
  `basic_ostream<charT, traits>::set_rdbuf(addressof(sb))` to install the
929
  contained `basic_stringbuf`.
930
 
931
+ #### Swap <a id="ostringstream.swap">[[ostringstream.swap]]</a>
932
 
933
  ``` cpp
934
  void swap(basic_ostringstream& rhs);
935
  ```
936
 
 
1002
 
1003
  *Effects:* Equivalent to: `rdbuf()->str(std::move(s));`
1004
 
1005
  ### Class template `basic_stringstream` <a id="stringstream">[[stringstream]]</a>
1006
 
1007
+ #### General <a id="stringstream.general">[[stringstream.general]]</a>
1008
+
1009
  ``` cpp
1010
  namespace std {
1011
  template<class charT, class traits = char_traits<charT>,
1012
  class Allocator = allocator<charT>>
1013
  class basic_stringstream : public basic_iostream<charT, traits> {
 
1042
  const basic_string<charT, traits, SAlloc>& s,
1043
  ios_base::openmode which = ios_base::out | ios_base::in);
1044
  basic_stringstream(const basic_stringstream&) = delete;
1045
  basic_stringstream(basic_stringstream&& rhs);
1046
 
 
1047
  basic_stringstream& operator=(const basic_stringstream&) = delete;
1048
  basic_stringstream& operator=(basic_stringstream&& rhs);
1049
+
1050
+ // [stringstream.swap], swap
1051
  void swap(basic_stringstream& rhs);
1052
 
1053
  // [stringstream.members], members
1054
  basic_stringbuf<charT, traits, Allocator>* rdbuf() const;
1055
 
 
1065
  void str(basic_string<charT, traits, Allocator>&& s);
1066
 
1067
  private:
1068
  basic_stringbuf<charT, traits> sb; // exposition only
1069
  };
 
 
 
 
1070
  }
1071
  ```
1072
 
1073
  The class template `basic_stringstream<charT, traits>` supports reading
1074
  and writing from objects of class
 
1154
  by move constructing the base class, and the contained
1155
  `basic_stringbuf`. Then calls
1156
  `basic_istream<charT, traits>::set_rdbuf(addressof(sb))` to install the
1157
  contained `basic_stringbuf`.
1158
 
1159
+ #### Swap <a id="stringstream.swap">[[stringstream.swap]]</a>
1160
 
1161
  ``` cpp
1162
  void swap(basic_stringstream& rhs);
1163
  ```
1164