From Jason Turner

[ostream.formatted.print]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpmx_72za3/{from.md → to.md} +27 -16
tmp/tmpmx_72za3/{from.md → to.md} RENAMED
@@ -7,28 +7,38 @@ template<class... Args>
7
 
8
  *Effects:* If the ordinary literal encoding [[lex.charset]] is UTF-8,
9
  equivalent to:
10
 
11
  ``` cpp
12
- vprint_unicode(os, fmt.str, make_format_args(std::forward<Args>(args)...));
13
  ```
14
 
15
  Otherwise, equivalent to:
16
 
17
  ``` cpp
18
- vprint_nonunicode(os, fmt.str, make_format_args(std::forward<Args>(args)...));
19
  ```
20
 
21
  ``` cpp
22
  template<class... Args>
23
  void println(ostream& os, format_string<Args...> fmt, Args&&... args);
24
  ```
25
 
26
  *Effects:* Equivalent to:
27
 
28
  ``` cpp
29
- print(os, "{}\n", format(fmt, std::forward<Args>(args)...));
 
 
 
 
 
 
 
 
 
 
30
  ```
31
 
32
  ``` cpp
33
  void vprint_unicode(ostream& os, string_view fmt, format_args args);
34
  void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
@@ -40,28 +50,29 @@ function [[ostream.formatted.reqmts]] of `os`, except that:
40
  - failure to generate output is reported as specified below, and
41
  - any exception thrown by the call to `vformat` is propagated without
42
  regard to the value of `os.exceptions()` and without turning on
43
  `ios_base::badbit` in the error state of `os`.
44
 
45
- After constructing a `sentry` object, the function initializes an
46
- automatic variable via
47
 
48
  ``` cpp
49
  string out = vformat(os.getloc(), fmt, args);
50
  ```
51
 
52
- If the function is `vprint_unicode` and `os` is a stream that refers to
53
- a terminal capable of displaying Unicode which is determined in an
54
- implementation-defined manner, writes `out` to the terminal using the
55
- native Unicode API; if `out` contains invalid code units, the behavior
56
- is undefined and implementations are encouraged to diagnose it. If the
57
- native Unicode API is used, the function flushes `os` before writing
58
- `out`. Otherwise (if `os` is not such a stream or the function is
59
- `vprint_nonunicode`), inserts the character sequence \[`out.begin()`,
60
- `out.end()`) into `os`. If writing to the terminal or inserting into
61
- `os` fails, calls `os.setstate(ios_base::badbit)` (which may throw
62
- `ios_base::failure`).
 
63
 
64
  *Recommended practice:* For `vprint_unicode`, if invoking the native
65
  Unicode API requires transcoding, implementations should substitute
66
  invalid code units with U+fffd (replacement character) per the Unicode
67
  Standard, Chapter 3.9 ‘U+fffd‘ Substitution in Conversion.
 
7
 
8
  *Effects:* If the ordinary literal encoding [[lex.charset]] is UTF-8,
9
  equivalent to:
10
 
11
  ``` cpp
12
+ vprint_unicode(os, fmt.str, make_format_args(args...));
13
  ```
14
 
15
  Otherwise, equivalent to:
16
 
17
  ``` cpp
18
+ vprint_nonunicode(os, fmt.str, make_format_args(args...));
19
  ```
20
 
21
  ``` cpp
22
  template<class... Args>
23
  void println(ostream& os, format_string<Args...> fmt, Args&&... args);
24
  ```
25
 
26
  *Effects:* Equivalent to:
27
 
28
  ``` cpp
29
+ print(os, "{}\n", format(os.getloc(), fmt, std::forward<Args>(args)...));
30
+ ```
31
+
32
+ ``` cpp
33
+ void println(ostream& os);
34
+ ```
35
+
36
+ *Effects:* Equivalent to:
37
+
38
+ ``` cpp
39
+ print(os, "\n");
40
  ```
41
 
42
  ``` cpp
43
  void vprint_unicode(ostream& os, string_view fmt, format_args args);
44
  void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
 
50
  - failure to generate output is reported as specified below, and
51
  - any exception thrown by the call to `vformat` is propagated without
52
  regard to the value of `os.exceptions()` and without turning on
53
  `ios_base::badbit` in the error state of `os`.
54
 
55
+ After constructing a `sentry` object, the function initializes a
56
+ variable with automatic storage duration via
57
 
58
  ``` cpp
59
  string out = vformat(os.getloc(), fmt, args);
60
  ```
61
 
62
+ - If the function is `vprint_unicode` and `os` is a stream that refers
63
+ to a terminal that is capable of displaying Unicode only via a native
64
+ Unicode API, which is determined in an implementation-defined manner,
65
+ flushes `os` and then writes `out` to the terminal using the native
66
+ Unicode API; if `out` contains invalid code units, the behavior is
67
+ undefined. Then establishes an observable
68
+ checkpoint [[intro.abstract]].
69
+ - Otherwise inserts the character sequence \[`out.begin()`, `out.end()`)
70
+ into `os`.
71
+
72
+ If writing to the terminal or inserting into `os` fails, calls
73
+ `os.setstate(ios_base::badbit)` (which may throw `ios_base::failure`).
74
 
75
  *Recommended practice:* For `vprint_unicode`, if invoking the native
76
  Unicode API requires transcoding, implementations should substitute
77
  invalid code units with U+fffd (replacement character) per the Unicode
78
  Standard, Chapter 3.9 ‘U+fffd‘ Substitution in Conversion.