diff --git a/include/fmt/core.h b/include/fmt/core.h index 4b5236f6..399b70e7 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2444,28 +2444,22 @@ constexpr int get_arg_index_by_name(basic_string_view name) { if constexpr (detail::is_statically_named_arg()) { if (name == T::name) return N; } - if constexpr (sizeof...(Args) == 0) { - return invalid_arg_index; - } else { + if constexpr (sizeof...(Args) > 0) return get_arg_index_by_name(name); - } -} - -template -constexpr int get_arg_index_by_name(basic_string_view name) { - if constexpr (sizeof...(Args) == 0) { - return invalid_arg_index; - } else { - return get_arg_index_by_name<0, Args...>(name); - } -} -#else -template -constexpr int get_arg_index_by_name(basic_string_view) { return invalid_arg_index; } #endif +template +FMT_CONSTEXPR int get_arg_index_by_name(basic_string_view name) { +#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS + if constexpr (sizeof...(Args) > 0) + return get_arg_index_by_name<0, Args...>(name); +#endif + (void)name; + return invalid_arg_index; +} + template class format_string_checker { public: