diff --git a/include/fmt/compile.h b/include/fmt/compile.h index a5e2dd39..82625bbc 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -261,16 +261,15 @@ class prepared_format { }; template struct part_counter { - public: - FMT_CONSTEXPR part_counter() : counter_(0u) {} + unsigned num_parts = 0; FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) { - if (begin != end) ++counter_; + if (begin != end) ++num_parts; } - FMT_CONSTEXPR void on_arg_id() { ++counter_; } - FMT_CONSTEXPR void on_arg_id(unsigned) { ++counter_; } - FMT_CONSTEXPR void on_arg_id(basic_string_view) { ++counter_; } + FMT_CONSTEXPR void on_arg_id() { ++num_parts; } + FMT_CONSTEXPR void on_arg_id(unsigned) { ++num_parts; } + FMT_CONSTEXPR void on_arg_id(basic_string_view) { ++num_parts; } FMT_CONSTEXPR void on_replacement_field(const Char*) {} @@ -290,11 +289,6 @@ template struct part_counter { } FMT_CONSTEXPR void on_error(const char*) {} - - FMT_CONSTEXPR unsigned result() const { return counter_; } - - private: - unsigned counter_; }; template class compiletime_prepared_parts_type_provider { @@ -305,7 +299,7 @@ template class compiletime_prepared_parts_type_provider { FMT_CONSTEXPR_DECL const auto text = to_string_view(Format{}); part_counter counter; internal::parse_format_string(text, counter); - return counter.result(); + return counter.num_parts; } // Workaround for old compilers. Compiletime parts preparation will not be