From b54d94cbd16a3532a920daf5d546bf19a2dc1e4c Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sat, 23 Nov 2024 19:36:46 +0000 Subject: [PATCH] add a `_CCCL_NO_CONCEPTS` config macro --- libcudacxx/include/cuda/std/__cccl/dialect.h | 5 +++++ .../include/cuda/std/__concepts/concept_macros.h | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libcudacxx/include/cuda/std/__cccl/dialect.h b/libcudacxx/include/cuda/std/__cccl/dialect.h index 8dfedd5a3cc..9995a7aea5d 100644 --- a/libcudacxx/include/cuda/std/__cccl/dialect.h +++ b/libcudacxx/include/cuda/std/__cccl/dialect.h @@ -104,6 +104,11 @@ # define _CCCL_NO_VARIABLE_TEMPLATES #endif // _CCCL_STD_VER <= 2011 +// concepts are only available from C++20 onwards +#if _CCCL_STD_VER <= 2017 || !defined(__cpp_concepts) || (__cpp_concepts < 201907L) +# define _CCCL_NO_CONCEPTS +#endif // _CCCL_STD_VER <= 2017 + // noexcept function types are only available from C++17 onwards #if _CCCL_STD_VER >= 2017 && defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510L) # define _CCCL_FUNCTION_TYPE_NOEXCEPT noexcept diff --git a/libcudacxx/include/cuda/std/__concepts/concept_macros.h b/libcudacxx/include/cuda/std/__concepts/concept_macros.h index 2850c38a493..1301f3f6d59 100644 --- a/libcudacxx/include/cuda/std/__concepts/concept_macros.h +++ b/libcudacxx/include/cuda/std/__concepts/concept_macros.h @@ -50,19 +50,19 @@ using __cccl_enable_if_t = typename __cccl_select<_Bp>::template type<_Tp>; template using __cccl_requires_t = typename __cccl_select<_Bp>::template type<_Tp>; -#if (defined(__cpp_concepts) && _CCCL_STD_VER >= 2020) +#if !defined(_CCCL_NO_CONCEPTS) || defined(_CCCL_DOXYGEN_INVOKED) # define _CCCL_TEMPLATE(...) template <__VA_ARGS__> # define _CCCL_REQUIRES(...) requires __VA_ARGS__ # define _CCCL_AND && # define _CCCL_TRAILING_REQUIRES_AUX_(...) requires __VA_ARGS__ # define _CCCL_TRAILING_REQUIRES(...) ->__VA_ARGS__ _CCCL_TRAILING_REQUIRES_AUX_ -#else // ^^^ __cpp_concepts ^^^ / vvv !__cpp_concepts vvv +#else // ^^^ _CCCL_NO_CONCEPTS ^^^ / vvv !_CCCL_NO_CONCEPTS vvv # define _CCCL_TEMPLATE(...) template <__VA_ARGS__ # define _CCCL_REQUIRES(...) , bool _CCCL_true_ = true, __cccl_enable_if_t < __VA_ARGS__ && _CCCL_true_, int > = 0 > # define _CCCL_AND &&_CCCL_true_, int > = 0, __cccl_enable_if_t < # define _CCCL_TRAILING_REQUIRES_AUX_(...) , __VA_ARGS__ > # define _CCCL_TRAILING_REQUIRES(...) ->__cccl_requires_t < __VA_ARGS__ _CCCL_TRAILING_REQUIRES_AUX_ -#endif // !__cpp_concepts +#endif // !defined(_CCCL_NO_CONCEPTS) #if _CCCL_STD_VER >= 2014 @@ -145,7 +145,7 @@ namespace __unqualified_cuda_std = _CUDA_VSTD; // NOLINT(misc-unused-alias-decls # define _CCCL_PP_EAT_TYPENAME_SELECT_1(...) _CCCL_PP_CAT3(_CCCL_PP_EAT_TYPENAME_, __VA_ARGS__) # define _CCCL_PP_EAT_TYPENAME_typename -# if (defined(__cpp_concepts) && _CCCL_STD_VER >= 2020) || defined(_CCCL_DOXYGEN_INVOKED) +# if !defined(_CCCL_NO_CONCEPTS) || defined(_CCCL_DOXYGEN_INVOKED) # define _CCCL_CONCEPT concept @@ -225,7 +225,7 @@ namespace __unqualified_cuda_std = _CUDA_VSTD; // NOLINT(misc-unused-alias-decls // ); // // Can only be used as the last requirement in a concept definition. -# if defined(__cpp_concepts) && _CCCL_STD_VER >= 2020 +# if !defined(_CCCL_NO_CONCEPTS) || defined(_CCCL_DOXYGEN_INVOKED) # define _CCCL_REQUIRES_EXPR(_TY, ...) requires(__VA_ARGS__) _CCCL_REQUIRES_EXPR_2 # define _CCCL_REQUIRES_EXPR_2(...) {_CCCL_PP_FOR_EACH(_CCCL_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__)} # else