@@ -122,6 +122,14 @@ struct BasicFormatSpecifier
122
122
123
123
BasicFormatSpecifier () = default ;
124
124
125
+ /* *
126
+ * Constructor. Initializes the replacement field's format parameter position and infers its
127
+ * presentation type.
128
+ *
129
+ * @param context The context holding the format string parsing state.
130
+ */
131
+ explicit constexpr BasicFormatSpecifier (FormatParseContext &context);
132
+
125
133
BasicFormatSpecifier (BasicFormatSpecifier &&) = default ;
126
134
BasicFormatSpecifier &operator =(BasicFormatSpecifier &&) = default ;
127
135
@@ -174,17 +182,6 @@ struct BasicFormatSpecifier
174
182
*/
175
183
constexpr void parse (FormatParseContext &context);
176
184
177
- /* *
178
- * Infer a presentation type for a replacement field based on the corresponding format
179
- * parameter's type.
180
- *
181
- * TODO: This should be private. Once the standard fly::Formatters are updated to inherit from
182
- * this structure, they may infer their presentation type.
183
- *
184
- * @param context The context holding the format string parsing state.
185
- */
186
- constexpr void infer_type (FormatParseContext &context);
187
-
188
185
/* *
189
186
* The width formatting option may either be a number or a nested replacement field. If a
190
187
* numeric value was specified, return that value. If a nested replacement field was specified,
@@ -337,6 +334,14 @@ struct BasicFormatSpecifier
337
334
*/
338
335
constexpr void parse_type (FormatParseContext &context);
339
336
337
+ /* *
338
+ * Infer a presentation type for a replacement field based on the corresponding format
339
+ * parameter's type.
340
+ *
341
+ * @param context The context holding the format string parsing state.
342
+ */
343
+ constexpr void infer_type (FormatParseContext &context);
344
+
340
345
/* *
341
346
* After parsing a single replacement field, validate all options that were parsed. Raise an
342
347
* error if the field is invalid.
@@ -416,6 +421,14 @@ struct BasicFormatSpecifier
416
421
static constexpr const auto s_decimal = FLY_CHR(CharType, ' .' );
417
422
};
418
423
424
+ // ==================================================================================================
425
+ template <typename CharType>
426
+ constexpr BasicFormatSpecifier<CharType>::BasicFormatSpecifier(FormatParseContext &context) :
427
+ m_position (context.next_position())
428
+ {
429
+ infer_type (context);
430
+ }
431
+
419
432
// ==================================================================================================
420
433
template <typename CharType>
421
434
constexpr void BasicFormatSpecifier<CharType>::parse(FormatParseContext &context)
@@ -587,11 +600,6 @@ constexpr void BasicFormatSpecifier<CharType>::parse_type(FormatParseContext &co
587
600
}
588
601
}
589
602
}
590
-
591
- if (m_type == Type::None)
592
- {
593
- infer_type (context);
594
- }
595
603
}
596
604
597
605
// ==================================================================================================
0 commit comments