summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
authorGravatar Yuriy Chernyshov <thegeorg@yandex-team.com>2023-08-21 07:05:50 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-08-21 07:06:42 -0700
commit36ff83f3789878044f3d1537fef387925330c579 (patch)
treec7c78c99621ee8968b22f42eca018da31a081697 /absl/base
parent94b37802217a9c9bb182bd99d55096683ef45b2c (diff)
PR #1520: Make use of C++20 feature test macros to bestow better compatibility
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1520 Fixes #1519 and removes the burden of manually feature testing all the platforms supported by absl. Merge 26bc4ee13a93edaeee2a21b5eff3569b806acc91 into 94b37802217a9c9bb182bd99d55096683ef45b2c Merging this change closes #1520 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1520 from georgthegreat:feature-test-macros 26bc4ee13a93edaeee2a21b5eff3569b806acc91 PiperOrigin-RevId: 558777775 Change-Id: Ie3e1f309761c67fa233a03e42762776cd93c69b4
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/config.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/absl/base/config.h b/absl/base/config.h
index 65a71199..a8425ba7 100644
--- a/absl/base/config.h
+++ b/absl/base/config.h
@@ -75,6 +75,12 @@
#define ABSL_INTERNAL_CPLUSPLUS_LANG __cplusplus
#endif
+#if defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
+ ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
+// Include library feature test macros.
+#include <version>
+#endif
+
#if defined(__APPLE__)
// Included for TARGET_OS_IPHONE, __IPHONE_OS_VERSION_MIN_REQUIRED,
// __IPHONE_8_0.
@@ -557,6 +563,8 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
// Checks whether C++17 std::any is available.
#ifdef ABSL_HAVE_STD_ANY
#error "ABSL_HAVE_STD_ANY cannot be directly set."
+#elif defined(__cpp_lib_any) && __cpp_lib_any >= 201606L
+#define ABSL_HAVE_STD_ANY 1
#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
!ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
@@ -568,6 +576,8 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
// Checks whether C++17 std::optional is available.
#ifdef ABSL_HAVE_STD_OPTIONAL
#error "ABSL_HAVE_STD_OPTIONAL cannot be directly set."
+#elif defined(__cpp_lib_optional) && __cpp_lib_optional >= 202106L
+#define ABSL_HAVE_STD_OPTIONAL 1
#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
!ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
@@ -579,6 +589,8 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
// Checks whether C++17 std::variant is available.
#ifdef ABSL_HAVE_STD_VARIANT
#error "ABSL_HAVE_STD_VARIANT cannot be directly set."
+#elif defined(__cpp_lib_variant) && __cpp_lib_variant >= 201606L
+#define ABSL_HAVE_STD_VARIANT 1
#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
!ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
@@ -590,6 +602,8 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
// Checks whether C++17 std::string_view is available.
#ifdef ABSL_HAVE_STD_STRING_VIEW
#error "ABSL_HAVE_STD_STRING_VIEW cannot be directly set."
+#elif defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
+#define ABSL_HAVE_STD_STRING_VIEW 1
#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L
#define ABSL_HAVE_STD_STRING_VIEW 1