From 5af88653eb9c57940cecad748e1192de1a1a0bb3 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 22 Mar 2024 13:46:03 +0900 Subject: [PATCH] Cleanup --- include/fmt/format.h | 26 ++++++++++---------------- test/format-test.cc | 7 +++---- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index c8adf84b..c68bf2fb 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -761,28 +761,22 @@ using is_integer = # define FMT_USE_LONG_DOUBLE 1 #endif -#ifndef FMT_USE_FLOAT128 -# ifdef __clang__ -// Clang emulates GCC, so it has to appear early. -# if FMT_HAS_INCLUDE() -# define FMT_USE_FLOAT128 1 -# endif -# elif defined(__GNUC__) -// GNU C++: -# if defined(_GLIBCXX_USE_FLOAT128) && !defined(__STRICT_ANSI__) -# define FMT_USE_FLOAT128 1 -# endif -# endif -# ifndef FMT_USE_FLOAT128 -# define FMT_USE_FLOAT128 0 -# endif +#if defined(FMT_USE_FLOAT128) +// Use the provided definition. +#elif FMT_CLANG_VERSION && FMT_HAS_INCLUDE() +# define FMT_USE_FLOAT128 1 +#elif FMT_GCC_VERSION && defined(_GLIBCXX_USE_FLOAT128) && \ + !defined(__STRICT_ANSI__) +# define FMT_USE_FLOAT128 1 +#else +# define FMT_USE_FLOAT128 0 #endif - #if FMT_USE_FLOAT128 using float128 = __float128; #else using float128 = void; #endif + template using is_float128 = std::is_same; template diff --git a/test/format-test.cc b/test/format-test.cc index 207fef16..48e2c0b2 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1793,15 +1793,14 @@ struct deadlockable { FMT_BEGIN_NAMESPACE template <> struct formatter { - FMT_CONSTEXPR auto parse(fmt::format_parse_context& ctx) - -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } - auto format(const deadlockable& d, fmt::format_context& ctx) const + auto format(const deadlockable& d, format_context& ctx) const -> decltype(ctx.out()) { std::lock_guard lock(d.mutex); - return fmt::format_to(ctx.out(), "{}", d.value); + return format_to(ctx.out(), "{}", d.value); } }; FMT_END_NAMESPACE