mdbx++: fix/refine detection of C++20 concepts accessibility.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-04-21 21:50:52 +03:00
parent abc2341cb4
commit e00f827de7

View File

@ -209,14 +209,23 @@
#endif #endif
#endif /* MDBX_CXX20_UNLIKELY */ #endif /* MDBX_CXX20_UNLIKELY */
#ifndef MDBX_CXX20_CONCEPT #ifndef MDBX_HAVE_CXX20_CONCEPTS
#if defined(DOXYGEN) || \ #if defined(DOXYGEN) || \
(defined(__cpp_concepts) && __cpp_concepts >= 201907L && \ (defined(__cpp_concepts) && __cpp_concepts >= 201907L && \
(!defined(__clang__) || \ (!defined(__clang__) || __has_include(<concepts>) || \
(__clang_major__ >= 12 && !defined(__APPLE__) && \ (defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 202002L)))
!defined(__ANDROID_API__)) || \ #if __has_include(<concepts>) || \
__clang_major__ >= \ (defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 202002L)
/* Hope Apple will fix concepts in AppleClang 14 */ 14)) #include <concepts>
#endif /* <concepts> */
#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 #define MDBX_CXX20_CONCEPT(CONCEPT, NAME) CONCEPT NAME
#else #else
#define MDBX_CXX20_CONCEPT(CONCEPT, NAME) typename NAME #define MDBX_CXX20_CONCEPT(CONCEPT, NAME) typename NAME
@ -224,13 +233,7 @@
#endif /* MDBX_CXX20_CONCEPT */ #endif /* MDBX_CXX20_CONCEPT */
#ifndef MDBX_ASSERT_CXX20_CONCEPT_SATISFIED #ifndef MDBX_ASSERT_CXX20_CONCEPT_SATISFIED
#if defined(DOXYGEN) || \ #if MDBX_HAVE_CXX20_CONCEPTS
(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))
#define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE) \ #define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE) \
static_assert(CONCEPT<TYPE>) static_assert(CONCEPT<TYPE>)
#else #else
@ -509,13 +512,7 @@ static MDBX_CXX20_CONSTEXPR void *memcpy(void *dest, const void *src,
size_t bytes) noexcept; size_t bytes) noexcept;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if defined(DOXYGEN) || \ #if MDBX_HAVE_CXX20_CONCEPTS
(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))
template <typename T> template <typename T>
concept MutableByteProducer = requires(T a, char array[42]) { concept MutableByteProducer = requires(T a, char array[42]) {
@ -538,7 +535,7 @@ concept SliceTranscoder = ImmutableByteProducer<T> &&
{ a.is_erroneous() } -> std::same_as<bool>; { a.is_erroneous() } -> std::same_as<bool>;
}; };
#endif /* __cpp_concepts >= 201907L*/ #endif /* MDBX_HAVE_CXX20_CONCEPTS */
template <class ALLOCATOR = legacy_allocator, template <class ALLOCATOR = legacy_allocator,
typename CAPACITY_POLICY = default_capacity_policy, typename CAPACITY_POLICY = default_capacity_policy,