From 9adf78d6a79160d9c24909c975b33ffe42808314 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Sat, 18 Feb 2023 18:30:56 +0100 Subject: [PATCH] [NFC][libc++][format] Small improvements. While working on the formatter for the thread::id several minor issues where spotted. This fixes them. --- libcxx/include/__format/formatter_pointer.h | 4 +--- libcxx/include/__format/parser_std_format_spec.h | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libcxx/include/__format/formatter_pointer.h b/libcxx/include/__format/formatter_pointer.h index 1fb5ce3d533a..fe1b3cb496f1 100644 --- a/libcxx/include/__format/formatter_pointer.h +++ b/libcxx/include/__format/formatter_pointer.h @@ -32,8 +32,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS __formatter_pointer { public: - constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; } - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_pointer); @@ -48,7 +46,7 @@ public: return __formatter::__format_integer(reinterpret_cast(__ptr), __ctx, __specs); } - __format_spec::__parser<_CharT> __parser_; + __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__right}; }; // [format.formatter.spec]/2.4 diff --git a/libcxx/include/__format/parser_std_format_spec.h b/libcxx/include/__format/parser_std_format_spec.h index 4fff9ad859d1..15041602df5c 100644 --- a/libcxx/include/__format/parser_std_format_spec.h +++ b/libcxx/include/__format/parser_std_format_spec.h @@ -118,7 +118,7 @@ struct __fields { // formatters use the colon to mark the beginning of the // underlying-format-spec. To avoid parsing ambiguities these formatter // specializations prohibit the use of the colon as a fill character. - uint8_t __allow_colon_in_fill_ : 1 {false}; + uint8_t __use_range_fill_ : 1 {false}; }; // By not placing this constant in the formatter class it's not duplicated for @@ -140,8 +140,8 @@ inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true} inline constexpr __fields __fields_pointer{.__type_ = true}; # if _LIBCPP_STD_VER >= 23 -inline constexpr __fields __fields_tuple{.__type_ = false, .__allow_colon_in_fill_ = true}; -inline constexpr __fields __fields_range{.__type_ = false, .__allow_colon_in_fill_ = true}; +inline constexpr __fields __fields_tuple{.__use_range_fill_ = true}; +inline constexpr __fields __fields_range{.__use_range_fill_ = true}; # endif enum class _LIBCPP_ENUM_VIS __alignment : uint8_t { @@ -276,7 +276,7 @@ public: if (__begin == __end) return __begin; - if (__parse_fill_align(__begin, __end, __fields.__allow_colon_in_fill_) && __begin == __end) + if (__parse_fill_align(__begin, __end, __fields.__use_range_fill_) && __begin == __end) return __begin; if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end) -- 2.34.1