From ef72b471fca0ec27533f70bf123c46e3a800251d Mon Sep 17 00:00:00 2001 From: Alexey Ochapov Date: Sat, 18 Dec 2021 02:53:05 +0300 Subject: [PATCH] enable named arguments check in compile-time checks (#2649) works only if all named arguments are UDL-based --- include/fmt/core.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 9e0e8964..14ac2070 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1109,6 +1109,11 @@ template constexpr auto count_named_args() -> size_t { return count::value...>(); } +template +constexpr auto count_statically_named_args() -> size_t { + return count::value...>(); +} + enum class type { none_type, // Integer types should go first, @@ -3043,7 +3048,8 @@ template class basic_format_string { std::is_reference::value)...>() == 0, "passing views as lvalues is disallowed"); #ifdef FMT_HAS_CONSTEVAL - if constexpr (detail::count_named_args() == 0) { + if constexpr (detail::count_named_args() == + detail::count_statically_named_args()) { using checker = detail::format_string_checker...>; detail::parse_format_string(str_, checker(s, {}));