enable named arguments check in compile-time checks (#2649)

works only if all named arguments are UDL-based
This commit is contained in:
Alexey Ochapov 2021-12-18 02:53:05 +03:00 committed by GitHub
parent 82246b8766
commit ef72b471fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1109,6 +1109,11 @@ template <typename... Args> constexpr auto count_named_args() -> size_t {
return count<is_named_arg<Args>::value...>();
}
template <typename... Args>
constexpr auto count_statically_named_args() -> size_t {
return count<is_statically_named_arg<Args>::value...>();
}
enum class type {
none_type,
// Integer types should go first,
@ -3043,7 +3048,8 @@ template <typename Char, typename... Args> class basic_format_string {
std::is_reference<Args>::value)...>() == 0,
"passing views as lvalues is disallowed");
#ifdef FMT_HAS_CONSTEVAL
if constexpr (detail::count_named_args<Args...>() == 0) {
if constexpr (detail::count_named_args<Args...>() ==
detail::count_statically_named_args<Args...>()) {
using checker = detail::format_string_checker<Char, detail::error_handler,
remove_cvref_t<Args>...>;
detail::parse_format_string<true>(str_, checker(s, {}));