C++11 support for Replaceable
[folly.git] / folly / Portability.h
index 0f549868bdd0bb0ea4445bce692fbf8c56bbe669..cf2c8d32749897faab4c5409bef86ef8f468a11a 100644 (file)
@@ -407,3 +407,21 @@ constexpr auto kIsWindows = false;
 constexpr auto kMscVer = 0;
 #endif
 }
+
+// Define FOLLY_USE_CPP14_CONSTEXPR to be true if the compiler's C++14
+// constexpr support is "good enough".
+#ifndef FOLLY_USE_CPP14_CONSTEXPR
+#if defined(__clang__)
+#define FOLLY_USE_CPP14_CONSTEXPR __cplusplus >= 201300L
+#elif defined(__GNUC__)
+#define FOLLY_USE_CPP14_CONSTEXPR __cplusplus >= 201304L
+#else
+#define FOLLY_USE_CPP14_CONSTEXPR 0 // MSVC?
+#endif
+#endif
+
+#if FOLLY_USE_CPP14_CONSTEXPR
+#define FOLLY_CPP14_CONSTEXPR constexpr
+#else
+#define FOLLY_CPP14_CONSTEXPR inline
+#endif