From ab6c53b8ac7a291f730d5d260ea2b0cc19eb674c Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sat, 25 Jan 2025 01:36:08 +0000 Subject: [PATCH] add a `__call_result_t` template alias, implement `__is_callable_v` with it --- .../include/cuda/std/__type_traits/is_callable.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libcudacxx/include/cuda/std/__type_traits/is_callable.h b/libcudacxx/include/cuda/std/__type_traits/is_callable.h index 2e433f65cf8..7e577cfc8a0 100644 --- a/libcudacxx/include/cuda/std/__type_traits/is_callable.h +++ b/libcudacxx/include/cuda/std/__type_traits/is_callable.h @@ -20,23 +20,21 @@ # pragma system_header #endif // no system header -#include +#include #include _LIBCUDACXX_BEGIN_NAMESPACE_STD -template ()(_CUDA_VSTD::declval<_Args>()...))> -_LIBCUDACXX_HIDE_FROM_ABI true_type __is_callable_helper(int); -template -_LIBCUDACXX_HIDE_FROM_ABI false_type __is_callable_helper(...); +template +using __call_result_t = decltype(_CUDA_VSTD::declval<_Func>()(_CUDA_VSTD::declval<_Args>()...)); template -struct __is_callable : decltype(__is_callable_helper<_Func, _Args...>(0)) +struct __is_callable : _IsValidExpansion<__call_result_t, _Func, _Args...> {}; #ifndef _CCCL_NO_VARIABLE_TEMPLATES template -_CCCL_INLINE_VAR constexpr bool __is_callable_v = decltype(__is_callable_helper<_Func, _Args...>(0))::value; +_CCCL_INLINE_VAR constexpr bool __is_callable_v = _IsValidExpansion<__call_result_t, _Func, _Args...>::value; #endif // !_CCCL_NO_VARIABLE_TEMPLATES _LIBCUDACXX_END_NAMESPACE_STD