diff options
author | Martijn Vels <mvels@google.com> | 2023-01-20 07:20:05 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-01-20 07:21:07 -0800 |
commit | a0b102c35bae9dea68be21a718c8c7b459e239c8 (patch) | |
tree | 9123391c09f15b2f49ea725636d2b449796dad20 /absl/base/config.h | |
parent | c611e5ce1de222eb995f5aeabf3fa8cd57ae124b (diff) |
Add absl::is_constant_evaluated for pre-c++20 support
PiperOrigin-RevId: 503437019
Change-Id: I3630fec690f1472130fef21b16dfcd3c5208aa69
Diffstat (limited to 'absl/base/config.h')
-rw-r--r-- | absl/base/config.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/absl/base/config.h b/absl/base/config.h index 1058ce74..5cbc9855 100644 --- a/absl/base/config.h +++ b/absl/base/config.h @@ -928,4 +928,15 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || #define ABSL_INTERNAL_HAVE_ARM_NEON 1 #endif +// ABSL_HAVE_CONSTANT_EVALUATED is used for compile-time detection of +// constant evaluation support through `absl::is_constant_evaluated`. +#ifdef ABSL_HAVE_CONSTANT_EVALUATED +#error ABSL_HAVE_CONSTANT_EVALUATED cannot be directly set +#endif +#ifdef __cpp_lib_is_constant_evaluated +#define ABSL_HAVE_CONSTANT_EVALUATED 1 +#elif ABSL_HAVE_BUILTIN(__builtin_is_constant_evaluated) +#define ABSL_HAVE_CONSTANT_EVALUATED 1 +#endif + #endif // ABSL_BASE_CONFIG_H_ |