Add EA_CPP20_CONSTEXPR and EA_COMPILER_CPP20_ENABLED

This commit is contained in:
Rojo
2025-07-31 14:46:07 -08:00
parent b89b6ff26b
commit 0699a15efd
2 changed files with 22 additions and 6 deletions

View File

@@ -313,12 +313,11 @@
// decided to not define __cplusplus like thus until they have fully completed their
// C++20 support.
#if !defined(EA_COMPILER_CPP20_ENABLED) && defined(__cplusplus)
// TODO(rparoin): enable once a C++20 value for the __cplusplus macro has been published
// #if (__cplusplus >= 202003L)
// #define EA_COMPILER_CPP20_ENABLED 1
// #elif defined(_MSVC_LANG) && (_MSVC_LANG >= 202003L) // C++20+
// #define EA_COMPILER_CPP20_ENABLED 1
// #endif
#if defined(__cplusplus) && (__cplusplus >= 202002L)
#define EA_COMPILER_CPP20_ENABLED 1
#elif defined(_MSVC_LANG) && (_MSVC_LANG >= 202002L)
#define EA_COMPILER_CPP20_ENABLED 1
#endif
#endif

View File

@@ -2023,6 +2023,23 @@
#endif
#endif
/////////////////////////////////////////////////////////////////////////////////
//
// EA_CPP20_CONSTEXPR
//
// Defined as constexpr when the targeted language version is higher than or equal to
// C++20. Defined as nothing otherwise.
//
#if !defined(EA_CPP20_CONSTEXPR)
#if defined(EA_COMPILER_CPP20_ENABLED)
#define EA_CPP20_CONSTEXPR constexpr
#else
#define EA_CPP20_CONSTEXPR
#define EA_NO_CPP20_CONSTEXPR 1
#endif
#endif
// ------------------------------------------------------------------------
// EA_CONSTEXPR_IF
//