Skip to content

Commit

Permalink
Cleanup constexpr detection
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jan 12, 2024
1 parent 170ffb1 commit 810d175
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@
#define FMT_HAS_CPP17_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.
#ifdef FMT_USE_CONSTEXPR
// Use the provided definition.
Expand All @@ -129,12 +121,18 @@
# define FMT_CONSTEXPR
#endif

#if (FMT_CPLUSPLUS >= 202002L || \
(FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002)) && \
((!FMT_GLIBCXX_RELEASE || FMT_GLIBCXX_RELEASE >= 10) && \
(!FMT_LIBCPP_VERSION || FMT_LIBCPP_VERSION >= 10000) && \
(!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1928)) && \
defined(__cpp_lib_is_constant_evaluated)
// Detect C++20 extensions to constexpr and std::is_constant_evaluated.
#ifndef __cpp_lib_is_constant_evaluated
# define FMT_CONSTEXPR20
#elif FMT_GLIBCXX_RELEASE && FMT_GLIBCXX_RELEASE < 10
# define FMT_CONSTEXPR20
#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
#else
# define FMT_CONSTEXPR20
Expand All @@ -156,6 +154,14 @@
# 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.
#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && \
!defined(__NVCC__)
Expand Down

0 comments on commit 810d175

Please sign in to comment.