Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use libcu++ void_t everywhere #1977

Merged
merged 1 commit into from
Jul 17, 2024
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
6 changes: 1 addition & 5 deletions cub/cub/block/radix_rank_sort_operations.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,14 @@ _CCCL_HOST_DEVICE void for_each_member(F f, DecomposerT decomposer, T& aggregate

namespace radix
{

template <class...>
using void_t = void;

template <class T, class = void>
struct is_fundamental_type
{
static constexpr bool value = false;
};

template <class T>
struct is_fundamental_type<T, void_t<typename Traits<T>::UnsignedBits>>
struct is_fundamental_type<T, ::cuda::std::void_t<typename Traits<T>::UnsignedBits>>
{
static constexpr bool value = true;
};
Expand Down
22 changes: 11 additions & 11 deletions cub/cub/util_type.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -825,16 +825,16 @@ struct DoubleBuffer
* \brief Defines a structure \p detector_name that is templated on type \p T. The \p detector_name struct exposes a
* constant member \p value indicating whether or not parameter \p T exposes a nested type \p nested_type_name
*/
# define CUB_DEFINE_DETECT_NESTED_TYPE(detector_name, nested_type_name) \
template <typename T, typename = void> \
struct detector_name : ::cuda::std::false_type \
{ \
CUB_DEPRECATED_BECAUSE("Use ::value instead") static constexpr bool VALUE = false; \
}; \
template <typename T> \
struct detector_name<T, ::cuda::std::__void_t<typename T::nested_type_name>> : ::cuda::std::true_type \
{ \
CUB_DEPRECATED_BECAUSE("Use ::value instead") static constexpr bool VALUE = true; \
# define CUB_DEFINE_DETECT_NESTED_TYPE(detector_name, nested_type_name) \
template <typename T, typename = void> \
struct detector_name : ::cuda::std::false_type \
{ \
CUB_DEPRECATED_BECAUSE("Use ::value instead") static constexpr bool VALUE = false; \
}; \
template <typename T> \
struct detector_name<T, ::cuda::std::void_t<typename T::nested_type_name>> : ::cuda::std::true_type \
{ \
CUB_DEPRECATED_BECAUSE("Use ::value instead") static constexpr bool VALUE = true; \
};

/******************************************************************************
Expand All @@ -854,7 +854,7 @@ struct BinaryOpHasIdxParam : ::cuda::std::false_type
template <typename T, typename BinaryOp>
struct BinaryOpHasIdxParam<T,
BinaryOp,
::cuda::std::__void_t<decltype(::cuda::std::declval<BinaryOp>()(
::cuda::std::void_t<decltype(::cuda::std::declval<BinaryOp>()(
::cuda::std::declval<T>(), ::cuda::std::declval<T>(), int{}))>> : ::cuda::std::true_type
{
CUB_DEPRECATED_BECAUSE("Use ::value instead") static constexpr bool HAS_PARAM = true;
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__complex/vector_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct __complex_can_implicitly_construct : false_type
{};

template <class _Dest, class _Source>
struct __complex_can_implicitly_construct<_Dest, _Source, __void_t<decltype(_Dest{_CUDA_VSTD::declval<_Source>()})>>
struct __complex_can_implicitly_construct<_Dest, _Source, void_t<decltype(_Dest{_CUDA_VSTD::declval<_Source>()})>>
: true_type
{};

Expand All @@ -82,7 +82,7 @@ struct __has_vector_type : false_type
{};

template <class _Tp>
struct __has_vector_type<_Tp, __void_t<__type_to_vector_t<_Tp>>> : true_type
struct __has_vector_type<_Tp, void_t<__type_to_vector_t<_Tp>>> : true_type
{};

template <class _Tp>
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__concepts/destructible.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ _LIBCUDACXX_INLINE_VAR constexpr bool __destructible_impl<_Tp,
# if defined(_CCCL_COMPILER_GCC)
__enable_if_t<_CCCL_TRAIT(is_destructible, _Tp)>>
# else // ^^^ _CCCL_COMPILER_GCC ^^^ / vvv !_CCCL_COMPILER_GCC vvv
__void_t<decltype(_CUDA_VSTD::declval<_Tp>().~_Tp())>>
void_t<decltype(_CUDA_VSTD::declval<_Tp>().~_Tp())>>
# endif // !_CCCL_COMPILER_GCC
= noexcept(_CUDA_VSTD::declval<_Tp>().~_Tp());

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__cuda/barrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#endif // no system header

#include <cuda/std/__atomic/api/owned.h>
#include <cuda/std/__type_traits/void_t.h> // _CUDA_VSTD::__void_t
#include <cuda/std/__type_traits/void_t.h> // _CUDA_VSTD::void_t
#include <cuda/std/detail/libcxx/include/cstdlib> // _LIBCUDACXX_UNREACHABLE

#if defined(_CCCL_CUDA_COMPILER)
Expand Down Expand Up @@ -1063,7 +1063,7 @@ struct __get_size_align

// aligned_size_t<n> overload: return n.
template <typename T>
struct __get_size_align<T, _CUDA_VSTD::__void_t<decltype(T::align)>>
struct __get_size_align<T, _CUDA_VSTD::void_t<decltype(T::align)>>
{
static constexpr int align = T::align;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct __is_transparent : false_type
{};

template <class _Tp, class _Up>
struct __is_transparent<_Tp, _Up, __void_t<typename _Tp::is_transparent>> : true_type
struct __is_transparent<_Tp, _Up, void_t<typename _Tp::is_transparent>> : true_type
{};

#endif
Expand Down
12 changes: 6 additions & 6 deletions libcudacxx/include/cuda/std/__iterator/iterator_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct __cccl_type_is_defined : _CUDA_VSTD::false_type
{};

template <class _Tp>
struct __cccl_type_is_defined<_Tp, _CUDA_VSTD::__void_t<decltype(sizeof(_Tp))>> : _CUDA_VSTD::true_type
struct __cccl_type_is_defined<_Tp, _CUDA_VSTD::void_t<decltype(sizeof(_Tp))>> : _CUDA_VSTD::true_type
{};

// detect whether the used STL has contiguous_iterator_tag defined
Expand Down Expand Up @@ -206,11 +206,11 @@ struct __has_iterator_typedefs
_LIBCUDACXX_INLINE_VISIBILITY static false_type __test(...);
template <class _Up>
_LIBCUDACXX_INLINE_VISIBILITY static true_type
__test(__void_t<typename _Up::iterator_category>* = nullptr,
__void_t<typename _Up::difference_type>* = nullptr,
__void_t<typename _Up::value_type>* = nullptr,
__void_t<typename _Up::reference>* = nullptr,
__void_t<typename _Up::pointer>* = nullptr);
__test(void_t<typename _Up::iterator_category>* = nullptr,
void_t<typename _Up::difference_type>* = nullptr,
void_t<typename _Up::value_type>* = nullptr,
void_t<typename _Up::reference>* = nullptr,
void_t<typename _Up::pointer>* = nullptr);

public:
static const bool value = decltype(__test<_Tp>(0, 0, 0, 0, 0))::value;
Expand Down
16 changes: 8 additions & 8 deletions libcudacxx/include/cuda/std/__memory/allocator_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ _CCCL_NV_DIAG_SUPPRESS(1215)
_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if _CCCL_STD_VER <= 2014
# define _LIBCUDACXX_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \
template <class _Tp, class = void> \
struct NAME : false_type \
{}; \
template <class _Tp> \
struct NAME<_Tp, __void_t<typename _Tp::PROPERTY>> : true_type \
# define _LIBCUDACXX_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \
template <class _Tp, class = void> \
struct NAME : false_type \
{}; \
template <class _Tp> \
struct NAME<_Tp, void_t<typename _Tp::PROPERTY>> : true_type \
{}

#else // ^^^ _CCCL_STD_VER <= 2014 ^^^ / vvv _CCCL_STD_VER >= 2017 vvv
# define _LIBCUDACXX_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \
template <class _Tp, class = void> \
inline constexpr bool NAME##_v = false; \
template <class _Tp> \
inline constexpr bool NAME##_v<_Tp, __void_t<typename _Tp::PROPERTY>> = true;
inline constexpr bool NAME##_v<_Tp, void_t<typename _Tp::PROPERTY>> = true;
#endif // _CCCL_STD_VER >= 2017

// __pointer
Expand Down Expand Up @@ -190,7 +190,7 @@ template <class _Tp, class _Up, class = void>
struct __has_rebind_other : false_type
{};
template <class _Tp, class _Up>
struct __has_rebind_other<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>::other>> : true_type
struct __has_rebind_other<_Tp, _Up, void_t<typename _Tp::template rebind<_Up>::other>> : true_type
{};

template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__memory/construct_at.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct __is_narrowing_impl<_To, _From> : true_type
// This is a bit hacky, but we rely on the fact that arithmetic types cannot have more than one argument to their
// constructor
template <class _To, class _From>
struct __is_narrowing_impl<_To, _From, __void_t<decltype(_To{_CUDA_VSTD::declval<_From>()})>> : false_type
struct __is_narrowing_impl<_To, _From, void_t<decltype(_To{_CUDA_VSTD::declval<_From>()})>> : false_type
{};

template <class _Tp, class... _Args>
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__memory/pointer_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct __has_element_type : false_type
{};

template <class _Tp>
struct __has_element_type<_Tp, __void_t<typename _Tp::element_type>> : true_type
struct __has_element_type<_Tp, void_t<typename _Tp::element_type>> : true_type
{};

template <class _Ptr, bool = __has_element_type<_Ptr>::value>
Expand Down Expand Up @@ -123,7 +123,7 @@ struct __has_difference_type : false_type
{};

template <class _Tp>
struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type>> : true_type
struct __has_difference_type<_Tp, void_t<typename _Tp::difference_type>> : true_type
{};

template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__memory/uses_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ template <class _Tp, class = void>
struct __has_allocator_type : false_type
{};
template <class _Tp>
struct __has_allocator_type<_Tp, __void_t<typename _Tp::allocator_type>> : true_type
struct __has_allocator_type<_Tp, void_t<typename _Tp::allocator_type>> : true_type
{};

template <class _Tp, class _Alloc, bool = _CCCL_TRAIT(__has_allocator_type, _Tp)>
Expand All @@ -46,7 +46,7 @@ struct __uses_allocator<_Tp, _Alloc, true> : is_convertible<_Alloc, typename _Tp
template <class _Tp, class = void>
_LIBCUDACXX_INLINE_VAR constexpr bool __has_allocator_type_v = false;
template <class _Tp>
_LIBCUDACXX_INLINE_VAR constexpr bool __has_allocator_type_v<_Tp, __void_t<typename _Tp::allocator_type>> = true;
_LIBCUDACXX_INLINE_VAR constexpr bool __has_allocator_type_v<_Tp, void_t<typename _Tp::allocator_type>> = true;

template <class _Tp, class _Alloc, bool = _CCCL_TRAIT(__has_allocator_type, _Tp)>
_LIBCUDACXX_INLINE_VAR constexpr bool __uses_allocator_v = false;
Expand Down
6 changes: 3 additions & 3 deletions libcudacxx/include/cuda/std/__type_traits/common_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct __common_type2_imp

// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
template <class _Tp, class _Up>
struct __common_type2_imp<_Tp, _Up, __void_t<__cond_type<_Tp, _Up>>>
struct __common_type2_imp<_Tp, _Up, void_t<__cond_type<_Tp, _Up>>>
{
typedef _LIBCUDACXX_NODEBUG_TYPE __decay_t<__cond_type<_Tp, _Up>> type;
};
Expand All @@ -74,13 +74,13 @@ template <class... _Tp>
struct __common_types;

template <class _Tp, class _Up>
struct __common_type_impl<__common_types<_Tp, _Up>, __void_t<__common_type_t<_Tp, _Up>>>
struct __common_type_impl<__common_types<_Tp, _Up>, void_t<__common_type_t<_Tp, _Up>>>
{
typedef __common_type_t<_Tp, _Up> type;
};

template <class _Tp, class _Up, class _Vp, class... _Rest>
struct __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...>, __void_t<__common_type_t<_Tp, _Up>>>
struct __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...>, void_t<__common_type_t<_Tp, _Up>>>
: __common_type_impl<__common_types<__common_type_t<_Tp, _Up>, _Vp, _Rest...>>
{};

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__type_traits/is_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct __is_allocator : false_type

template <typename _Alloc>
struct __is_allocator<_Alloc,
__void_t<typename _Alloc::value_type>,
__void_t<decltype(_CUDA_VSTD::declval<_Alloc&>().allocate(size_t(0)))>> : true_type
void_t<typename _Alloc::value_type>,
void_t<decltype(_CUDA_VSTD::declval<_Alloc&>().allocate(size_t(0)))>> : true_type
{};

_LIBCUDACXX_END_NAMESPACE_STD
Expand Down
4 changes: 1 addition & 3 deletions libcudacxx/include/cuda/std/__type_traits/void_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if _CCCL_STD_VER > 2011
template <class...>
using void_t = void;
#endif

template <class...>
using __void_t = void;
using __void_t _LIBCUDACXX_DEPRECATED = void;

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ struct __narrowing_check
{};

template <class _Dest, class _Source>
struct __narrowing_check_impl<_Dest, _Source, __void_t<decltype(_Dest{_CUDA_VSTD::declval<_Source>()})>>
struct __narrowing_check_impl<_Dest, _Source, void_t<decltype(_Dest{_CUDA_VSTD::declval<_Source>()})>>
{
using type = __type_identity<_Dest>;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,20 @@ static_assert(cuda::std::is_default_constructible<cuda::stream_ref>::value, "");
static_assert(!cuda::std::is_constructible<cuda::stream_ref, int>::value, "");
static_assert(!cuda::std::is_constructible<cuda::stream_ref, cuda::std::nullptr_t>::value, "");

template <class...>
using void_t = void;

#if TEST_STD_VER < 2014
template <class T, class = void>
struct has_value_type : cuda::std::false_type
{};
template <class T>
struct has_value_type<T, void_t<typename T::value_type>> : cuda::std::true_type
struct has_value_type<T, cuda::std::void_t<typename T::value_type>> : cuda::std::true_type
{};
static_assert(has_value_type<cuda::stream_ref>::value, "");
#else
template <class T, class = void>
constexpr bool has_value_type = false;

template <class T>
constexpr bool has_value_type_v<T, void_t<typename T::value_type>> = true;
constexpr bool has_value_type_v<T, cuda::std::void_t<typename T::value_type>> = true;
static_assert(has_value_type<cuda::stream_ref>, "");
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// void_t

// UNSUPPORTED: c++98, c++03, c++11
// UNSUPPORTED: c++98, c++03

// XFAIL: gcc-5.1, gcc-5.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <thrust/detail/type_deduction.h>
#include <thrust/detail/type_traits.h>
#include <thrust/tuple.h>
#include <thrust/type_traits/void_t.h>

#include <type_traits>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <thrust/detail/type_traits.h>
#include <thrust/detail/type_traits/function_traits.h>

#include <cuda/std/__type_traits/void_t.h>

#include <type_traits>

THRUST_NAMESPACE_BEGIN
Expand All @@ -54,7 +56,7 @@ struct result_of_adaptable_function

// specialization for invocations which define result_type
template <typename Functor, typename... ArgTypes>
struct result_of_adaptable_function<Functor(ArgTypes...), ::cuda::std::__void_t<typename Functor::result_type>>
struct result_of_adaptable_function<Functor(ArgTypes...), ::cuda::std::void_t<typename Functor::result_type>>
{
using type = typename Functor::result_type;
};
Expand Down
5 changes: 3 additions & 2 deletions thrust/thrust/iterator/detail/iterator_traits.inl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
#include <thrust/detail/type_traits.h>
#include <thrust/iterator/detail/iterator_category_to_traversal.h>
#include <thrust/iterator/iterator_categories.h>
#include <thrust/type_traits/void_t.h>

#include <cuda/std/__type_traits/void_t.h>

THRUST_NAMESPACE_BEGIN

Expand Down Expand Up @@ -77,7 +78,7 @@ struct iterator_system_impl
{};

template <typename Iterator>
struct iterator_system_impl<Iterator, void_t<typename iterator_traits<Iterator>::iterator_category>>
struct iterator_system_impl<Iterator, ::cuda::std::void_t<typename iterator_traits<Iterator>::iterator_category>>
: detail::iterator_category_to_system<typename iterator_traits<Iterator>::iterator_category>
{};

Expand Down
1 change: 0 additions & 1 deletion thrust/thrust/iterator/iterator_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
# pragma system_header
#endif // no system header
#include <thrust/type_traits/void_t.h>

#include <iterator>

Expand Down
Loading
Loading