From ff8f32478697dae12ff02e89cb711a05478816e7 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 6 Sep 2024 08:28:02 -0700 Subject: [PATCH] Minor cleanup --- include/fmt/base.h | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 8bf02c38..255f9559 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -246,7 +246,8 @@ #elif FMT_GCC_VERSION >= 504 && !defined(__NVCOMPILER) // Workaround a _Pragma bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59884 // and an nvhpc warning: https://github.com/fmtlib/fmt/pull/2582. -# define FMT_GCC_PRAGMA(x) _Pragma(#x) +# define FMT_GCC_PRAGMA_IMPL(x) _Pragma(#x) +# define FMT_GCC_PRAGMA(x) FMT_GCC_PRAGMA_IMPL(GCC x) #else # define FMT_GCC_PRAGMA(x) #endif @@ -314,9 +315,9 @@ (void)ignore { 0, (expr, 0)... } // Enable minimal optimizations for more compact code in debug mode. -FMT_GCC_PRAGMA(GCC push_options) +FMT_GCC_PRAGMA(push_options) #if !defined(__OPTIMIZE__) && !defined(__CUDACC__) -FMT_GCC_PRAGMA(GCC optimize("Og")) +FMT_GCC_PRAGMA(optimize("Og")) #endif FMT_CLANG_PRAGMA(diagnostic push) @@ -1277,6 +1278,7 @@ template struct arg_mapper { FMT_MAP_API auto map(...) -> unformattable { return {}; } }; +// detail:: is used to workaround a bug in MSVC 2017. template using mapped_t = decltype(detail::arg_mapper::map(std::declval())); @@ -2239,17 +2241,15 @@ template class value { FMT_ALWAYS_INLINE value(const void* val) : pointer(val) {} template ::map( - std::declval()))>::value)> + FMT_ENABLE_IF(!std::is_same::map( + std::declval()))>::value)> FMT_CONSTEXPR20 FMT_ALWAYS_INLINE value(T&& val) { *this = arg_mapper::map(val); } - template < - typename T, - FMT_ENABLE_IF(std::is_same::map( - std::declval()))>::value)> + template ::map( + std::declval()))>::value)> FMT_CONSTEXPR20 FMT_ALWAYS_INLINE value(T&& val) { // Use enum instead of constexpr because the latter may generate code. enum { formattable_char = !std::is_same::value }; @@ -2871,12 +2871,6 @@ struct formatter::value> { }; -#if FMT_BUILTIN_TYPES -# define FMT_CUSTOM -#else -# define FMT_CUSTOM , detail::custom_tag() -#endif - /** * Constructs an object that stores references to arguments and can be * implicitly converted to `format_args`. `Context` can be omitted in which case @@ -2890,7 +2884,8 @@ template ()> constexpr FMT_ALWAYS_INLINE auto make_format_args(T&... args) -> detail::format_arg_store { - FMT_GCC_PRAGMA(GCC diagnostic ignored "-Wconversion") + // Suppress warnings for pathological types convertible to detail::value. + FMT_GCC_PRAGMA(diagnostic ignored "-Wconversion") return {{args...}}; } @@ -3063,7 +3058,7 @@ FMT_INLINE void println(format_string fmt, T&&... args) { FMT_END_EXPORT FMT_CLANG_PRAGMA(diagnostic pop) -FMT_GCC_PRAGMA(GCC pop_options) +FMT_GCC_PRAGMA(pop_options) FMT_END_NAMESPACE #ifdef FMT_HEADER_ONLY