diff --git a/include/fmt/core.h b/include/fmt/core.h index ae80287e..370b2f1e 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2627,7 +2627,9 @@ template class format_string_checker { #endif } - FMT_CONSTEXPR void on_replacement_field(int, const Char*) {} + FMT_CONSTEXPR void on_replacement_field(int id, const Char* begin) { + on_format_specs(id, begin, begin); // Call parse() on empty specs. + } FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char*) -> const Char* { diff --git a/test/core-test.cc b/test/core-test.cc index 22175dab..1d84ffd7 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -273,7 +273,7 @@ struct custom_context { bool called = false; template struct formatter_type { - auto parse(fmt::format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(fmt::format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } @@ -290,7 +290,7 @@ struct test_struct {}; FMT_BEGIN_NAMESPACE template struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } @@ -573,7 +573,7 @@ struct disabled_formatter_convertible { FMT_BEGIN_NAMESPACE template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } auto format(enabled_formatter, format_context& ctx) const @@ -583,7 +583,7 @@ template <> struct formatter { }; template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } auto format(enabled_ptr_formatter*, format_context& ctx) const @@ -607,7 +607,7 @@ struct nonconst_formattable {}; FMT_BEGIN_NAMESPACE template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } @@ -619,7 +619,7 @@ template <> struct formatter { }; template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } @@ -641,7 +641,7 @@ struct convertible_to_pointer_formattable { FMT_BEGIN_NAMESPACE template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } @@ -721,7 +721,7 @@ struct convertible_to_cstring { FMT_BEGIN_NAMESPACE template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } auto format(convertible_to_int, format_context& ctx) const @@ -842,7 +842,7 @@ struct its_a_trap { FMT_BEGIN_NAMESPACE template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } diff --git a/test/format-test.cc b/test/format-test.cc index b75d64bf..0f082f94 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2101,7 +2101,7 @@ struct check_back_appender {}; FMT_BEGIN_NAMESPACE template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); }