Browse Source

Add EA_CPP20_CONSTEXPR and EA_COMPILER_CPP20_ENABLED

Rojo 4 months ago
parent
commit
0699a15efd

+ 5 - 6
include/Common/EABase/config/eacompiler.h

@@ -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
 
 

+ 17 - 0
include/Common/EABase/config/eacompilertraits.h

@@ -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
 	//