Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions libcudacxx/include/cuda/std/__concepts/concept_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@ namespace __cccl_unqualified_cuda_std = ::cuda::std; // NOLINT(misc-unused-alias
// - requires(BOOL-EXPR...)
// - typename(TYPE...)
// - _Same_as(TYPE...) EXPR...
// - _Satisfies(CONCEPT...) EXPR...
//
// The last 4 are handled below:
#define _CCCL_CONCEPT_REQUIREMENT_SWITCH_requires _CCCL_PP_CASE(REQUIRES)
#define _CCCL_CONCEPT_REQUIREMENT_SWITCH_noexcept _CCCL_PP_CASE(NOEXCEPT)
#define _CCCL_CONCEPT_REQUIREMENT_SWITCH_typename _CCCL_PP_CASE(TYPENAME)
#define _CCCL_CONCEPT_REQUIREMENT_SWITCH__Same_as _CCCL_PP_CASE(SAME_AS)
#define _CCCL_CONCEPT_REQUIREMENT_SWITCH_requires _CCCL_PP_CASE(REQUIRES)
#define _CCCL_CONCEPT_REQUIREMENT_SWITCH_noexcept _CCCL_PP_CASE(NOEXCEPT)
#define _CCCL_CONCEPT_REQUIREMENT_SWITCH_typename _CCCL_PP_CASE(TYPENAME)
#define _CCCL_CONCEPT_REQUIREMENT_SWITCH__Same_as _CCCL_PP_CASE(SAME_AS)
#define _CCCL_CONCEPT_REQUIREMENT_SWITCH__Satisfies _CCCL_PP_CASE(SATISFIES)

// Converts "requires(ARGS...)" to "ARGS..."
#define _CCCL_CONCEPT_EAT_REQUIRES_(...) _CCCL_PP_CAT(_CCCL_CONCEPT_EAT_REQUIRES_, __VA_ARGS__)
Expand Down Expand Up @@ -183,6 +185,18 @@ namespace __cccl_unqualified_cuda_std = ::cuda::std; // NOLINT(misc-unused-alias
_CCCL_PP_EVAL(_CCCL_PP_FIRST, _CCCL_PP_CAT(_CCCL_CONCEPT_GET_TYPE_FROM_SAME_AS_, __VA_ARGS__)))
#define _CCCL_CONCEPT_GET_TYPE_FROM_SAME_AS__Same_as(...) EXPAND(__VA_ARGS__),

// Converts "_Satisfies(TYPE) EXPR..." to "EXPR..."
#define _CCCL_CONCEPT_EAT_SATISFIES_(...) _CCCL_PP_CAT(_CCCL_CONCEPT_EAT_SATISFIES_, __VA_ARGS__)
#define _CCCL_CONCEPT_EAT_SATISFIES__Satisfies(...)

// Converts "_Satisfies(TYPE) EXPR..." to "TYPE" (The ridiculous concatenation of _CCCL_PP_
// with EXPAND(__VA_ARGS__) is the only way to get MSVC's broken preprocessor to do macro
// expansion here.)
#define _CCCL_CONCEPT_GET_CONCEPT_FROM_SATISFIES_(...) \
_CCCL_PP_CAT(_CCCL_PP_, \
_CCCL_PP_EVAL(_CCCL_PP_FIRST, _CCCL_PP_CAT(_CCCL_CONCEPT_GET_CONCEPT_FROM_SATISFIES_, __VA_ARGS__)))
#define _CCCL_CONCEPT_GET_CONCEPT_FROM_SATISFIES__Satisfies(...) EXPAND(__VA_ARGS__),

// Here are the implementations of the internal macros, first for when concepts
// are available, and then for when they're not.
#if _CCCL_HAS_CONCEPTS() || defined(_CCCL_DOXYGEN_INVOKED)
Expand All @@ -207,6 +221,8 @@ namespace __cccl_unqualified_cuda_std = ::cuda::std; // NOLINT(misc-unused-alias
_CCCL_CONCEPT_TRY_ADD_TYPENAME_(_CCCL_CONCEPT_EAT_TYPENAME_(_REQ))
# define _CCCL_CONCEPT_REQUIREMENT_CASE_SAME_AS(_REQ) \
{_CCCL_CONCEPT_EAT_SAME_AS_(_REQ)}->_CCCL_CONCEPT_VSTD::same_as<_CCCL_CONCEPT_GET_TYPE_FROM_SAME_AS_(_REQ)>
# define _CCCL_CONCEPT_REQUIREMENT_CASE_SATISFIES(_REQ) \
{_CCCL_CONCEPT_EAT_SATISFIES_(_REQ)}->_CCCL_CONCEPT_GET_CONCEPT_FROM_SATISFIES_(_REQ)

# define _CCCL_FRAGMENT(_NAME, ...) _NAME<__VA_ARGS__>

Expand Down Expand Up @@ -251,6 +267,9 @@ namespace __cccl_unqualified_cuda_std = ::cuda::std; // NOLINT(misc-unused-alias
static_cast<::__cccl_tag<_CCCL_CONCEPT_EAT_TYPENAME_(_REQ)>*>(nullptr)
# define _CCCL_CONCEPT_REQUIREMENT_CASE_SAME_AS(_REQ) \
::__cccl_requires<::cuda::std::same_as<_CCCL_CONCEPT_SAME_AS_REQUIREMENT_(_REQ)>>
# define _CCCL_CONCEPT_REQUIREMENT_CASE_SATISFIES(_REQ) \
::__cccl_requires < _CCCL_CONCEPT_GET_CONCEPT_FROM_SATISFIES_(_REQ) < decltype(_CCCL_CONCEPT_EAT_SATISFIES_(_REQ)) \
>>

// Converts "_Same_as(TYPE) EXPR..." to "TYPE, decltype(EXPR...)"
# define _CCCL_CONCEPT_SAME_AS_REQUIREMENT_(_REQ) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ _CCCL_CONCEPT_FRAGMENT(
requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u)(
requires(_With_lvalue_reference<_Tp>),
requires(_With_lvalue_reference<_Up>),
requires(__boolean_testable<decltype(__t == __u)>),
requires(__boolean_testable<decltype(__t != __u)>),
requires(__boolean_testable<decltype(__u == __t)>),
requires(__boolean_testable<decltype(__u != __t)>)));
_Satisfies(__boolean_testable) __t == __u,
_Satisfies(__boolean_testable) __t != __u,
_Satisfies(__boolean_testable) __u == __t,
_Satisfies(__boolean_testable) __u != __t));

template <class _Tp, class _Up>
_CCCL_CONCEPT __weakly_equality_comparable_with = _CCCL_FRAGMENT(__weakly_equality_comparable_with_, _Tp, _Up);
Expand Down
16 changes: 8 additions & 8 deletions libcudacxx/include/cuda/std/__concepts/totally_ordered.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ template <class _Tp, class _Up>
_CCCL_CONCEPT_FRAGMENT(
__partially_ordered_with_,
requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u)(
requires(__boolean_testable<decltype(__t < __u)>),
requires(__boolean_testable<decltype(__t > __u)>),
requires(__boolean_testable<decltype(__t <= __u)>),
requires(__boolean_testable<decltype(__t >= __u)>),
requires(__boolean_testable<decltype(__u < __t)>),
requires(__boolean_testable<decltype(__u > __t)>),
requires(__boolean_testable<decltype(__u <= __t)>),
requires(__boolean_testable<decltype(__u >= __t)>)));
_Satisfies(__boolean_testable)(__t < __u), //
_Satisfies(__boolean_testable)(__t > __u), //
_Satisfies(__boolean_testable)(__t <= __u), //
_Satisfies(__boolean_testable)(__t >= __u), //
_Satisfies(__boolean_testable)(__u < __t), //
_Satisfies(__boolean_testable)(__u > __t), //
_Satisfies(__boolean_testable)(__u <= __t), //
_Satisfies(__boolean_testable)(__u >= __t)));

template <class _Tp, class _Up>
_CCCL_CONCEPT __partially_ordered_with = _CCCL_FRAGMENT(__partially_ordered_with_, _Tp, _Up);
Expand Down
Loading