From e00f827de76e73a21cfdd333d2fb66f84bcf6b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Thu, 21 Apr 2022 21:50:52 +0300 Subject: [PATCH] mdbx++: fix/refine detection of C++20 concepts accessibility. --- mdbx.h++ | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/mdbx.h++ b/mdbx.h++ index a2b1b176..abf214b8 100644 --- a/mdbx.h++ +++ b/mdbx.h++ @@ -209,14 +209,23 @@ #endif #endif /* MDBX_CXX20_UNLIKELY */ -#ifndef MDBX_CXX20_CONCEPT +#ifndef MDBX_HAVE_CXX20_CONCEPTS #if defined(DOXYGEN) || \ (defined(__cpp_concepts) && __cpp_concepts >= 201907L && \ - (!defined(__clang__) || \ - (__clang_major__ >= 12 && !defined(__APPLE__) && \ - !defined(__ANDROID_API__)) || \ - __clang_major__ >= \ - /* Hope Apple will fix concepts in AppleClang 14 */ 14)) + (!defined(__clang__) || __has_include() || \ + (defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 202002L))) +#if __has_include() || \ + (defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 202002L) +#include +#endif /* */ +#define MDBX_HAVE_CXX20_CONCEPTS 1 +#else +#define MDBX_HAVE_CXX20_CONCEPTS 0 +#endif +#endif /* MDBX_HAVE_CXX20_CONCEPTS */ + +#ifndef MDBX_CXX20_CONCEPT +#if MDBX_HAVE_CXX20_CONCEPTS #define MDBX_CXX20_CONCEPT(CONCEPT, NAME) CONCEPT NAME #else #define MDBX_CXX20_CONCEPT(CONCEPT, NAME) typename NAME @@ -224,13 +233,7 @@ #endif /* MDBX_CXX20_CONCEPT */ #ifndef MDBX_ASSERT_CXX20_CONCEPT_SATISFIED -#if defined(DOXYGEN) || \ - (defined(__cpp_concepts) && __cpp_concepts >= 201907L && \ - (!defined(__clang__) || \ - (__clang_major__ >= 12 && !defined(__APPLE__) && \ - !defined(__ANDROID_API__)) || \ - __clang_major__ >= \ - /* Hope Apple will fix concepts in AppleClang 14 */ 14)) +#if MDBX_HAVE_CXX20_CONCEPTS #define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE) \ static_assert(CONCEPT) #else @@ -509,13 +512,7 @@ static MDBX_CXX20_CONSTEXPR void *memcpy(void *dest, const void *src, size_t bytes) noexcept; //------------------------------------------------------------------------------ -#if defined(DOXYGEN) || \ - (defined(__cpp_concepts) && __cpp_concepts >= 201907L && \ - (!defined(__clang__) || \ - (__clang_major__ >= 12 && !defined(__APPLE__) && \ - !defined(__ANDROID_API__)) || \ - __clang_major__ >= \ - /* Hope Apple will fix concepts in AppleClang 14 */ 14)) +#if MDBX_HAVE_CXX20_CONCEPTS template concept MutableByteProducer = requires(T a, char array[42]) { @@ -538,7 +535,7 @@ concept SliceTranscoder = ImmutableByteProducer && { a.is_erroneous() } -> std::same_as; }; -#endif /* __cpp_concepts >= 201907L*/ +#endif /* MDBX_HAVE_CXX20_CONCEPTS */ template