Simplify format string parsing

This commit is contained in:
Victor Zverovich
2022-12-25 12:31:38 -08:00
parent b8f36207c9
commit bd12aaa98e
4 changed files with 38 additions and 47 deletions

View File

@@ -523,9 +523,10 @@ TEST(format_test, constexpr_parse_arg_id) {
template <size_t N> constexpr auto parse_test_specs(const char (&s)[N]) {
auto ctx = fmt::detail::compile_parse_context<char>(fmt::string_view(s, N),
43, nullptr);
auto result = fmt::detail::parse_format_specs(s, s + N - 1, ctx,
fmt::detail::type::float_type);
return result.specs;
auto specs = fmt::detail::dynamic_format_specs<>();
fmt::detail::parse_format_specs(s, s + N - 1, specs, ctx,
fmt::detail::type::float_type);
return specs;
}
TEST(core_test, constexpr_parse_format_specs) {

View File

@@ -518,11 +518,10 @@ template <class charT> struct formatter<std::complex<double>, charT> {
public:
FMT_CONSTEXPR typename basic_format_parse_context<charT>::iterator parse(
basic_format_parse_context<charT>& ctx) {
auto result = parse_format_specs(ctx.begin(), ctx.end(), ctx,
detail::type::string_type);
specs_ = result.specs;
auto end = parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,
detail::type::string_type);
detail::parse_float_type_spec(specs_, detail::error_handler());
return result.end;
return end;
}
template <class FormatContext>