From Jason Turner

[time.parse]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp1_k8wcnv/{from.md → to.md} +94 -21
tmp/tmp1_k8wcnv/{from.md → to.md} RENAMED
@@ -5,94 +5,130 @@ unqualified, so as to enable argument dependent lookup
5
  [[basic.lookup.argdep]]. In the following paragraphs, let `is` denote an
6
  object of type `basic_istream<charT, traits>` and let `I` be
7
  `basic_istream<charT, traits>&`, where `charT` and `traits` are template
8
  parameters in that context.
9
 
 
 
 
 
 
 
10
  ``` cpp
 
 
 
11
  template<class charT, class traits, class Alloc, class Parsable>
12
  unspecified
13
  parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp);
14
  ```
15
 
 
 
 
16
  *Constraints:* The expression
17
 
18
  ``` cpp
19
- from_stream(declval<basic_istream<charT, traits>&>(), fmt.c_str(), tp)
20
  ```
21
 
22
- is well-formed when treated as an unevaluated operand.
 
23
 
24
  *Returns:* A manipulator such that the expression `is >> parse(fmt, tp)`
25
- has type `I`, has value `is`, and calls
26
- `from_stream(is, fmt.c_str(), tp)`.
27
 
28
  ``` cpp
 
 
 
 
29
  template<class charT, class traits, class Alloc, class Parsable>
30
  unspecified
31
  parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
32
  basic_string<charT, traits, Alloc>& abbrev);
33
  ```
34
 
 
 
 
35
  *Constraints:* The expression
36
 
37
  ``` cpp
38
- from_stream(declval<basic_istream<charT, traits>&>(), fmt.c_str(), tp, addressof(abbrev))
39
  ```
40
 
41
- is well-formed when treated as an unevaluated operand.
 
42
 
43
  *Returns:* A manipulator such that the expression
44
  `is >> parse(fmt, tp, abbrev)` has type `I`, has value `is`, and calls
45
- `from_stream(is, fmt.c_str(), tp, addressof(abbrev))`.
46
 
47
  ``` cpp
 
 
 
48
  template<class charT, class traits, class Alloc, class Parsable>
49
  unspecified
50
  parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
51
  minutes& offset);
52
  ```
53
 
 
 
 
 
54
  *Constraints:* The expression
55
 
56
  ``` cpp
57
  from_stream(declval<basic_istream<charT, traits>&>(),
58
- fmt.c_str(), tp,
59
  declval<basic_string<charT, traits, Alloc>*>(),
60
  &offset)
61
  ```
62
 
63
- is well-formed when treated as an unevaluated operand.
 
64
 
65
  *Returns:* A manipulator such that the expression
66
  `is >> parse(fmt, tp, offset)` has type `I`, has value `is`, and calls:
67
 
68
  ``` cpp
69
  from_stream(is,
70
- fmt.c_str(), tp,
71
  static_cast<basic_string<charT, traits, Alloc>*>(nullptr),
72
  &offset)
73
  ```
74
 
75
  ``` cpp
 
 
 
 
76
  template<class charT, class traits, class Alloc, class Parsable>
77
  unspecified
78
  parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
79
  basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
80
  ```
81
 
 
 
 
82
  *Constraints:* The expression
83
 
84
  ``` cpp
85
  from_stream(declval<basic_istream<charT, traits>&>(),
86
- fmt.c_str(), tp, addressof(abbrev), &offset)
87
  ```
88
 
89
- is well-formed when treated as an unevaluated operand.
 
90
 
91
  *Returns:* A manipulator such that the expression
92
  `is >> parse(fmt, tp, abbrev, offset)` has type `I`, has value `is`, and
93
- calls `from_stream(is, fmt.c_str(), tp, addressof(abbrev), &offset)`.
94
 
95
  All `from_stream` overloads behave as unformatted input functions,
96
  except that they have an unspecified effect on the value returned by
97
  subsequent calls to `basic_istream<>::gcount()`. Each overload takes a
98
  format string containing ordinary characters and flags which have
@@ -101,29 +137,66 @@ by `E` or `O`. During parsing each flag interprets characters as parts
101
  of date and time types according to  [[time.parse.spec]]. Some flags can
102
  be modified by a width parameter given as a positive decimal integer
103
  called out as `N` below which governs how many characters are parsed
104
  from the stream in interpreting the flag. All characters in the format
105
  string that are not represented in  [[time.parse.spec]], except for
106
- white space, are parsed unchanged from the stream. A white space
107
- character matches zero or more white space characters in the input
108
- stream.
109
 
110
  If the type being parsed cannot represent the information that the
111
  format flag refers to, `is.setstate(ios_base::failbit)` is called.
112
 
113
  [*Example 1*: A `duration` cannot represent a
114
  `weekday`. — *end example*]
115
 
116
- However, if a flag refers to a “time of day” (e.g. `%H`, `%I`, `%p`,
117
  etc.), then a specialization of `duration` is parsed as the time of day
118
  elapsed since midnight.
119
 
120
  If the `from_stream` overload fails to parse everything specified by the
121
  format string, or if insufficient information is parsed to specify a
122
  complete duration, time point, or calendrical data structure,
123
  `setstate(ios_base::failbit)` is called on the `basic_istream`.
124
 
125
- [*Note 1*: `%n`, `%t`, and a space can be combined to match a wide
126
- range of white-space patterns. For example, `"%n "` matches one or more
127
- white space characters, and `"%n%t%t"` matches one to three white space
128
- characters. *end note*]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
 
5
  [[basic.lookup.argdep]]. In the following paragraphs, let `is` denote an
6
  object of type `basic_istream<charT, traits>` and let `I` be
7
  `basic_istream<charT, traits>&`, where `charT` and `traits` are template
8
  parameters in that context.
9
 
10
+ *Recommended practice:* Implementations should make it difficult to
11
+ accidentally store or use a manipulator that may contain a dangling
12
+ reference to a format string, for example by making the manipulators
13
+ produced by `parse` immovable and preventing stream extraction into an
14
+ lvalue of such a manipulator type.
15
+
16
  ``` cpp
17
+ template<class charT, class Parsable>
18
+ unspecified
19
+ parse(const charT* fmt, Parsable& tp);
20
  template<class charT, class traits, class Alloc, class Parsable>
21
  unspecified
22
  parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp);
23
  ```
24
 
25
+ Let F be `fmt` for the first overload and `fmt.c_str()` for the second
26
+ overload. Let `traits` be `char_traits<charT>` for the first overload.
27
+
28
  *Constraints:* The expression
29
 
30
  ``` cpp
31
+ from_stream(declval<basic_istream<charT, traits>&>(), F, tp)
32
  ```
33
 
34
+ is well-formed when treated as an unevaluated
35
+ operand [[term.unevaluated.operand]].
36
 
37
  *Returns:* A manipulator such that the expression `is >> parse(fmt, tp)`
38
+ has type `I`, has value `is`, and calls `from_stream(is, `F`, tp)`.
 
39
 
40
  ``` cpp
41
+ template<class charT, class traits, class Alloc, class Parsable>
42
+ unspecified
43
+ parse(const charT* fmt, Parsable& tp,
44
+ basic_string<charT, traits, Alloc>& abbrev);
45
  template<class charT, class traits, class Alloc, class Parsable>
46
  unspecified
47
  parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
48
  basic_string<charT, traits, Alloc>& abbrev);
49
  ```
50
 
51
+ Let F be `fmt` for the first overload and `fmt.c_str()` for the second
52
+ overload.
53
+
54
  *Constraints:* The expression
55
 
56
  ``` cpp
57
+ from_stream(declval<basic_istream<charT, traits>&>(), F, tp, addressof(abbrev))
58
  ```
59
 
60
+ is well-formed when treated as an unevaluated
61
+ operand [[term.unevaluated.operand]].
62
 
63
  *Returns:* A manipulator such that the expression
64
  `is >> parse(fmt, tp, abbrev)` has type `I`, has value `is`, and calls
65
+ `from_stream(is, `F`, tp, addressof(abbrev))`.
66
 
67
  ``` cpp
68
+ template<class charT, class Parsable>
69
+ unspecified
70
+ parse(const charT* fmt, Parsable& tp, minutes& offset);
71
  template<class charT, class traits, class Alloc, class Parsable>
72
  unspecified
73
  parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
74
  minutes& offset);
75
  ```
76
 
77
+ Let F be `fmt` for the first overload and `fmt.c_str()` for the second
78
+ overload. Let `traits` be `char_traits<charT>` and `Alloc` be
79
+ `allocator<charT>` for the first overload.
80
+
81
  *Constraints:* The expression
82
 
83
  ``` cpp
84
  from_stream(declval<basic_istream<charT, traits>&>(),
85
+ F, tp,
86
  declval<basic_string<charT, traits, Alloc>*>(),
87
  &offset)
88
  ```
89
 
90
+ is well-formed when treated as an unevaluated
91
+ operand [[term.unevaluated.operand]].
92
 
93
  *Returns:* A manipulator such that the expression
94
  `is >> parse(fmt, tp, offset)` has type `I`, has value `is`, and calls:
95
 
96
  ``` cpp
97
  from_stream(is,
98
+ F, tp,
99
  static_cast<basic_string<charT, traits, Alloc>*>(nullptr),
100
  &offset)
101
  ```
102
 
103
  ``` cpp
104
+ template<class charT, class traits, class Alloc, class Parsable>
105
+ unspecified
106
+ parse(const charT* fmt, Parsable& tp,
107
+ basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
108
  template<class charT, class traits, class Alloc, class Parsable>
109
  unspecified
110
  parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
111
  basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
112
  ```
113
 
114
+ Let F be `fmt` for the first overload and `fmt.c_str()` for the second
115
+ overload.
116
+
117
  *Constraints:* The expression
118
 
119
  ``` cpp
120
  from_stream(declval<basic_istream<charT, traits>&>(),
121
+ F, tp, addressof(abbrev), &offset)
122
  ```
123
 
124
+ is well-formed when treated as an unevaluated
125
+ operand [[term.unevaluated.operand]].
126
 
127
  *Returns:* A manipulator such that the expression
128
  `is >> parse(fmt, tp, abbrev, offset)` has type `I`, has value `is`, and
129
+ calls `from_stream(is, `F`, tp, addressof(abbrev), &offset)`.
130
 
131
  All `from_stream` overloads behave as unformatted input functions,
132
  except that they have an unspecified effect on the value returned by
133
  subsequent calls to `basic_istream<>::gcount()`. Each overload takes a
134
  format string containing ordinary characters and flags which have
 
137
  of date and time types according to  [[time.parse.spec]]. Some flags can
138
  be modified by a width parameter given as a positive decimal integer
139
  called out as `N` below which governs how many characters are parsed
140
  from the stream in interpreting the flag. All characters in the format
141
  string that are not represented in  [[time.parse.spec]], except for
142
+ whitespace, are parsed unchanged from the stream. A whitespace character
143
+ matches zero or more whitespace characters in the input stream.
 
144
 
145
  If the type being parsed cannot represent the information that the
146
  format flag refers to, `is.setstate(ios_base::failbit)` is called.
147
 
148
  [*Example 1*: A `duration` cannot represent a
149
  `weekday`. — *end example*]
150
 
151
+ However, if a flag refers to a “time of day” (e.g., `%H`, `%I`, `%p`,
152
  etc.), then a specialization of `duration` is parsed as the time of day
153
  elapsed since midnight.
154
 
155
  If the `from_stream` overload fails to parse everything specified by the
156
  format string, or if insufficient information is parsed to specify a
157
  complete duration, time point, or calendrical data structure,
158
  `setstate(ios_base::failbit)` is called on the `basic_istream`.
159
 
160
+ **Table: Meaning of `parse` flags** <a id="time.parse.spec">[time.parse.spec]</a>
161
+
162
+ | Flag | Parsed value |
163
+ | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
164
+ | `%a` | The locale's full or abbreviated case-insensitive weekday name. |
165
+ | `%A` | Equivalent to `%a`. |
166
+ | `%b` | The locale's full or abbreviated case-insensitive month name. |
167
+ | `%B` | Equivalent to `%b`. |
168
+ | `%c` | The locale's date and time representation. The modified command `%Ec` interprets the locale's alternate date and time representation. |
169
+ | `%C` | The century as a decimal number. The modified command `%*N*C` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%EC` interprets the locale's alternative representation of the century. |
170
+ | `%d` | The day of the month as a decimal number. The modified command `%*N*d` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%Od` interprets the locale's alternative representation of the day of the month. |
171
+ | `%D` | Equivalent to `%m/%d/%y`. |
172
+ | `%e` | Equivalent to `%d` and can be modified like `%d`. |
173
+ | `%F` | Equivalent to `%Y-%m-%d`. If modified with a width `*N*`, the width is applied to only `%Y`. |
174
+ | `%g` | The last two decimal digits of the ISO week-based year. The modified command `%*N*g` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. |
175
+ | `%G` | The ISO week-based year as a decimal number. The modified command `%*N*G` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 4. Leading zeroes are permitted but not required. |
176
+ | `%h` | Equivalent to `%b`. |
177
+ | `%H` | The hour (24-hour clock) as a decimal number. The modified command `%*N*H` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OH` interprets the locale's alternative representation. |
178
+ | `%I` | The hour (12-hour clock) as a decimal number. The modified command `%*N*I` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OI` interprets the locale's alternative representation. |
179
+ | `%j` | If the type being parsed is a specialization of `duration`, a decimal number of `days`. Otherwise, the day of the year as a decimal number. Jan 1 is `1`. In either case, the modified command `%*N*j` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 3. Leading zeroes are permitted but not required. |
180
+ | `%m` | The month as a decimal number. Jan is `1`. The modified command `%*N*m` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%Om` interprets the locale's alternative representation. |
181
+ | `%M` | The minutes as a decimal number. The modified command `%*N*M` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OM` interprets the locale's alternative representation. |
182
+ | `%n` | Matches one whitespace character. *`%n`, `%t`, and a space can be combined to match a wide range of whitespace patterns. For example, `"%n "` matches one or more whitespace characters, and `"%n%t%t"` matches one to three whitespace characters.* |
183
+ | `%p` | The locale's equivalent of the AM/PM designations associated with a 12-hour clock. |
184
+ | `%r` | The locale's 12-hour clock time. |
185
+ | `%R` | Equivalent to `%H:%M`. |
186
+ | `%S` | The seconds as a decimal number. The modified command `%*N*S` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2 if the input time has a precision convertible to seconds. Otherwise the default width is determined by the decimal precision of the input and the field is interpreted as a `long double` in a fixed format. If encountered, the locale determines the decimal point character. Leading zeroes are permitted but not required. The modified command `%OS` interprets the locale's alternative representation. |
187
+ | `%t` | Matches zero or one whitespace characters. |
188
+ | `%T` | Equivalent to `%H:%M:%S`. |
189
+ | `%u` | The ISO weekday as a decimal number (`1`-`7`), where Monday is `1`. The modified command `%*N*u` specifies the maximum number of characters to read. If `*N*` is not specified, the default is `1`. Leading zeroes are permitted but not required. |
190
+ | `%U` | The week number of the year as a decimal number. The first Sunday of the year is the first day of week `01`. Days of the same year prior to that are in week `00`. The modified command `%*N*U` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OU` interprets the locale's alternative representation. |
191
+ | `%V` | The ISO week-based week number as a decimal number. The modified command `%*N*V` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. |
192
+ | `%w` | The weekday as a decimal number (`0`-`6`), where Sunday is `0`. The modified command `%*N*w` specifies the maximum number of characters to read. If `*N*` is not specified, the default is `1`. Leading zeroes are permitted but not required. The modified command `%Ow` interprets the locale's alternative representation. |
193
+ | `%W` | The week number of the year as a decimal number. The first Monday of the year is the first day of week `01`. Days of the same year prior to that are in week `00`. The modified command `%*N*W` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OW` interprets the locale's alternative representation. |
194
+ | `%x` | The locale's date representation. The modified command `%Ex` interprets the locale's alternate date representation. |
195
+ | `%X` | The locale's time representation. The modified command `%EX` interprets the locale's alternate time representation. |
196
+ | `%y` | The last two decimal digits of the year. If the century is not otherwise specified (e.g., with `%C`), values in the range {[}`69`, `99`{]} are presumed to refer to the years 1969 to 1999, and values in the range {[}`00`, `68`{]} are presumed to refer to the years 2000 to 2068. The modified command `%*N*y` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified commands `%Ey` and `%Oy` interpret the locale's alternative representation. |
197
+ | `%Y` | The year as a decimal number. The modified command `%*N*Y` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 4. Leading zeroes are permitted but not required. The modified command `%EY` interprets the locale's alternative representation. |
198
+ | `%z` | The offset from UTC in the format `[+|-]hh[mm]`. For example `-0430` refers to 4 hours 30 minutes behind UTC, and `04` refers to 4 hours ahead of UTC. The modified commands `%Ez` and `%Oz` parse a `:` between the hours and minutes and render leading zeroes on the hour field optional: `[+|-]h[h][:mm]`. For example `-04:30` refers to 4 hours 30 minutes behind UTC, and `4` refers to 4 hours ahead of UTC. |
199
+ | `%Z` | The time zone abbreviation or name. A single word is parsed. This word can only contain characters from the basic character set [[lex.charset]] that are alphanumeric, or one of `'_'`, `'/'`, `'-'`, or `'+'`. |
200
+ | `%%` | A `%` character is extracted. |
201
+
202