24
24
# pragma system_header
25
25
#endif // no system header
26
26
27
+ #include < cuda/std/cstddef> // for size_t
28
+
27
29
// //////////////////////////////////////////////////////////////////////////////
28
30
// _CCCL_TEMPLATE
29
31
// Usage:
@@ -50,51 +52,46 @@ using __cccl_enable_if_t = typename __cccl_select<_Bp>::template type<_Tp>;
50
52
template <class _Tp , bool _Bp>
51
53
using __cccl_requires_t = typename __cccl_select<_Bp>::template type<_Tp>;
52
54
53
- #if (defined(__cpp_concepts) && _CCCL_STD_VER >= 2020)
55
+ #if (defined(__cpp_concepts) && _CCCL_STD_VER >= 2020) || defined(_CCCL_DOXYGEN_INVOKED)
54
56
# define _CCCL_TEMPLATE (...) template <__VA_ARGS__>
55
57
# define _CCCL_REQUIRES (...) requires __VA_ARGS__
56
58
# define _CCCL_AND &&
57
59
# define _CCCL_TRAILING_REQUIRES_AUX_ (...) requires __VA_ARGS__
58
60
# define _CCCL_TRAILING_REQUIRES (...) ->__VA_ARGS__ _CCCL_TRAILING_REQUIRES_AUX_
59
61
#else // ^^^ __cpp_concepts ^^^ / vvv !__cpp_concepts vvv
60
62
# define _CCCL_TEMPLATE (...) template <__VA_ARGS__
61
- # define _CCCL_REQUIRES (...) , bool _CCCL_true_ = true , __cccl_enable_if_t < __VA_ARGS__ && _CCCL_true_ , int > = 0 >
62
- # define _CCCL_AND &&_CCCL_true_ , int > = 0 , __cccl_enable_if_t <
63
+ # define _CCCL_REQUIRES (...) , bool __cccl_true_ = true , __cccl_enable_if_t < __VA_ARGS__ && __cccl_true_ , int > = 0 >
64
+ # define _CCCL_AND &&__cccl_true_ , int > = 0 , __cccl_enable_if_t <
63
65
# define _CCCL_TRAILING_REQUIRES_AUX_ (...) , __VA_ARGS__ >
64
66
# define _CCCL_TRAILING_REQUIRES (...) ->__cccl_requires_t < __VA_ARGS__ _CCCL_TRAILING_REQUIRES_AUX_
65
67
#endif // !__cpp_concepts
66
68
67
69
#if _CCCL_STD_VER >= 2014
68
70
69
- namespace __cccl_concept
70
- {
71
-
72
- template <typename ...>
73
- struct _Tag ;
71
+ template <class ...>
72
+ struct __cccl_tag ;
74
73
75
74
template <class >
76
- _LIBCUDACXX_HIDE_FROM_ABI constexpr bool __is_true ()
75
+ _LIBCUDACXX_HIDE_FROM_ABI constexpr bool __cccl_is_true ()
77
76
{
78
77
return true ;
79
78
}
80
79
81
- # if _CCCL_COMPILER(CLANG) || _CCCL_COMPILER( MSVC)
80
+ # if _CCCL_COMPILER(MSVC)
82
81
template <bool _Bp>
83
82
_LIBCUDACXX_HIDE_FROM_ABI __cccl_enable_if_t <_Bp> __cccl_requires ()
84
83
{}
85
- # else // ^^^ _CCCL_COMPILER(CLANG) || _CCCL_COMPILER( MSVC) ^^^ / vvv other compilers vvv
84
+ # else // ^^^ _CCCL_COMPILER(MSVC) ^^^ / vvv !_CCCL_COMPILER(MSVC) vvv
86
85
template <bool _Bp, __cccl_enable_if_t <_Bp, int > = 0 >
87
86
_CCCL_INLINE_VAR constexpr int __cccl_requires = 0 ;
88
- # endif // !_CCCL_COMPILER(CLANG) && !_CCCL_COMPILER( MSVC)
87
+ # endif // !_CCCL_COMPILER(MSVC)
89
88
90
89
template <class _Tp , class ... _Args>
91
- _LIBCUDACXX_HIDE_FROM_ABI auto __cccl_make_dependent (_Tp*, _Tag <_Args...>*) -> _Tp;
90
+ _LIBCUDACXX_HIDE_FROM_ABI auto __cccl_make_dependent (_Tp*, __cccl_tag <_Args...>*) -> _Tp;
92
91
93
92
template <class _Impl , class ... _Args>
94
- using __requires_expr_impl =
95
- decltype (__cccl_make_dependent(static_cast <_Impl*>(nullptr ), static_cast <_Tag<void , _Args...>*>(nullptr )));
96
-
97
- } // namespace __cccl_concept
93
+ using __cccl_requires_expr_impl =
94
+ decltype (__cccl_make_dependent(static_cast <_Impl*>(nullptr ), static_cast<__cccl_tag<void, _Args...>*>(nullptr )));
98
95
99
96
// So that we can refer to the ::cuda::std namespace below
100
97
_LIBCUDACXX_BEGIN_NAMESPACE_STD
@@ -107,21 +104,21 @@ _LIBCUDACXX_END_NAMESPACE_STD
107
104
//
108
105
// where ::concept is a fully qualified name, would not compile. The
109
106
// _CUDA_VSTD macro is fully qualified.
110
- namespace __unqualified_cuda_std = _CUDA_VSTD; // NOLINT(misc-unused-alias-decls)
107
+ namespace __cccl_unqualified_cuda_std = _CUDA_VSTD; // NOLINT(misc-unused-alias-decls)
111
108
112
109
# if _CCCL_CUDACC_BELOW(12, 2)
113
- # define _CCCL_CONCEPT_VSTD __unqualified_cuda_std // must not be fully qualified
110
+ # define _CCCL_CONCEPT_VSTD __cccl_unqualified_cuda_std // must not be fully qualified
114
111
# else
115
112
# define _CCCL_CONCEPT_VSTD _CUDA_VSTD
116
113
# endif
117
114
118
115
# define _CCCL_CONCEPT_FRAGMENT_REQS_M0 (_REQ ) _CCCL_CONCEPT_FRAGMENT_REQS_SELECT_(_REQ)(_REQ)
119
116
# define _CCCL_CONCEPT_FRAGMENT_REQS_M1 (_REQ ) _CCCL_PP_EXPAND _REQ
120
117
# define _CCCL_CONCEPT_FRAGMENT_REQS_ (...) {_CCCL_PP_FOR_EACH (_CCCL_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__)}
121
- # define _CCCL_CONCEPT_FRAGMENT_REQS_SELECT_ (_REQ ) \
122
- _CCCL_PP_CAT3 (_CCCL_CONCEPT_FRAGMENT_REQS_SELECT_, \
123
- _CCCL_PP_EVAL (_CCCL_PP_CHECK, _CCCL_PP_CAT3(_CCCL_CONCEPT_FRAGMENT_REQS_SELECT_PROBE_, _REQ))) \
124
- /* */
118
+ # define _CCCL_CONCEPT_FRAGMENT_REQS_SELECT_ (_REQ ) \
119
+ _CCCL_PP_CAT3 (_CCCL_CONCEPT_FRAGMENT_REQS_SELECT_, \
120
+ _CCCL_PP_EVAL (_CCCL_PP_CHECK, _CCCL_PP_CAT3(_CCCL_CONCEPT_FRAGMENT_REQS_SELECT_PROBE_, _REQ)))
121
+
125
122
# define _CCCL_CONCEPT_FRAGMENT_REQS_SELECT_PROBE_requires _CCCL_PP_PROBE_N (~, 1 )
126
123
# define _CCCL_CONCEPT_FRAGMENT_REQS_SELECT_PROBE_noexcept _CCCL_PP_PROBE_N (~, 2 )
127
124
# define _CCCL_CONCEPT_FRAGMENT_REQS_SELECT_PROBE_typename _CCCL_PP_PROBE_N (~, 3 )
@@ -132,15 +129,14 @@ namespace __unqualified_cuda_std = _CUDA_VSTD; // NOLINT(misc-unused-alias-decls
132
129
# define _CCCL_CONCEPT_FRAGMENT_REQS_SELECT_2 _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_OR_NOEXCEPT
133
130
# define _CCCL_CONCEPT_FRAGMENT_REQS_SELECT_3 _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_OR_NOEXCEPT
134
131
# define _CCCL_CONCEPT_FRAGMENT_REQS_SELECT_4 _CCCL_CONCEPT_FRAGMENT_REQS_SAME_AS
132
+
135
133
# define _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_OR_NOEXCEPT (_REQ ) \
136
134
_CCCL_PP_CAT4 (_CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_, _REQ)
137
135
# define _CCCL_PP_EAT_TYPENAME_PROBE_typename _CCCL_PP_PROBE (~)
138
136
# define _CCCL_PP_EAT_TYPENAME_SELECT_ (_Xp, ...) \
139
137
_CCCL_PP_CAT3 (_CCCL_PP_EAT_TYPENAME_SELECT_, \
140
138
_CCCL_PP_EVAL (_CCCL_PP_CHECK, _CCCL_PP_CAT3(_CCCL_PP_EAT_TYPENAME_PROBE_, _Xp)))
141
- # define _CCCL_PP_EAT_TYPENAME_ (...) \
142
- _CCCL_PP_EVAL2 (_CCCL_PP_EAT_TYPENAME_SELECT_, __VA_ARGS__, ) \
143
- (__VA_ARGS__)
139
+ # define _CCCL_PP_EAT_TYPENAME_ (...) _CCCL_PP_EVAL2(_CCCL_PP_EAT_TYPENAME_SELECT_, __VA_ARGS__, )(__VA_ARGS__)
144
140
# define _CCCL_PP_EAT_TYPENAME_SELECT_0 (...) __VA_ARGS__
145
141
# define _CCCL_PP_EAT_TYPENAME_SELECT_1 (...) _CCCL_PP_CAT3(_CCCL_PP_EAT_TYPENAME_, __VA_ARGS__)
146
142
# define _CCCL_PP_EAT_TYPENAME_typename
@@ -178,13 +174,13 @@ namespace __unqualified_cuda_std = _CUDA_VSTD; // NOLINT(misc-unused-alias-decls
178
174
# define _CCCL_CONCEPT_FRAGMENT (_NAME, ...) \
179
175
_LIBCUDACXX_HIDE_FROM_ABI auto _NAME##_CCCL_CONCEPT_FRAGMENT_impl_ _CCCL_CONCEPT_FRAGMENT_REQS_##__VA_ARGS__ > { \
180
176
} \
181
- template <typename ... _As> \
177
+ template <class ... _As> \
182
178
_LIBCUDACXX_HIDE_FROM_ABI char _NAME##_CCCL_CONCEPT_FRAGMENT_( \
183
- __cccl_concept::_Tag <_As...>*, decltype(&_NAME##_CCCL_CONCEPT_FRAGMENT_impl_<_As...>)); \
184
- _LIBCUDACXX_HIDE_FROM_ABI char (&_NAME##_CCCL_CONCEPT_FRAGMENT_(...))[2] /* */
179
+ ::__cccl_tag <_As...>*, decltype(&_NAME##_CCCL_CONCEPT_FRAGMENT_impl_<_As...>)); \
180
+ _LIBCUDACXX_HIDE_FROM_ABI char (&_NAME##_CCCL_CONCEPT_FRAGMENT_(...))[2]
185
181
# if defined(_MSC_VER) && !defined(__clang__)
186
182
# define _CCCL_CONCEPT_FRAGMENT_TRUE (...) \
187
- __cccl_concept::__is_true <decltype(_CCCL_PP_FOR_EACH(_CCCL_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__) void ())>()
183
+ ::__cccl_is_true <decltype(_CCCL_PP_FOR_EACH(_CCCL_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__) void ())>()
188
184
# else
189
185
# define _CCCL_CONCEPT_FRAGMENT_TRUE (...) \
190
186
!(decltype(_CCCL_PP_FOR_EACH(_CCCL_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__) void (), false ){})
@@ -194,23 +190,22 @@ namespace __unqualified_cuda_std = _CUDA_VSTD; // NOLINT(misc-unused-alias-decls
194
190
# define _CCCL_CONCEPT_FRAGMENT_REQS_M (_REQ ) \
195
191
_CCCL_PP_CAT2 (_CCCL_CONCEPT_FRAGMENT_REQS_M, _CCCL_PP_IS_PAREN(_REQ)) \
196
192
(_REQ),
197
- # define _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_requires (...) __cccl_concept ::__cccl_requires<__VA_ARGS__>
198
- # define _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_typename (...) static_cast <__cccl_concept::_Tag <__VA_ARGS__>*>(nullptr )
193
+ # define _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_requires (...) ::__cccl_requires<__VA_ARGS__>
194
+ # define _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_typename (...) static_cast <::__cccl_tag <__VA_ARGS__>*>(nullptr )
199
195
# if _CCCL_COMPILER(GCC, <, 14)
200
196
// GCC < 14 can't mangle noexcept expressions, so just check that the
201
197
// expression is well-formed.
202
198
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70790
203
199
# define _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_noexcept (...) __VA_ARGS__
204
200
# else
205
- # define _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_noexcept (...) __cccl_concept ::__cccl_requires<noexcept (__VA_ARGS__)>
201
+ # define _CCCL_CONCEPT_FRAGMENT_REQS_REQUIRES_noexcept (...) ::__cccl_requires<noexcept (__VA_ARGS__)>
206
202
# endif
207
203
# define _CCCL_CONCEPT_FRAGMENT_REQS_SAME_AS (_REQ ) \
208
- __cccl_concept::__cccl_requires< \
209
- _CUDA_VSTD::same_as<_CCCL_PP_CAT4(_CCCL_CONCEPT_FRAGMENT_REQS_SAME_AS_, _REQ) _CCCL_PP_RPAREN>>
204
+ ::__cccl_requires<_CUDA_VSTD::same_as<_CCCL_PP_CAT4(_CCCL_CONCEPT_FRAGMENT_REQS_SAME_AS_, _REQ) _CCCL_PP_RPAREN>>
210
205
# define _CCCL_CONCEPT_FRAGMENT_REQS_SAME_AS__Same_as (...) __VA_ARGS__, decltype _CCCL_PP_LPAREN
211
206
212
207
# define _CCCL_FRAGMENT (_NAME, ...) \
213
- (1u == sizeof (_NAME##_CCCL_CONCEPT_FRAGMENT_(static_cast <__cccl_concept::_Tag <__VA_ARGS__>*>(nullptr ), nullptr )))
208
+ (1u == sizeof (_NAME##_CCCL_CONCEPT_FRAGMENT_(static_cast <::__cccl_tag <__VA_ARGS__>*>(nullptr ), nullptr )))
214
209
215
210
# endif
216
211
@@ -225,7 +220,7 @@ namespace __unqualified_cuda_std = _CUDA_VSTD; // NOLINT(misc-unused-alias-decls
225
220
// );
226
221
//
227
222
// Can only be used as the last requirement in a concept definition.
228
- # if defined(__cpp_concepts) && _CCCL_STD_VER >= 2020
223
+ # if defined(__cpp_concepts) && _CCCL_STD_VER >= 2020 || defined(_CCCL_DOXYGEN_INVOKED)
229
224
# define _CCCL_REQUIRES_EXPR (_TY, ...) requires(__VA_ARGS__) _CCCL_REQUIRES_EXPR_2
230
225
# define _CCCL_REQUIRES_EXPR_2 (...) {_CCCL_PP_FOR_EACH (_CCCL_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__)}
231
226
# else
@@ -249,27 +244,29 @@ namespace __unqualified_cuda_std = _CUDA_VSTD; // NOLINT(misc-unused-alias-decls
249
244
# define _CCCL_REQUIRES_EXPR_EXPAND_TPARAMS (...) _CCCL_PP_FOR_EACH(_CCCL_REQUIRES_EXPR_EXPAND_TPARAM, __VA_ARGS__)
250
245
251
246
# define _CCCL_REQUIRES_EXPR (_TY, ...) \
252
- __cccl_concept::__requires_expr_impl< struct _CCCL_PP_CAT ( \
253
- __cccl_requires_expr_detail_, __LINE__) _CCCL_REQUIRES_EXPR_EXPAND_TPARAMS _TY>:: \
254
- __cccl_is_satisfied (static_cast <__cccl_concept::_Tag <void _CCCL_REQUIRES_EXPR_EXPAND_TPARAMS _TY>*>(nullptr ), \
255
- static_cast<void (*)(__VA_ARGS__)>(nullptr )); \
247
+ ::__cccl_requires_expr_impl< \
248
+ struct _CCCL_PP_CAT ( __cccl_requires_expr_detail_, __LINE__) _CCCL_REQUIRES_EXPR_EXPAND_TPARAMS \
249
+ _TY>:: __cccl_is_satisfied(static_cast <::__cccl_tag <void _CCCL_REQUIRES_EXPR_EXPAND_TPARAMS _TY>*>(nullptr ), \
250
+ static_cast <void (*)(__VA_ARGS__)>(nullptr )); \
256
251
struct _CCCL_PP_CAT (__cccl_requires_expr_detail_, __LINE__) \
257
252
{ \
258
- using _Self_t = _CCCL_PP_CAT (__cccl_requires_expr_detail_, __LINE__); \
253
+ using __cccl_self_t = _CCCL_PP_CAT (__cccl_requires_expr_detail_, __LINE__); \
259
254
template <class _CCCL_REQUIRES_EXPR_TPARAMS _TY> \
260
- _LIBCUDACXX_HIDE_FROM_ABI static auto _Well_formed (__VA_ARGS__) _CCCL_REQUIRES_EXPR_2
261
-
262
- # define _CCCL_REQUIRES_EXPR_2 (...) \
263
- ->decltype (_CCCL_PP_FOR_EACH (_CCCL_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__) void ()) {} \
264
- template <class ... Args, class Sig , class = decltype (static_cast <Sig*>(&_Self_t::_Well_formed<Args...>))> \
265
- _LIBCUDACXX_HIDE_FROM_ABI static constexpr bool __cccl_is_satisfied (__cccl_concept::_Tag<Args...>*, Sig*) \
266
- { \
267
- return true ; \
268
- } \
269
- _LIBCUDACXX_HIDE_FROM_ABI static constexpr bool __cccl_is_satisfied (void *, ...) \
270
- { \
271
- return false ; \
272
- } \
255
+ _LIBCUDACXX_HIDE_FROM_ABI static auto __cccl_well_formed (__VA_ARGS__) _CCCL_REQUIRES_EXPR_2
256
+
257
+ # define _CCCL_REQUIRES_EXPR_2 (...) \
258
+ ->decltype (_CCCL_PP_FOR_EACH (_CCCL_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__) void ()) {} \
259
+ template <class ... _Args, \
260
+ class _Sig , \
261
+ class = decltype (static_cast <_Sig*>(&__cccl_self_t ::__cccl_well_formed<_Args...>))> \
262
+ _LIBCUDACXX_HIDE_FROM_ABI static constexpr bool __cccl_is_satisfied (::__cccl_tag<_Args...>*, _Sig*) \
263
+ { \
264
+ return true ; \
265
+ } \
266
+ _LIBCUDACXX_HIDE_FROM_ABI static constexpr bool __cccl_is_satisfied (void *, ...) \
267
+ { \
268
+ return false ; \
269
+ } \
273
270
}
274
271
# endif
275
272
0 commit comments