From 4d616479b577eaf1f5a88dc6b8cf038aafb58d05 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 9 Jan 2024 19:12:31 -0800 Subject: [PATCH] Simplify make_format_args --- include/fmt/core.h | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 74f81458..7a7ef0c8 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -200,12 +200,12 @@ FMT_END_NAMESPACE_STD # endif #endif -#ifndef FMT_INLINE -# if FMT_GCC_VERSION || FMT_CLANG_VERSION -# define FMT_INLINE inline __attribute__((always_inline)) -# else -# define FMT_INLINE inline -# endif +#ifdef FMT_INLINE +// Use the provided definition. +#elif FMT_GCC_VERSION || FMT_CLANG_VERSION +# define FMT_INLINE inline __attribute__((always_inline)) +#else +# define FMT_INLINE inline #endif #ifdef _MSC_VER @@ -1523,6 +1523,12 @@ constexpr auto encode_types() -> unsigned long long { (encode_types() << packed_arg_bits); } +template +constexpr unsigned long long make_descriptor() { + return NUM_ARGS <= max_packed_args ? encode_types() + : is_unpacked_bit | NUM_ARGS; +} + #if defined(__cpp_if_constexpr) // This type is intentionally undefined, only used for errors template struct type_is_unformattable_for; @@ -1932,29 +1938,21 @@ using is_formattable = bool_constant(), - unsigned long long DESC = NUM_ARGS <= detail::max_packed_args - ? detail::encode_types() - : detail::is_unpacked_bit | NUM_ARGS, + unsigned long long DESC = detail::make_descriptor(), FMT_ENABLE_IF(NUM_NAMED_ARGS == 0)> constexpr auto make_format_args(T&... args) - -> detail::format_arg_store { + -> detail::format_arg_store { return {{detail::make_arg( args)...}}; } template (), - unsigned long long DESC = - (NUM_ARGS <= detail::max_packed_args - ? detail::encode_types() - : detail::is_unpacked_bit | NUM_ARGS) | - (NUM_NAMED_ARGS != 0 - ? static_cast(detail::has_named_args_bit) - : 0), + unsigned long long DESC = detail::make_descriptor() | + static_cast(detail::has_named_args_bit), FMT_ENABLE_IF(NUM_NAMED_ARGS != 0)> constexpr auto make_format_args(T&... args) - -> detail::format_arg_store { + -> detail::format_arg_store { return {args...}; }