From a727881c37490ca3e083709064cb45d1fff0b712 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 9 Oct 2022 07:28:58 +0200 Subject: [PATCH] Utility: add a macro for conditional compilation This is useful for Magnum vectors. --- src/Corrade/Utility/Macros.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Corrade/Utility/Macros.h b/src/Corrade/Utility/Macros.h index 00a2714e9..994d91e80 100644 --- a/src/Corrade/Utility/Macros.h +++ b/src/Corrade/Utility/Macros.h @@ -394,12 +394,24 @@ Expands to @cpp constexpr @ce on C++14 and newer, empty on C++11. Useful for selectively marking functions that make use of C++14 relaxed constexpr rules. @see @ref CORRADE_CXX_STANDARD */ -#if CORRADE_CXX_STANDARD >= 201402 +#if __cpp_constexpr >= 201304 #define CORRADE_CONSTEXPR14 constexpr #else #define CORRADE_CONSTEXPR14 #endif +#if defined(__clang__) && __clang_major__ >= 9 || defined(__GNUG__) && __GNUG__ >= 9 || defined(_MSC_VER) && _MSC_VER >= 1931 +#define CORRADE_CONSTEVAL (__builtin_is_constant_evaluated()) +#elif CORRADE_CXX_STANDARD >= 202002L +#define CORRADE_CONSTEVAL (std::is_constant_evaluated()) /*include type_traits*/ +#endif + +#ifdef CORRADE_CONSTEVAL +#define CORRADE_CONSTEVAL14 CORRADE_CONSTEXPR14 +#else +#define CORRADE_CONSTEVAL14 +#endif + /** @hideinitializer @brief Always inline a function @m_since{2019,10}