fix #3105 - Compile-time error when mixing named argument with automatic indexing

This commit is contained in:
Radek Brich 2022-11-30 14:00:32 +01:00 committed by Victor Zverovich
parent b0c8263cb2
commit 62ceb181b1
2 changed files with 2 additions and 1 deletions

View File

@ -2975,7 +2975,7 @@ class format_string_checker {
#if FMT_USE_NONTYPE_TEMPLATE_ARGS #if FMT_USE_NONTYPE_TEMPLATE_ARGS
auto index = get_arg_index_by_name<Args...>(id); auto index = get_arg_index_by_name<Args...>(id);
if (index == invalid_arg_index) on_error("named argument is not found"); if (index == invalid_arg_index) on_error("named argument is not found");
return context_.check_arg_id(index), index; return index;
#else #else
(void)id; (void)id;
on_error("compile-time checks for named arguments require C++20 support"); on_error("compile-time checks for named arguments require C++20 support");

View File

@ -1907,6 +1907,7 @@ TEST(format_test, compile_time_string) {
EXPECT_EQ("", fmt::format(FMT_STRING(""))); EXPECT_EQ("", fmt::format(FMT_STRING("")));
EXPECT_EQ("", fmt::format(FMT_STRING(""), "arg"_a = 42)); EXPECT_EQ("", fmt::format(FMT_STRING(""), "arg"_a = 42));
EXPECT_EQ("42", fmt::format(FMT_STRING("{answer}"), "answer"_a = Answer())); EXPECT_EQ("42", fmt::format(FMT_STRING("{answer}"), "answer"_a = Answer()));
EXPECT_EQ("1 2", fmt::format(FMT_STRING("{} {two}"), 1, "two"_a = 2));
#endif #endif
(void)static_with_null; (void)static_with_null;