@@ -104,7 +104,7 @@ namespace fly::detail {
104
104
* Strong enumeration types - If an overload of operator<< is defined, valid presentations
105
105
* are: none, "s". Else, valid presentations are: none, "c", b", "B", "o", "d", "x", "X".
106
106
*
107
- * Other (general ) types - Valid presentations: none, "s" . An overload of operator<< must be
107
+ * Other (generic ) types - Valid presentations: none. An overload of operator<< must be
108
108
* defined for generic types.
109
109
*
110
110
* For details on each presentation type, see the above links.
@@ -390,37 +390,14 @@ class BasicFormatString
390
390
* Helper trait to determine if a type is either streamable or string-like.
391
391
*/
392
392
template <typename T>
393
- using is_formatable_type = std::disjunction<
393
+ using is_formattable_type = std::disjunction<
394
394
typename traits::OstreamTraits::template is_declared<T>,
395
395
detail::is_like_supported_string<T>,
396
396
detail::is_supported_character<T>,
397
397
std::is_enum<std::remove_cvref_t <T>>>;
398
398
399
399
template <typename T>
400
- static inline constexpr bool is_formatable_type_v = is_formatable_type<T>::value;
401
-
402
- /* *
403
- * Helper trait to classify an enumeration type as default-formatted (i.e. the user has not
404
- * defined a custom operator<< for this type).
405
- */
406
- template <typename T>
407
- using is_default_formatted_enum = std::conjunction<
408
- std::is_enum<T>,
409
- std::negation<typename traits::OstreamTraits::template is_declared<T>>>;
410
-
411
- template <typename T>
412
- static inline constexpr bool is_default_formatted_enum_v = is_default_formatted_enum<T>::value;
413
-
414
- /* *
415
- * Helper trait to classify an enumeration type as user-formatted (i.e. the user has defined a
416
- * custom operator<< for this type).
417
- */
418
- template <typename T>
419
- using is_user_formatted_enum =
420
- std::conjunction<std::is_enum<T>, typename traits::OstreamTraits::template is_declared<T>>;
421
-
422
- template <typename T>
423
- static inline constexpr bool is_user_formatted_enum_v = is_user_formatted_enum<T>::value;
400
+ static inline constexpr bool is_formattable_type_v = is_formattable_type<T>::value;
424
401
425
402
/* *
426
403
* Helper trait to classify a type as an integer, excluding character and boolean types.
@@ -434,6 +411,18 @@ class BasicFormatString
434
411
template <typename T>
435
412
static inline constexpr bool is_integer_v = is_integer<T>::value;
436
413
414
+ /* *
415
+ * Helper trait to classify an enumeration type as default-formatted (i.e. the user has not
416
+ * defined a custom operator<< for this type).
417
+ */
418
+ template <typename T>
419
+ using is_default_formatted_enum = std::conjunction<
420
+ std::is_enum<T>,
421
+ std::negation<typename traits::OstreamTraits::template is_declared<T>>>;
422
+
423
+ template <typename T>
424
+ static inline constexpr bool is_default_formatted_enum_v = is_default_formatted_enum<T>::value;
425
+
437
426
/* *
438
427
* Upon parsing an un-escaped opening brace, parse a single replacement field in the format
439
428
* string. If valid, the lexer will be advanced to the character after the closing brace.
@@ -563,12 +552,12 @@ class BasicFormatString
563
552
constexpr void validate_type (ParameterType type, const FormatSpecifier &specifier);
564
553
565
554
/* *
566
- * Determine the type of a format parameter. Returns ParameterType::Generic if the given index
567
- * was not found, or if the type of the format parameter is unknown.
555
+ * Determine the type of a format parameter. Returns ParameterType::Generic if the type of the
556
+ * format parameter is unknown.
568
557
*
569
558
* @param index The index of the format parameter to inspect.
570
559
*
571
- * @return The type of the format parameter.
560
+ * @return If found, the type of the format parameter. Otherwise, an uninitialized value .
572
561
*/
573
562
template <size_t N = 0 >
574
563
constexpr std::optional<ParameterType> parameter_type (size_t index);
@@ -791,7 +780,7 @@ FLY_CONSTEVAL BasicFormatString<StringType, ParameterTypes...>::BasicFormatStrin
791
780
{
792
781
std::optional<char_type> ch;
793
782
794
- if constexpr (!(is_formatable_type_v <ParameterTypes> && ...))
783
+ if constexpr (!(is_formattable_type_v <ParameterTypes> && ...))
795
784
{
796
785
on_error (" An overloaded operator<< must be defined for all format parameters" );
797
786
}
@@ -1204,10 +1193,9 @@ constexpr void BasicFormatString<StringType, ParameterTypes...>::validate_type(
1204
1193
switch (type)
1205
1194
{
1206
1195
case ParameterType::Generic:
1207
- if ((specifier.m_type != FormatSpecifier::Type::None) &&
1208
- (specifier.m_type != FormatSpecifier::Type::String))
1196
+ if (specifier.m_type != FormatSpecifier::Type::None)
1209
1197
{
1210
- on_error (" Generic types must be formatted with {} or {:s} " );
1198
+ on_error (" Generic types must be formatted with {}" );
1211
1199
}
1212
1200
break ;
1213
1201
@@ -1227,7 +1215,7 @@ constexpr void BasicFormatString<StringType, ParameterTypes...>::validate_type(
1227
1215
if ((specifier.m_type != FormatSpecifier::Type::None) &&
1228
1216
(specifier.m_type != FormatSpecifier::Type::String))
1229
1217
{
1230
- on_error (" String types and user-formatted enums must be formatted with {} or {:s}" );
1218
+ on_error (" String types must be formatted with {} or {:s}" );
1231
1219
}
1232
1220
break ;
1233
1221
@@ -1247,9 +1235,7 @@ constexpr void BasicFormatString<StringType, ParameterTypes...>::validate_type(
1247
1235
(specifier.m_type != FormatSpecifier::Type::Decimal) &&
1248
1236
(specifier.m_type != FormatSpecifier::Type::Hex))
1249
1237
{
1250
- on_error (
1251
- " Integral types and default-formatted enums must be formatted with {} or one "
1252
- " of {:cbBodxX}" );
1238
+ on_error (" Integral types must be formatted with {} or one of {:cbBodxX}" );
1253
1239
}
1254
1240
break ;
1255
1241
@@ -1298,7 +1284,7 @@ constexpr auto BasicFormatString<StringType, ParameterTypes...>::parameter_type(
1298
1284
{
1299
1285
return ParameterType::Character;
1300
1286
}
1301
- else if constexpr (is_like_supported_string_v<T> || is_user_formatted_enum_v<T> )
1287
+ else if constexpr (is_like_supported_string_v<T>)
1302
1288
{
1303
1289
return ParameterType::String;
1304
1290
}
0 commit comments