From Jason Turner

[output.streams]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpc_e_fnzy/{from.md → to.md} +63 -62
tmp/tmpc_e_fnzy/{from.md → to.md} RENAMED
@@ -19,13 +19,13 @@ namespace std {
19
  template<class charT, class traits = char_traits<charT>>
20
  class basic_ostream : virtual public basic_ios<charT, traits> {
21
  public:
22
  // types (inherited from basic_ios[ios])
23
  using char_type = charT;
24
- using int_type = typename traits::int_type;
25
- using pos_type = typename traits::pos_type;
26
- using off_type = typename traits::off_type;
27
  using traits_type = traits;
28
 
29
  // [ostream.cons], constructor/destructor
30
  explicit basic_ostream(basic_streambuf<char_type, traits>* sb);
31
  virtual ~basic_ostream();
@@ -197,11 +197,11 @@ virtual ~basic_ostream();
197
 
198
  ``` cpp
199
  basic_ostream& operator=(basic_ostream&& rhs);
200
  ```
201
 
202
- *Effects:* Equivalent to: `swap(rhs)`.
203
 
204
  *Returns:* `*this`.
205
 
206
  ``` cpp
207
  void swap(basic_ostream& rhs);
@@ -237,28 +237,29 @@ explicit sentry(basic_ostream& os);
237
 
238
  If `os.good()` is nonzero, prepares for formatted or unformatted output.
239
  If `os.tie()` is not a null pointer, calls `os.tie()->flush()`.[^29]
240
 
241
  If, after any preparation is completed, `os.good()` is `true`,
242
- `ok_ == true` otherwise, `ok_ == false`. During preparation, the
243
  constructor may call `setstate(failbit)` (which may throw
244
  `ios_base::failure` [[iostate.flags]]).[^30]
245
 
246
  ``` cpp
247
  ~sentry();
248
  ```
249
 
250
  If
251
  `(os.flags() & ios_base::unitbuf) && !uncaught_exceptions() && os.good()`
252
- is `true`, calls `os.rdbuf()->pubsync()`. If that function returns -1,
253
- sets `badbit` in `os.rdstate()` without propagating an exception.
 
254
 
255
  ``` cpp
256
  explicit operator bool() const;
257
  ```
258
 
259
- *Effects:* Returns `ok_`.
260
 
261
  ##### Seek members <a id="ostream.seeks">[[ostream.seeks]]</a>
262
 
263
  Each seek member function begins execution by constructing an object of
264
  class `sentry`. It returns by destroying the `sentry` object.
@@ -313,16 +314,16 @@ function is `*this`.
313
  The descriptions of the individual formatted output functions describe
314
  how they perform output and do not mention the `sentry` object.
315
 
316
  If a formatted output function of a stream `os` determines padding, it
317
  does so as follows. Given a `charT` character sequence `seq` where
318
- `charT` is the character type of the stream, if the length of `seq` is
319
- less than `os.width()`, then enough copies of `os.fill()` are added to
320
- this sequence as necessary to pad to a width of `os.width()` characters.
321
- If `(os.flags() & ios_base::adjustfield) == ios_base::left` is `true`,
322
- the fill characters are placed after the character sequence; otherwise,
323
- they are placed before the character sequence.
324
 
325
  ##### Arithmetic inserters <a id="ostream.inserters.arithmetic">[[ostream.inserters.arithmetic]]</a>
326
 
327
  ``` cpp
328
  basic_ostream& operator<<(bool val);
@@ -347,59 +348,52 @@ When `val` is of type `bool`, `long`, `unsigned long`, `long long`,
347
  `unsigned long long`, `double`, `long double`, or `const void*`, the
348
  formatting conversion occurs as if it performed the following code
349
  fragment:
350
 
351
  ``` cpp
352
- bool failed = use_facet<
353
- num_put<charT, ostreambuf_iterator<charT, traits>>
354
- >(getloc()).put(*this, *this, fill(), val).failed();
355
  ```
356
 
357
  When `val` is of type `short` the formatting conversion occurs as if it
358
  performed the following code fragment:
359
 
360
  ``` cpp
361
  ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;
362
- bool failed = use_facet<
363
- num_put<charT, ostreambuf_iterator<charT, traits>>
364
- >(getloc()).put(*this, *this, fill(),
365
  baseflags == ios_base::oct || baseflags == ios_base::hex
366
  ? static_cast<long>(static_cast<unsigned short>(val))
367
  : static_cast<long>(val)).failed();
368
  ```
369
 
370
  When `val` is of type `int` the formatting conversion occurs as if it
371
  performed the following code fragment:
372
 
373
  ``` cpp
374
  ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;
375
- bool failed = use_facet<
376
- num_put<charT, ostreambuf_iterator<charT, traits>>
377
- >(getloc()).put(*this, *this, fill(),
378
  baseflags == ios_base::oct || baseflags == ios_base::hex
379
  ? static_cast<long>(static_cast<unsigned int>(val))
380
  : static_cast<long>(val)).failed();
381
  ```
382
 
383
  When `val` is of type `unsigned short` or `unsigned int` the formatting
384
  conversion occurs as if it performed the following code fragment:
385
 
386
  ``` cpp
387
- bool failed = use_facet<
388
- num_put<charT, ostreambuf_iterator<charT, traits>>
389
- >(getloc()).put(*this, *this, fill(),
390
- static_cast<unsigned long>(val)).failed();
391
  ```
392
 
393
  When `val` is of type `float` the formatting conversion occurs as if it
394
  performed the following code fragment:
395
 
396
  ``` cpp
397
- bool failed = use_facet<
398
- num_put<charT, ostreambuf_iterator<charT, traits>>
399
- >(getloc()).put(*this, *this, fill(),
400
- static_cast<double>(val)).failed();
401
  ```
402
 
403
  The first argument provides an object of the `ostreambuf_iterator<>`
404
  class which is an iterator for class `basic_ostream<>`. It bypasses
405
  `ostream`s and uses `streambuf`s directly. Class `locale` relies on
@@ -427,26 +421,22 @@ basic_ostream& operator<<(extended-floating-point-type val);
427
  *`extended-floating-point-type`* is less than or equal to that of
428
  `double`, the formatting conversion occurs as if it performed the
429
  following code fragment:
430
 
431
  ``` cpp
432
- bool failed = use_facet<
433
- num_put<charT, ostreambuf_iterator<charT, traits>>
434
- >(getloc()).put(*this, *this, fill(),
435
- static_cast<double>(val)).failed();
436
  ```
437
 
438
  Otherwise, if the floating-point conversion rank of
439
  *`extended-floating-point-type`* is less than or equal to that of
440
  `long double`, the formatting conversion occurs as if it performed the
441
  following code fragment:
442
 
443
  ``` cpp
444
- bool failed = use_facet<
445
- num_put<charT, ostreambuf_iterator<charT, traits>>
446
- >(getloc()).put(*this, *this, fill(),
447
- static_cast<long double>(val)).failed();
448
  ```
449
 
450
  Otherwise, an invocation of the operator function is conditionally
451
  supported with *implementation-defined* semantics.
452
 
@@ -540,15 +530,15 @@ template<class traits>
540
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, unsigned char c);
541
  ```
542
 
543
  *Effects:* Behaves as a formatted output
544
  function [[ostream.formatted.reqmts]] of `out`. Constructs a character
545
- sequence `seq`. If `c` has type `char` and the character type of the
546
- stream is not `char`, then `seq` consists of `out.widen(c)`; otherwise
547
- `seq` consists of `c`. Determines padding for `seq` as described
548
- in  [[ostream.formatted.reqmts]]. Inserts `seq` into `out`. Calls
549
- `os.width(0)`.
550
 
551
  *Returns:* `out`.
552
 
553
  ``` cpp
554
  template<class charT, class traits>
@@ -598,28 +588,38 @@ template<class... Args>
598
 
599
  *Effects:* If the ordinary literal encoding [[lex.charset]] is UTF-8,
600
  equivalent to:
601
 
602
  ``` cpp
603
- vprint_unicode(os, fmt.str, make_format_args(std::forward<Args>(args)...));
604
  ```
605
 
606
  Otherwise, equivalent to:
607
 
608
  ``` cpp
609
- vprint_nonunicode(os, fmt.str, make_format_args(std::forward<Args>(args)...));
610
  ```
611
 
612
  ``` cpp
613
  template<class... Args>
614
  void println(ostream& os, format_string<Args...> fmt, Args&&... args);
615
  ```
616
 
617
  *Effects:* Equivalent to:
618
 
619
  ``` cpp
620
- print(os, "{}\n", format(fmt, std::forward<Args>(args)...));
 
 
 
 
 
 
 
 
 
 
621
  ```
622
 
623
  ``` cpp
624
  void vprint_unicode(ostream& os, string_view fmt, format_args args);
625
  void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
@@ -631,28 +631,29 @@ function [[ostream.formatted.reqmts]] of `os`, except that:
631
  - failure to generate output is reported as specified below, and
632
  - any exception thrown by the call to `vformat` is propagated without
633
  regard to the value of `os.exceptions()` and without turning on
634
  `ios_base::badbit` in the error state of `os`.
635
 
636
- After constructing a `sentry` object, the function initializes an
637
- automatic variable via
638
 
639
  ``` cpp
640
  string out = vformat(os.getloc(), fmt, args);
641
  ```
642
 
643
- If the function is `vprint_unicode` and `os` is a stream that refers to
644
- a terminal capable of displaying Unicode which is determined in an
645
- implementation-defined manner, writes `out` to the terminal using the
646
- native Unicode API; if `out` contains invalid code units, the behavior
647
- is undefined and implementations are encouraged to diagnose it. If the
648
- native Unicode API is used, the function flushes `os` before writing
649
- `out`. Otherwise (if `os` is not such a stream or the function is
650
- `vprint_nonunicode`), inserts the character sequence \[`out.begin()`,
651
- `out.end()`) into `os`. If writing to the terminal or inserting into
652
- `os` fails, calls `os.setstate(ios_base::badbit)` (which may throw
653
- `ios_base::failure`).
 
654
 
655
  *Recommended practice:* For `vprint_unicode`, if invoking the native
656
  Unicode API requires transcoding, implementations should substitute
657
  invalid code units with U+fffd (replacement character) per the Unicode
658
  Standard, Chapter 3.9 ‘U+fffd‘ Substitution in Conversion.
@@ -713,11 +714,11 @@ object. If that object returns `true` when converted to a value of type
713
  [[iostate.flags]]). Otherwise, if the `sentry` object returns `false`,
714
  does nothing.
715
 
716
  *Returns:* `*this`.
717
 
718
- #### Standard manipulators <a id="ostream.manip">[[ostream.manip]]</a>
719
 
720
  Each instantiation of any of the function templates specified in this
721
  subclause is a designated addressable function [[namespace.std]].
722
 
723
  ``` cpp
@@ -759,11 +760,11 @@ of exposition, calls `buf->set_emit_on_sync(true)`. Otherwise this
759
  manipulator has no effect.
760
 
761
  [*Note 1*: To work around the issue that the `Allocator` template
762
  argument cannot be deduced, implementations can introduce an
763
  intermediate base class to `basic_syncbuf` that manages its
764
- `emit_on_sync` flag. — *end note*]
765
 
766
  *Returns:* `os`.
767
 
768
  ``` cpp
769
  template<class charT, class traits>
 
19
  template<class charT, class traits = char_traits<charT>>
20
  class basic_ostream : virtual public basic_ios<charT, traits> {
21
  public:
22
  // types (inherited from basic_ios[ios])
23
  using char_type = charT;
24
+ using int_type = traits::int_type;
25
+ using pos_type = traits::pos_type;
26
+ using off_type = traits::off_type;
27
  using traits_type = traits;
28
 
29
  // [ostream.cons], constructor/destructor
30
  explicit basic_ostream(basic_streambuf<char_type, traits>* sb);
31
  virtual ~basic_ostream();
 
197
 
198
  ``` cpp
199
  basic_ostream& operator=(basic_ostream&& rhs);
200
  ```
201
 
202
+ *Effects:* Equivalent to `swap(rhs)`.
203
 
204
  *Returns:* `*this`.
205
 
206
  ``` cpp
207
  void swap(basic_ostream& rhs);
 
237
 
238
  If `os.good()` is nonzero, prepares for formatted or unformatted output.
239
  If `os.tie()` is not a null pointer, calls `os.tie()->flush()`.[^29]
240
 
241
  If, after any preparation is completed, `os.good()` is `true`,
242
+ *`ok_`*` == true` otherwise, *`ok_`*` == false`. During preparation, the
243
  constructor may call `setstate(failbit)` (which may throw
244
  `ios_base::failure` [[iostate.flags]]).[^30]
245
 
246
  ``` cpp
247
  ~sentry();
248
  ```
249
 
250
  If
251
  `(os.flags() & ios_base::unitbuf) && !uncaught_exceptions() && os.good()`
252
+ is `true`, calls `os.rdbuf()->pubsync()`. If that function returns -1 or
253
+ exits via an exception, sets `badbit` in `os.rdstate()` without
254
+ propagating an exception.
255
 
256
  ``` cpp
257
  explicit operator bool() const;
258
  ```
259
 
260
+ *Effects:* Returns *ok\_*.
261
 
262
  ##### Seek members <a id="ostream.seeks">[[ostream.seeks]]</a>
263
 
264
  Each seek member function begins execution by constructing an object of
265
  class `sentry`. It returns by destroying the `sentry` object.
 
314
  The descriptions of the individual formatted output functions describe
315
  how they perform output and do not mention the `sentry` object.
316
 
317
  If a formatted output function of a stream `os` determines padding, it
318
  does so as follows. Given a `charT` character sequence `seq` where
319
+ `charT` is the character container type of the stream, if the length of
320
+ `seq` is less than `os.width()`, then enough copies of `os.fill()` are
321
+ added to this sequence as necessary to pad to a width of `os.width()`
322
+ characters. If `(os.flags() & ios_base::adjustfield) == ios_base::left`
323
+ is `true`, the fill characters are placed after the character sequence;
324
+ otherwise, they are placed before the character sequence.
325
 
326
  ##### Arithmetic inserters <a id="ostream.inserters.arithmetic">[[ostream.inserters.arithmetic]]</a>
327
 
328
  ``` cpp
329
  basic_ostream& operator<<(bool val);
 
348
  `unsigned long long`, `double`, `long double`, or `const void*`, the
349
  formatting conversion occurs as if it performed the following code
350
  fragment:
351
 
352
  ``` cpp
353
+ bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
354
+ getloc()).put(*this, *this, fill(), val).failed();
 
355
  ```
356
 
357
  When `val` is of type `short` the formatting conversion occurs as if it
358
  performed the following code fragment:
359
 
360
  ``` cpp
361
  ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;
362
+ bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
363
+ getloc()).put(*this, *this, fill(),
 
364
  baseflags == ios_base::oct || baseflags == ios_base::hex
365
  ? static_cast<long>(static_cast<unsigned short>(val))
366
  : static_cast<long>(val)).failed();
367
  ```
368
 
369
  When `val` is of type `int` the formatting conversion occurs as if it
370
  performed the following code fragment:
371
 
372
  ``` cpp
373
  ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;
374
+ bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
375
+ getloc()).put(*this, *this, fill(),
 
376
  baseflags == ios_base::oct || baseflags == ios_base::hex
377
  ? static_cast<long>(static_cast<unsigned int>(val))
378
  : static_cast<long>(val)).failed();
379
  ```
380
 
381
  When `val` is of type `unsigned short` or `unsigned int` the formatting
382
  conversion occurs as if it performed the following code fragment:
383
 
384
  ``` cpp
385
+ bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
386
+ getloc()).put(*this, *this, fill(), static_cast<unsigned long>(val)).failed();
 
 
387
  ```
388
 
389
  When `val` is of type `float` the formatting conversion occurs as if it
390
  performed the following code fragment:
391
 
392
  ``` cpp
393
+ bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
394
+ getloc()).put(*this, *this, fill(), static_cast<double>(val)).failed();
 
 
395
  ```
396
 
397
  The first argument provides an object of the `ostreambuf_iterator<>`
398
  class which is an iterator for class `basic_ostream<>`. It bypasses
399
  `ostream`s and uses `streambuf`s directly. Class `locale` relies on
 
421
  *`extended-floating-point-type`* is less than or equal to that of
422
  `double`, the formatting conversion occurs as if it performed the
423
  following code fragment:
424
 
425
  ``` cpp
426
+ bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
427
+ getloc()).put(*this, *this, fill(), static_cast<double>(val)).failed();
 
 
428
  ```
429
 
430
  Otherwise, if the floating-point conversion rank of
431
  *`extended-floating-point-type`* is less than or equal to that of
432
  `long double`, the formatting conversion occurs as if it performed the
433
  following code fragment:
434
 
435
  ``` cpp
436
+ bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
437
+ getloc()).put(*this, *this, fill(), static_cast<long double>(val)).failed();
 
 
438
  ```
439
 
440
  Otherwise, an invocation of the operator function is conditionally
441
  supported with *implementation-defined* semantics.
442
 
 
530
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, unsigned char c);
531
  ```
532
 
533
  *Effects:* Behaves as a formatted output
534
  function [[ostream.formatted.reqmts]] of `out`. Constructs a character
535
+ sequence `seq`. If `c` has type `char` and the character container type
536
+ of the stream is not `char`, then `seq` consists of `out.widen(c)`;
537
+ otherwise `seq` consists of `c`. Determines padding for `seq` as
538
+ described in  [[ostream.formatted.reqmts]]. Inserts `seq` into `out`.
539
+ Calls `os.width(0)`.
540
 
541
  *Returns:* `out`.
542
 
543
  ``` cpp
544
  template<class charT, class traits>
 
588
 
589
  *Effects:* If the ordinary literal encoding [[lex.charset]] is UTF-8,
590
  equivalent to:
591
 
592
  ``` cpp
593
+ vprint_unicode(os, fmt.str, make_format_args(args...));
594
  ```
595
 
596
  Otherwise, equivalent to:
597
 
598
  ``` cpp
599
+ vprint_nonunicode(os, fmt.str, make_format_args(args...));
600
  ```
601
 
602
  ``` cpp
603
  template<class... Args>
604
  void println(ostream& os, format_string<Args...> fmt, Args&&... args);
605
  ```
606
 
607
  *Effects:* Equivalent to:
608
 
609
  ``` cpp
610
+ print(os, "{}\n", format(os.getloc(), fmt, std::forward<Args>(args)...));
611
+ ```
612
+
613
+ ``` cpp
614
+ void println(ostream& os);
615
+ ```
616
+
617
+ *Effects:* Equivalent to:
618
+
619
+ ``` cpp
620
+ print(os, "\n");
621
  ```
622
 
623
  ``` cpp
624
  void vprint_unicode(ostream& os, string_view fmt, format_args args);
625
  void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
 
631
  - failure to generate output is reported as specified below, and
632
  - any exception thrown by the call to `vformat` is propagated without
633
  regard to the value of `os.exceptions()` and without turning on
634
  `ios_base::badbit` in the error state of `os`.
635
 
636
+ After constructing a `sentry` object, the function initializes a
637
+ variable with automatic storage duration via
638
 
639
  ``` cpp
640
  string out = vformat(os.getloc(), fmt, args);
641
  ```
642
 
643
+ - If the function is `vprint_unicode` and `os` is a stream that refers
644
+ to a terminal that is capable of displaying Unicode only via a native
645
+ Unicode API, which is determined in an implementation-defined manner,
646
+ flushes `os` and then writes `out` to the terminal using the native
647
+ Unicode API; if `out` contains invalid code units, the behavior is
648
+ undefined. Then establishes an observable
649
+ checkpoint [[intro.abstract]].
650
+ - Otherwise inserts the character sequence \[`out.begin()`, `out.end()`)
651
+ into `os`.
652
+
653
+ If writing to the terminal or inserting into `os` fails, calls
654
+ `os.setstate(ios_base::badbit)` (which may throw `ios_base::failure`).
655
 
656
  *Recommended practice:* For `vprint_unicode`, if invoking the native
657
  Unicode API requires transcoding, implementations should substitute
658
  invalid code units with U+fffd (replacement character) per the Unicode
659
  Standard, Chapter 3.9 ‘U+fffd‘ Substitution in Conversion.
 
714
  [[iostate.flags]]). Otherwise, if the `sentry` object returns `false`,
715
  does nothing.
716
 
717
  *Returns:* `*this`.
718
 
719
+ #### Standard `basic_ostream` manipulators <a id="ostream.manip">[[ostream.manip]]</a>
720
 
721
  Each instantiation of any of the function templates specified in this
722
  subclause is a designated addressable function [[namespace.std]].
723
 
724
  ``` cpp
 
760
  manipulator has no effect.
761
 
762
  [*Note 1*: To work around the issue that the `Allocator` template
763
  argument cannot be deduced, implementations can introduce an
764
  intermediate base class to `basic_syncbuf` that manages its
765
+ *emit-on-sync* flag. — *end note*]
766
 
767
  *Returns:* `os`.
768
 
769
  ``` cpp
770
  template<class charT, class traits>