From Jason Turner

[format.tuple]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwblhyyyi/{from.md → to.md} +131 -0
tmp/tmpwblhyyyi/{from.md → to.md} RENAMED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Tuple formatter <a id="format.tuple">[[format.tuple]]</a>
2
+
3
+ For each of `pair` and `tuple`, the library provides the following
4
+ formatter specialization where `pair-or-tuple` is the name of the
5
+ template:
6
+
7
+ ``` cpp
8
+ namespace std {
9
+ template<class charT, formattable<charT>... Ts>
10
+ struct formatter<pair-or-tuple<Ts...>, charT> {
11
+ private:
12
+ tuple<formatter<remove_cvref_t<Ts>, charT>...> underlying_; // exposition only
13
+ basic_string_view<charT> separator_ = STATICALLY-WIDEN<charT>(", "); // exposition only
14
+ basic_string_view<charT> opening-bracket_ = STATICALLY-WIDEN<charT>("("); // exposition only
15
+ basic_string_view<charT> closing-bracket_ = STATICALLY-WIDEN<charT>(")"); // exposition only
16
+
17
+ public:
18
+ constexpr void set_separator(basic_string_view<charT> sep) noexcept;
19
+ constexpr void set_brackets(basic_string_view<charT> opening,
20
+ basic_string_view<charT> closing) noexcept;
21
+
22
+ template<class ParseContext>
23
+ constexpr typename ParseContext::iterator
24
+ parse(ParseContext& ctx);
25
+
26
+ template<class FormatContext>
27
+ typename FormatContext::iterator
28
+ format(see below& elems, FormatContext& ctx) const;
29
+ };
30
+ }
31
+ ```
32
+
33
+ The `parse` member functions of these formatters interpret the format
34
+ specification as a *tuple-format-spec* according to the following
35
+ syntax:
36
+
37
+ ``` bnf
38
+ tuple-format-spec
39
+ tuple-fill-and-alignₒₚₜ widthₒₚₜ tuple-typeₒₚₜ
40
+ ```
41
+
42
+ ``` bnf
43
+ tuple-fill-and-align
44
+ tuple-fillₒₚₜ align
45
+ ```
46
+
47
+ ``` bnf
48
+ tuple-fill
49
+ any character other than '{' or '}' or ':'
50
+ ```
51
+
52
+ ``` bnf
53
+ tuple-type
54
+ 'm'
55
+ 'n'
56
+ ```
57
+
58
+ The *tuple-fill-and-align* is interpreted the same way as a
59
+ *fill-and-align* [[format.string.std]]. The productions *align* and
60
+ *width* are described in [[format.string]].
61
+
62
+ The *tuple-type* specifier changes the way a `pair` or `tuple` is
63
+ formatted, with certain options only valid with certain argument types.
64
+ The meaning of the various type options is as specified in
65
+ [[formatter.tuple.type]].
66
+
67
+ **Table: Meaning of tuple-type options** <a id="formatter.tuple.type">[formatter.tuple.type]</a>
68
+
69
+ | Option | Requirements | Meaning |
70
+ | ------ | ------------ | -------------------------------------- |
71
+ | <charT>(": ")); set_brackets({}, {}); \end{codeblock}% |
72
+ | % `n` | none | Equivalent to: `set_brackets({}, {});` |
73
+ | % none | none | No effects |
74
+
75
+ ``` cpp
76
+ constexpr void set_separator(basic_string_view<charT> sep) noexcept;
77
+ ```
78
+
79
+ *Effects:* Equivalent to: *`separator_`*` = sep;`
80
+
81
+ ``` cpp
82
+ constexpr void set_brackets(basic_string_view<charT> opening,
83
+ basic_string_view<charT> closing) noexcept;
84
+ ```
85
+
86
+ *Effects:* Equivalent to:
87
+
88
+ ``` cpp
89
+ opening-bracket_ = opening;
90
+ closing-bracket_ = closing;
91
+ ```
92
+
93
+ ``` cpp
94
+ template<class ParseContext>
95
+ constexpr typename ParseContext::iterator
96
+ parse(ParseContext& ctx);
97
+ ```
98
+
99
+ *Effects:* Parses the format specifier as a *tuple-format-spec* and
100
+ stores the parsed specifiers in `*this`. The values of
101
+ *opening-bracket\_*, *closing-bracket\_*, and *separator\_* are modified
102
+ if and only if required by the *tuple-type*, if present. For each
103
+ element *`e`* in *underlying\_*, if *`e`*`.set_debug_format()` is a
104
+ valid expression, calls *`e`*`.set_debug_format()`.
105
+
106
+ *Returns:* An iterator past the end of the *tuple-format-spec*.
107
+
108
+ ``` cpp
109
+ template<class FormatContext>
110
+ typename FormatContext::iterator
111
+ format(see below& elems, FormatContext& ctx) const;
112
+ ```
113
+
114
+ The type of `elems` is:
115
+
116
+ - If `(formattable<const Ts, charT> && ...)` is `true`,
117
+ `const `*`pair-or-tuple`*`<Ts...>&`.
118
+ - Otherwise *`pair-or-tuple`*`<Ts...>&`.
119
+
120
+ *Effects:* Writes the following into `ctx.out()`, adjusted according to
121
+ the *tuple-format-spec*:
122
+
123
+ - *opening-bracket\_*,
124
+ - for each index `I` in the \[`0`, `sizeof...(Ts)`):
125
+ - if `I != 0`, *separator\_*,
126
+ - the result of writing `get<I>(elems)` via
127
+ `get<I>(`*`underlying_`*`)`, and
128
+ - *closing-bracket\_*.
129
+
130
+ *Returns:* An iterator past the end of the output range.
131
+