Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Use placeholder expressions #1186

Merged
merged 1 commit into from
Jul 3, 2020
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
4 changes: 3 additions & 1 deletion thrust/system/cuda/detail/find.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ find(execution_policy<Derived> &policy,
InputIt last,
T const& value)
{
using thrust::placeholders::_1;

return cuda_cub::find_if(policy,
first,
last,
thrust::detail::equal_to_value<T>(value));
_1 == value);
}


Expand Down
5 changes: 3 additions & 2 deletions thrust/system/cuda/detail/remove.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ remove(execution_policy<Derived> &policy,
InputIt last,
const T & value)
{
thrust::detail::equal_to_value<T> pred(value);
return cuda_cub::remove_if(policy, first, last, pred);
using thrust::placeholders::_1;

return cuda_cub::remove_if(policy, first, last, _1 == value);
}

// copy
Expand Down
4 changes: 3 additions & 1 deletion thrust/system/cuda/detail/replace.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ replace(execution_policy<Derived> &policy,
T const & old_value,
T const & new_value)
{
using thrust::placeholders::_1;

cuda_cub::transform_if(policy,
first,
last,
first,
__replace::constant_f<T>(new_value),
thrust::detail::equal_to_value<T>(old_value));
_1 == old_value);
}

template <class Derived,
Expand Down
5 changes: 3 additions & 2 deletions thrust/system/detail/generic/find.inl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ InputIterator find(thrust::execution_policy<DerivedPolicy> &exec,
InputIterator last,
const T& value)
{
// XXX consider a placeholder expression here
return thrust::find_if(exec, first, last, thrust::detail::equal_to_value<T>(value));
using thrust::placeholders::_1;

return thrust::find_if(exec, first, last, _1 == value);
} // end find()


Expand Down
7 changes: 3 additions & 4 deletions thrust/system/detail/generic/mismatch.inl
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ __host__ __device__
InputIterator1 last1,
InputIterator2 first2)
{
typedef typename thrust::iterator_value<InputIterator1>::type InputType1;

// XXX use a placeholder expression here
return thrust::mismatch(exec, first1, last1, first2, thrust::detail::equal_to<InputType1>());
using namespace thrust::placeholders;

return thrust::mismatch(exec, first1, last1, first2, _1 == _2);
} // end mismatch()


Expand Down
12 changes: 7 additions & 5 deletions thrust/system/detail/generic/replace.inl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

#include <thrust/detail/config.h>
#include <thrust/functional.h>
#include <thrust/system/detail/generic/replace.h>
#include <thrust/transform.h>
#include <thrust/replace.h>
#include <thrust/detail/internal_functional.h>

namespace thrust
{
Expand Down Expand Up @@ -124,8 +124,9 @@ __host__ __device__
const T &old_value,
const T &new_value)
{
thrust::detail::equal_to_value<T> pred(old_value);
return thrust::replace_copy_if(exec, first, last, result, pred, new_value);
using thrust::placeholders::_1;

return thrust::replace_copy_if(exec, first, last, result, _1 == old_value, new_value);
} // end replace_copy()


Expand Down Expand Up @@ -164,8 +165,9 @@ __host__ __device__
const T &old_value,
const T &new_value)
{
thrust::detail::equal_to_value<T> pred(old_value);
return thrust::replace_if(exec, first, last, pred, new_value);
using thrust::placeholders::_1;

return thrust::replace_if(exec, first, last, _1 == old_value, new_value);
} // end replace()


Expand Down
30 changes: 4 additions & 26 deletions thrust/system/detail/generic/sequence.inl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include <thrust/detail/config.h>
#include <thrust/functional.h>
#include <thrust/system/detail/generic/sequence.h>
#include <thrust/iterator/iterator_traits.h>
#include <thrust/tabulate.h>
Expand All @@ -27,30 +28,6 @@ namespace detail
{
namespace generic
{
namespace sequence_detail
{


template<typename T>
struct sequence_functor
{
T init, step;

__host__ __device__
sequence_functor(T init, T step)
: init(init), step(step)
{}

template<typename Index>
__host__ __device__
T operator()(Index i) const
{
return static_cast<T>(init + step * i);
}
};


} // end sequence_detail


template<typename DerivedPolicy, typename ForwardIterator>
Expand Down Expand Up @@ -84,8 +61,9 @@ __host__ __device__
T init,
T step)
{
// XXX TODO use a placeholder expression here
thrust::tabulate(exec, first, last, sequence_detail::sequence_functor<T>(init, step));
using thrust::placeholders::_1;

thrust::tabulate(exec, first, last, init + step * _1);
} // end sequence()


Expand Down