diff --git a/include/fmt/base.h b/include/fmt/base.h index 282f7f07..88799cfd 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -2841,24 +2841,23 @@ FMT_CONSTEXPR inline auto check_char_specs(const format_specs& specs) -> bool { return true; } -template +template FMT_VISIBILITY("hidden") // Suppress an ld warning on macOS (#3769). -FMT_CONSTEXPR auto parse_format_specs(ParseContext& ctx) +FMT_CONSTEXPR auto parse_format_specs(basic_format_parse_context& ctx) -> decltype(ctx.begin()) { - using char_type = typename ParseContext::char_type; - using context = buffered_context; + using context = buffered_context; using mapped_type = remove_cvref_t().map(std::declval()))>; #if defined(__cpp_if_constexpr) if constexpr (std::is_default_constructible< - formatter>::value) { - return formatter().parse(ctx); + formatter>::value) { + return formatter().parse(ctx); } else { - type_is_unformattable_for _; + type_is_unformattable_for _; return ctx.begin(); } #else - return formatter().parse(ctx); + return formatter().parse(ctx); #endif } @@ -2867,32 +2866,26 @@ template struct arg_pack {}; template class format_string_checker { private: - using parse_context_type = compile_parse_context; - - // Format specifiers parsing function. - // In the future basic_format_parse_context will replace compile_parse_context - // here and will use is_constant_evaluated and downcasting to access the data - // needed for compile-time checks: https://godbolt.org/z/GvWzcTjh1. - using parse_func = const Char* (*)(parse_context_type&); - type types_[NUM_ARGS > 0 ? NUM_ARGS : 1]; - parse_context_type context_; - parse_func parse_funcs_[NUM_ARGS > 0 ? NUM_ARGS : 1]; named_arg_info named_args_[NUM_NAMED_ARGS > 0 ? NUM_NAMED_ARGS : 1]; + compile_parse_context context_; + + using parse_func = const Char* (*)(basic_format_parse_context&); + parse_func parse_funcs_[NUM_ARGS > 0 ? NUM_ARGS : 1]; public: template explicit FMT_CONSTEXPR format_string_checker(basic_string_view fmt, arg_pack) : types_{mapped_type_constant>::value...}, + named_args_{}, context_(fmt, NUM_ARGS, types_), - parse_funcs_{&parse_format_specs...}, - named_args_{} { - using dummy = int[]; + parse_funcs_{&parse_format_specs...} { + using ignore = int[]; int arg_index = 0, named_arg_index = 0; - (void)dummy{0, (init_statically_named_arg(named_args_, arg_index, - named_arg_index), - 0)...}; + (void)ignore{0, (init_statically_named_arg(named_args_, arg_index, + named_arg_index), + 0)...}; ignore_unused(arg_index, named_arg_index); }