diff --git a/stl/inc/format b/stl/inc/format index e09d61e5f3..0ffd0c8ddb 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -3519,7 +3519,10 @@ struct _Format_checker { consteval explicit _Format_checker(basic_string_view<_CharT> _Fmt) noexcept : _Parse_context(_Fmt, _Num_args), _Parse_funcs{&_Compile_time_parse_format_specs<_Args, _ParseContext>...} {} constexpr void _On_text(const _CharT*, const _CharT*) const noexcept {} - constexpr void _On_replacement_field(size_t, const _CharT*) const noexcept {} + constexpr void _On_replacement_field(const size_t _Id, const _CharT*) const { + _ParseContext _Parse_ctx({}); + (void) _Parse_funcs[_Id](_Parse_ctx); + } constexpr const _CharT* _On_format_specs(const size_t _Id, const _CharT* _First, const _CharT*) { _Parse_context.advance_to(_Parse_context.begin() + (_First - _Parse_context.begin()._Unwrapped())); if (_Id < _Num_args) { diff --git a/tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp b/tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp index e15a100d78..928ff8aa89 100644 --- a/tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp +++ b/tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp @@ -57,7 +57,7 @@ struct not_const_formattable_type { template <> struct std::formatter { - basic_format_parse_context::iterator parse(basic_format_parse_context& parse_ctx) { + constexpr basic_format_parse_context::iterator parse(basic_format_parse_context& parse_ctx) { if (parse_ctx.begin() != parse_ctx.end()) { throw format_error{"only empty specs please"}; } @@ -71,7 +71,7 @@ struct std::formatter { template <> struct std::formatter { - basic_format_parse_context::iterator parse(basic_format_parse_context& parse_ctx) { + constexpr basic_format_parse_context::iterator parse(basic_format_parse_context& parse_ctx) { if (parse_ctx.begin() != parse_ctx.end()) { throw format_error{"only empty specs please"}; }