From Jason Turner

[span.streams]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpau3agep4/{from.md → to.md} +39 -35
tmp/tmpau3agep4/{from.md → to.md} RENAMED
@@ -6,47 +6,51 @@ The header `<spanstream>` defines class templates and types that
6
  associate stream buffers with objects whose types are specializations of
7
  `span` as described in [[views.span]].
8
 
9
  [*Note 1*: A user of these classes is responsible for ensuring that the
10
  character sequence represented by the given `span` outlives the use of
11
- the sequence by objects of the classes in subclause [[span.streams]].
12
- Using multiple `basic_spanbuf` objects referring to overlapping
13
- underlying sequences from different threads, where at least one
14
- `basic_spanbuf` object is used for writing to the sequence, results in a
15
- data race. — *end note*]
16
 
17
  ### Header `<spanstream>` synopsis <a id="spanstream.syn">[[spanstream.syn]]</a>
18
 
19
  ``` cpp
20
  namespace std {
 
21
  template<class charT, class traits = char_traits<charT>>
22
  class basic_spanbuf;
23
 
24
  template<class charT, class traits>
25
  void swap(basic_spanbuf<charT, traits>& x, basic_spanbuf<charT, traits>& y);
26
 
27
  using spanbuf = basic_spanbuf<char>;
28
  using wspanbuf = basic_spanbuf<wchar_t>;
29
 
 
30
  template<class charT, class traits = char_traits<charT>>
31
  class basic_ispanstream;
32
 
33
  template<class charT, class traits>
34
  void swap(basic_ispanstream<charT, traits>& x, basic_ispanstream<charT, traits>& y);
35
 
36
  using ispanstream = basic_ispanstream<char>;
37
  using wispanstream = basic_ispanstream<wchar_t>;
38
 
 
39
  template<class charT, class traits = char_traits<charT>>
40
  class basic_ospanstream;
41
 
42
  template<class charT, class traits>
43
  void swap(basic_ospanstream<charT, traits>& x, basic_ospanstream<charT, traits>& y);
44
 
45
  using ospanstream = basic_ospanstream<char>;
46
  using wospanstream = basic_ospanstream<wchar_t>;
47
 
 
48
  template<class charT, class traits = char_traits<charT>>
49
  class basic_spanstream;
50
 
51
  template<class charT, class traits>
52
  void swap(basic_spanstream<charT, traits>& x, basic_spanstream<charT, traits>& y);
@@ -65,13 +69,13 @@ namespace std {
65
  template<class charT, class traits = char_traits<charT>>
66
  class basic_spanbuf
67
  : public basic_streambuf<charT, traits> {
68
  public:
69
  using char_type = charT;
70
- using int_type = typename traits::int_type;
71
- using pos_type = typename traits::pos_type;
72
- using off_type = typename traits::off_type;
73
  using traits_type = traits;
74
 
75
  // [spanbuf.cons], constructors
76
  basic_spanbuf() : basic_spanbuf(ios_base::in | ios_base::out) {}
77
  explicit basic_spanbuf(ios_base::openmode which)
@@ -248,11 +252,11 @@ follows:
248
  - `(pptr() - pbase())` for the output sequence, or `(gptr() - eback())`
249
  for the input sequence when `way` is `ios_base::cur`;
250
  - when `way` is `ios_base::end` :
251
  - `(pptr() - pbase())` if `ios_base::out` is set in *mode* and
252
  `ios_base::in` is not set in *mode*,
253
- - `buf.size()` otherwise.
254
 
255
  If `baseoff` + `off` would overflow, or if `baseoff` + `off` is less
256
  than zero, or if `baseoff` + `off` is greater than *`buf`*`.size()`, the
257
  positioning operation fails. Otherwise, the function computes
258
 
@@ -295,13 +299,13 @@ namespace std {
295
  template<class charT, class traits = char_traits<charT>>
296
  class basic_ispanstream
297
  : public basic_istream<charT, traits> {
298
  public:
299
  using char_type = charT;
300
- using int_type = typename traits::int_type;
301
- using pos_type = typename traits::pos_type;
302
- using off_type = typename traits::off_type;
303
  using traits_type = traits;
304
 
305
  // [ispanstream.cons], constructors
306
  explicit basic_ispanstream(std::span<charT> s,
307
  ios_base::openmode which = ios_base::in);
@@ -337,33 +341,33 @@ includes the termination character `'\0'` in the underlying
337
  ``` cpp
338
  explicit basic_ispanstream(std::span<charT> s, ios_base::openmode which = ios_base::in);
339
  ```
340
 
341
  *Effects:* Initializes the base class with
342
- `basic_istream<charT, traits>(addressof(sb))` and `sb` with
343
  `basic_spanbuf<charT, traits>(s, which | ios_base::in)`
344
  [[spanbuf.cons]].
345
 
346
  ``` cpp
347
  basic_ispanstream(basic_ispanstream&& rhs);
348
  ```
349
 
350
- *Effects:* Initializes the base class with `std::move(rhs)` and `sb`
351
- with `std::move(rhs.sb)`. Next,
352
- `basic_istream<charT, traits>::set_rdbuf(addressof(sb))` is called to
353
- install the contained `basic_spanbuf`.
354
 
355
  ``` cpp
356
  template<class ROS> explicit basic_ispanstream(ROS&& s)
357
  ```
358
 
359
  *Constraints:* `ROS` models `ranges::borrowed_range`.
360
  `!convertible_to<ROS, std::span<charT>> && convertible_to<ROS, std::span<charT const>>`
361
  is `true`.
362
 
363
  *Effects:* Let `sp` be `std::span<const charT>(std::forward<ROS>(s))`.
364
- Equivalent to
365
 
366
  ``` cpp
367
  basic_ispanstream(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()))
368
  ```
369
 
@@ -421,11 +425,11 @@ is `true`.
421
 
422
  *Effects:* Let `sp` be `std::span<const charT>(std::forward<ROS>(s))`.
423
  Equivalent to:
424
 
425
  ``` cpp
426
- this->span(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()))
427
  ```
428
 
429
  ### Class template `basic_ospanstream` <a id="ospanstream">[[ospanstream]]</a>
430
 
431
  #### General <a id="ospanstream.general">[[ospanstream.general]]</a>
@@ -435,13 +439,13 @@ namespace std {
435
  template<class charT, class traits = char_traits<charT>>
436
  class basic_ospanstream
437
  : public basic_ostream<charT, traits> {
438
  public:
439
  using char_type = charT;
440
- using int_type = typename traits::int_type;
441
- using pos_type = typename traits::pos_type;
442
- using off_type = typename traits::off_type;
443
  using traits_type = traits;
444
 
445
  // [ospanstream.cons], constructors
446
  explicit basic_ospanstream(std::span<charT> s,
447
  ios_base::openmode which = ios_base::out);
@@ -472,22 +476,22 @@ namespace std {
472
  explicit basic_ospanstream(std::span<charT> s,
473
  ios_base::openmode which = ios_base::out);
474
  ```
475
 
476
  *Effects:* Initializes the base class with
477
- `basic_ostream<charT, traits>(addressof(sb))` and `sb` with
478
  `basic_spanbuf<charT, traits>(s, which | ios_base::out)`
479
  [[spanbuf.cons]].
480
 
481
  ``` cpp
482
  basic_ospanstream(basic_ospanstream&& rhs) noexcept;
483
  ```
484
 
485
- *Effects:* Initializes the base class with `std::move(rhs)` and `sb`
486
- with `std::move(rhs.sb)`. Next,
487
- `basic_ostream<charT, traits>::set_rdbuf(addressof(sb))` is called to
488
- install the contained `basic_spanbuf`.
489
 
490
  #### Swap <a id="ospanstream.swap">[[ospanstream.swap]]</a>
491
 
492
  ``` cpp
493
  void swap(basic_ospanstream& rhs);
@@ -540,13 +544,13 @@ namespace std {
540
  template<class charT, class traits = char_traits<charT>>
541
  class basic_spanstream
542
  : public basic_iostream<charT, traits> {
543
  public:
544
  using char_type = charT;
545
- using int_type = typename traits::int_type;
546
- using pos_type = typename traits::pos_type;
547
- using off_type = typename traits::off_type;
548
  using traits_type = traits;
549
 
550
  // [spanstream.cons], constructors
551
  explicit basic_spanstream(std::span<charT> s,
552
  ios_base::openmode which = ios_base::out | ios_base::in);
@@ -577,21 +581,21 @@ namespace std {
577
  explicit basic_spanstream(std::span<charT> s,
578
  ios_base::openmode which = ios_base::out | ios_bas::in);
579
  ```
580
 
581
  *Effects:* Initializes the base class with
582
- `basic_iostream<charT, traits>(addressof(sb))` and `sb` with
583
  `basic_spanbuf<charT, traits>(s, which)` [[spanbuf.cons]].
584
 
585
  ``` cpp
586
  basic_spanstream(basic_spanstream&& rhs);
587
  ```
588
 
589
- *Effects:* Initializes the base class with `std::move(rhs)` and `sb`
590
- with `std::move(rhs.sb)`. Next,
591
- `basic_iostream<charT, traits>::set_rdbuf(addressof(sb))` is called to
592
- install the contained `basic_spanbuf`.
593
 
594
  #### Swap <a id="spanstream.swap">[[spanstream.swap]]</a>
595
 
596
  ``` cpp
597
  void swap(basic_spanstream& rhs);
 
6
  associate stream buffers with objects whose types are specializations of
7
  `span` as described in [[views.span]].
8
 
9
  [*Note 1*: A user of these classes is responsible for ensuring that the
10
  character sequence represented by the given `span` outlives the use of
11
+ the sequence by objects of the classes in [[span.streams]]. Using
12
+ multiple `basic_spanbuf` objects referring to overlapping underlying
13
+ sequences from different threads, where at least one `basic_spanbuf`
14
+ object is used for writing to the sequence, results in a data
15
+ race. — *end note*]
16
 
17
  ### Header `<spanstream>` synopsis <a id="spanstream.syn">[[spanstream.syn]]</a>
18
 
19
  ``` cpp
20
  namespace std {
21
+ // [spanbuf], class template basic_spanbuf
22
  template<class charT, class traits = char_traits<charT>>
23
  class basic_spanbuf;
24
 
25
  template<class charT, class traits>
26
  void swap(basic_spanbuf<charT, traits>& x, basic_spanbuf<charT, traits>& y);
27
 
28
  using spanbuf = basic_spanbuf<char>;
29
  using wspanbuf = basic_spanbuf<wchar_t>;
30
 
31
+ // [ispanstream], class template basic_ispanstream
32
  template<class charT, class traits = char_traits<charT>>
33
  class basic_ispanstream;
34
 
35
  template<class charT, class traits>
36
  void swap(basic_ispanstream<charT, traits>& x, basic_ispanstream<charT, traits>& y);
37
 
38
  using ispanstream = basic_ispanstream<char>;
39
  using wispanstream = basic_ispanstream<wchar_t>;
40
 
41
+ // [ospanstream], class template basic_ospanstream
42
  template<class charT, class traits = char_traits<charT>>
43
  class basic_ospanstream;
44
 
45
  template<class charT, class traits>
46
  void swap(basic_ospanstream<charT, traits>& x, basic_ospanstream<charT, traits>& y);
47
 
48
  using ospanstream = basic_ospanstream<char>;
49
  using wospanstream = basic_ospanstream<wchar_t>;
50
 
51
+ // [spanstream], class template basic_spanstream
52
  template<class charT, class traits = char_traits<charT>>
53
  class basic_spanstream;
54
 
55
  template<class charT, class traits>
56
  void swap(basic_spanstream<charT, traits>& x, basic_spanstream<charT, traits>& y);
 
69
  template<class charT, class traits = char_traits<charT>>
70
  class basic_spanbuf
71
  : public basic_streambuf<charT, traits> {
72
  public:
73
  using char_type = charT;
74
+ using int_type = traits::int_type;
75
+ using pos_type = traits::pos_type;
76
+ using off_type = traits::off_type;
77
  using traits_type = traits;
78
 
79
  // [spanbuf.cons], constructors
80
  basic_spanbuf() : basic_spanbuf(ios_base::in | ios_base::out) {}
81
  explicit basic_spanbuf(ios_base::openmode which)
 
252
  - `(pptr() - pbase())` for the output sequence, or `(gptr() - eback())`
253
  for the input sequence when `way` is `ios_base::cur`;
254
  - when `way` is `ios_base::end` :
255
  - `(pptr() - pbase())` if `ios_base::out` is set in *mode* and
256
  `ios_base::in` is not set in *mode*,
257
+ - *`buf`*`.size()` otherwise.
258
 
259
  If `baseoff` + `off` would overflow, or if `baseoff` + `off` is less
260
  than zero, or if `baseoff` + `off` is greater than *`buf`*`.size()`, the
261
  positioning operation fails. Otherwise, the function computes
262
 
 
299
  template<class charT, class traits = char_traits<charT>>
300
  class basic_ispanstream
301
  : public basic_istream<charT, traits> {
302
  public:
303
  using char_type = charT;
304
+ using int_type = traits::int_type;
305
+ using pos_type = traits::pos_type;
306
+ using off_type = traits::off_type;
307
  using traits_type = traits;
308
 
309
  // [ispanstream.cons], constructors
310
  explicit basic_ispanstream(std::span<charT> s,
311
  ios_base::openmode which = ios_base::in);
 
341
  ``` cpp
342
  explicit basic_ispanstream(std::span<charT> s, ios_base::openmode which = ios_base::in);
343
  ```
344
 
345
  *Effects:* Initializes the base class with
346
+ `basic_istream<charT, traits>(addressof(`*`sb`*`))` and *sb* with
347
  `basic_spanbuf<charT, traits>(s, which | ios_base::in)`
348
  [[spanbuf.cons]].
349
 
350
  ``` cpp
351
  basic_ispanstream(basic_ispanstream&& rhs);
352
  ```
353
 
354
+ *Effects:* Initializes the base class with `std::move(rhs)` and *sb*
355
+ with `std::move(rhs.`*`sb`*`)`. Next,
356
+ `basic_istream<charT, traits>::set_rdbuf(addressof(`*`sb`*`))` is called
357
+ to install the contained `basic_spanbuf`.
358
 
359
  ``` cpp
360
  template<class ROS> explicit basic_ispanstream(ROS&& s)
361
  ```
362
 
363
  *Constraints:* `ROS` models `ranges::borrowed_range`.
364
  `!convertible_to<ROS, std::span<charT>> && convertible_to<ROS, std::span<charT const>>`
365
  is `true`.
366
 
367
  *Effects:* Let `sp` be `std::span<const charT>(std::forward<ROS>(s))`.
368
+ Equivalent to:
369
 
370
  ``` cpp
371
  basic_ispanstream(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()))
372
  ```
373
 
 
425
 
426
  *Effects:* Let `sp` be `std::span<const charT>(std::forward<ROS>(s))`.
427
  Equivalent to:
428
 
429
  ``` cpp
430
+ this->span(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()));
431
  ```
432
 
433
  ### Class template `basic_ospanstream` <a id="ospanstream">[[ospanstream]]</a>
434
 
435
  #### General <a id="ospanstream.general">[[ospanstream.general]]</a>
 
439
  template<class charT, class traits = char_traits<charT>>
440
  class basic_ospanstream
441
  : public basic_ostream<charT, traits> {
442
  public:
443
  using char_type = charT;
444
+ using int_type = traits::int_type;
445
+ using pos_type = traits::pos_type;
446
+ using off_type = traits::off_type;
447
  using traits_type = traits;
448
 
449
  // [ospanstream.cons], constructors
450
  explicit basic_ospanstream(std::span<charT> s,
451
  ios_base::openmode which = ios_base::out);
 
476
  explicit basic_ospanstream(std::span<charT> s,
477
  ios_base::openmode which = ios_base::out);
478
  ```
479
 
480
  *Effects:* Initializes the base class with
481
+ `basic_ostream<charT, traits>(addressof(`*`sb`*`))` and *sb* with
482
  `basic_spanbuf<charT, traits>(s, which | ios_base::out)`
483
  [[spanbuf.cons]].
484
 
485
  ``` cpp
486
  basic_ospanstream(basic_ospanstream&& rhs) noexcept;
487
  ```
488
 
489
+ *Effects:* Initializes the base class with `std::move(rhs)` and *sb*
490
+ with `std::move(rhs.`*`sb`*`)`. Next,
491
+ `basic_ostream<charT, traits>::set_rdbuf(addressof(`*`sb`*`))` is called
492
+ to install the contained `basic_spanbuf`.
493
 
494
  #### Swap <a id="ospanstream.swap">[[ospanstream.swap]]</a>
495
 
496
  ``` cpp
497
  void swap(basic_ospanstream& rhs);
 
544
  template<class charT, class traits = char_traits<charT>>
545
  class basic_spanstream
546
  : public basic_iostream<charT, traits> {
547
  public:
548
  using char_type = charT;
549
+ using int_type = traits::int_type;
550
+ using pos_type = traits::pos_type;
551
+ using off_type = traits::off_type;
552
  using traits_type = traits;
553
 
554
  // [spanstream.cons], constructors
555
  explicit basic_spanstream(std::span<charT> s,
556
  ios_base::openmode which = ios_base::out | ios_base::in);
 
581
  explicit basic_spanstream(std::span<charT> s,
582
  ios_base::openmode which = ios_base::out | ios_bas::in);
583
  ```
584
 
585
  *Effects:* Initializes the base class with
586
+ `basic_iostream<charT, traits>(addressof(`*`sb`*`))` and *sb* with
587
  `basic_spanbuf<charT, traits>(s, which)` [[spanbuf.cons]].
588
 
589
  ``` cpp
590
  basic_spanstream(basic_spanstream&& rhs);
591
  ```
592
 
593
+ *Effects:* Initializes the base class with `std::move(rhs)` and *sb*
594
+ with `std::move(rhs.`*`sb`*`)`. Next,
595
+ `basic_iostream<charT, traits>::set_rdbuf(addressof(`*`sb`*`))` is
596
+ called to install the contained `basic_spanbuf`.
597
 
598
  #### Swap <a id="spanstream.swap">[[spanstream.swap]]</a>
599
 
600
  ``` cpp
601
  void swap(basic_spanstream& rhs);