Skip to content
Merged
Changes from 1 commit
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
30 changes: 2 additions & 28 deletions thrust/thrust/zip_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
#endif // no system header

#include <thrust/detail/type_deduction.h>
#include <thrust/tuple.h>
#include <thrust/type_traits/integer_sequence.h>

#include <cuda/functional>
#include <cuda/std/tuple>

THRUST_NAMESPACE_BEGIN

Expand All @@ -34,29 +33,6 @@ THRUST_NAMESPACE_BEGIN
* \{
*/

namespace detail
{
namespace zip_detail
{

// Add workaround for decltype(auto) on C++11-only compilers:
_CCCL_EXEC_CHECK_DISABLE
template <typename Function, typename Tuple, std::size_t... Is>
_CCCL_HOST_DEVICE decltype(auto) apply_impl(Function&& func, Tuple&& args, index_sequence<Is...>)
{
return func(thrust::get<Is>(THRUST_FWD(args))...);
}

template <typename Function, typename Tuple>
_CCCL_HOST_DEVICE decltype(auto) apply(Function&& func, Tuple&& args)
{
constexpr auto tuple_size = thrust::tuple_size<::cuda::std::decay_t<Tuple>>::value;
return apply_impl(THRUST_FWD(func), THRUST_FWD(args), make_index_sequence<tuple_size>{});
}

} // namespace zip_detail
} // namespace detail

/*! \p zip_function is a function object that allows the easy use of N-ary
* function objects with \p zip_iterators without redefining them to take a
* \p tuple instead of N arguments.
Expand Down Expand Up @@ -129,12 +105,10 @@ class zip_function
: func(::cuda::std::move(func))
{}

// Add workaround for decltype(auto) on C++11-only compilers:

template <typename Tuple>
_CCCL_HOST_DEVICE decltype(auto) operator()(Tuple&& args) const
{
return detail::zip_detail::apply(func, THRUST_FWD(args));
return ::cuda::std::apply(func, ::cuda::std::forward<Tuple>(args));
}

//! Returns a reference to the underlying function.
Expand Down
Loading