From Jason Turner

[ostream.formatted.print]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpuvzkogzk/{from.md → to.md} +68 -0
tmp/tmpuvzkogzk/{from.md → to.md} RENAMED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### Print <a id="ostream.formatted.print">[[ostream.formatted.print]]</a>
2
+
3
+ ``` cpp
4
+ template<class... Args>
5
+ void print(ostream& os, format_string<Args...> fmt, Args&&... args);
6
+ ```
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);
35
+ ```
36
+
37
+ *Effects:* Behaves as a formatted output
38
+ function [[ostream.formatted.reqmts]] of `os`, except that:
39
+
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.
68
+