Cleanup constexpr detection

This commit is contained in:
Victor Zverovich
2024-01-11 21:06:40 -08:00
parent 170ffb1ff8
commit 810d1750f1

View File

@ -101,14 +101,6 @@
#define FMT_HAS_CPP17_ATTRIBUTE(attribute) \ #define FMT_HAS_CPP17_ATTRIBUTE(attribute) \
(FMT_CPLUSPLUS >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute)) (FMT_CPLUSPLUS >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute))
#ifdef FMT_DEPRECATED
// Use the provided definition.
#elif FMT_HAS_CPP14_ATTRIBUTE(deprecated)
# define FMT_DEPRECATED [[deprecated]]
#else
# define FMT_DEPRECATED /* deprecated */
#endif
// Detect C++14 relaxed constexpr. // Detect C++14 relaxed constexpr.
#ifdef FMT_USE_CONSTEXPR #ifdef FMT_USE_CONSTEXPR
// Use the provided definition. // Use the provided definition.
@ -129,12 +121,18 @@
# define FMT_CONSTEXPR # define FMT_CONSTEXPR
#endif #endif
#if (FMT_CPLUSPLUS >= 202002L || \ // Detect C++20 extensions to constexpr and std::is_constant_evaluated.
(FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002)) && \ #ifndef __cpp_lib_is_constant_evaluated
((!FMT_GLIBCXX_RELEASE || FMT_GLIBCXX_RELEASE >= 10) && \ # define FMT_CONSTEXPR20
(!FMT_LIBCPP_VERSION || FMT_LIBCPP_VERSION >= 10000) && \ #elif FMT_GLIBCXX_RELEASE && FMT_GLIBCXX_RELEASE < 10
(!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1928)) && \ # define FMT_CONSTEXPR20
defined(__cpp_lib_is_constant_evaluated) #elif FMT_LIBCPP_VERSION && FMT_LIBCPP_VERSION < 10000
# define FMT_CONSTEXPR20
#elif FMT_MSC_VERSION && FMT_MSC_VERSION < 1928
# define FMT_CONSTEXPR20
#elif FMT_CPLUSPLUS >= 202002L
# define FMT_CONSTEXPR20 constexpr
#elif FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002
# define FMT_CONSTEXPR20 constexpr # define FMT_CONSTEXPR20 constexpr
#else #else
# define FMT_CONSTEXPR20 # define FMT_CONSTEXPR20
@ -156,6 +154,14 @@
# endif # endif
#endif #endif
#ifdef FMT_DEPRECATED
// Use the provided definition.
#elif FMT_HAS_CPP14_ATTRIBUTE(deprecated)
# define FMT_DEPRECATED [[deprecated]]
#else
# define FMT_DEPRECATED /* deprecated */
#endif
// Disable [[noreturn]] on MSVC/NVCC because of bogus unreachable code warnings. // Disable [[noreturn]] on MSVC/NVCC because of bogus unreachable code warnings.
#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && \ #if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && \
!defined(__NVCC__) !defined(__NVCC__)