Skip to content

Commit e63d1f8

Browse files
authored
add a __call_result_t template alias, implement __is_callable_v with it (#3527)
1 parent de038b7 commit e63d1f8

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

libcudacxx/include/cuda/std/__type_traits/is_callable.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,21 @@
2020
# pragma system_header
2121
#endif // no system header
2222

23-
#include <cuda/std/__type_traits/integral_constant.h>
23+
#include <cuda/std/__type_traits/is_valid_expansion.h>
2424
#include <cuda/std/__utility/declval.h>
2525

2626
_LIBCUDACXX_BEGIN_NAMESPACE_STD
2727

28-
template <class _Func, class... _Args, class = decltype(_CUDA_VSTD::declval<_Func>()(_CUDA_VSTD::declval<_Args>()...))>
29-
_LIBCUDACXX_HIDE_FROM_ABI true_type __is_callable_helper(int);
30-
template <class...>
31-
_LIBCUDACXX_HIDE_FROM_ABI false_type __is_callable_helper(...);
28+
template <class _Func, class... _Args>
29+
using __call_result_t = decltype(_CUDA_VSTD::declval<_Func>()(_CUDA_VSTD::declval<_Args>()...));
3230

3331
template <class _Func, class... _Args>
34-
struct __is_callable : decltype(__is_callable_helper<_Func, _Args...>(0))
32+
struct __is_callable : _IsValidExpansion<__call_result_t, _Func, _Args...>
3533
{};
3634

3735
#ifndef _CCCL_NO_VARIABLE_TEMPLATES
3836
template <class _Func, class... _Args>
39-
_CCCL_INLINE_VAR constexpr bool __is_callable_v = decltype(__is_callable_helper<_Func, _Args...>(0))::value;
37+
_CCCL_INLINE_VAR constexpr bool __is_callable_v = _IsValidExpansion<__call_result_t, _Func, _Args...>::value;
4038
#endif // !_CCCL_NO_VARIABLE_TEMPLATES
4139

4240
_LIBCUDACXX_END_NAMESPACE_STD

0 commit comments

Comments
 (0)