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

Commit

Permalink
Revert "Use placeholder expressions"
Browse files Browse the repository at this point in the history
This reverts commit f483906.

See discussion in #1229.

Bug 3043659
  • Loading branch information
alliepiper committed Jul 14, 2020
1 parent 587219b commit c3c368a
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 26 deletions.
4 changes: 1 addition & 3 deletions thrust/system/cuda/detail/find.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,10 @@ find(execution_policy<Derived> &policy,
InputIt last,
T const& value)
{
using thrust::placeholders::_1;

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


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

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

// copy
Expand Down
4 changes: 1 addition & 3 deletions thrust/system/cuda/detail/replace.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,12 @@ 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),
_1 == old_value);
thrust::detail::equal_to_value<T>(old_value));
}

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

return thrust::find_if(exec, first, last, _1 == value);
// XXX consider a placeholder expression here
return thrust::find_if(exec, first, last, thrust::detail::equal_to_value<T>(value));
} // end find()


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

return thrust::mismatch(exec, first1, last1, first2, _1 == _2);
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>());
} // end mismatch()


Expand Down
12 changes: 5 additions & 7 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,9 +124,8 @@ __host__ __device__
const T &old_value,
const T &new_value)
{
using thrust::placeholders::_1;

return thrust::replace_copy_if(exec, first, last, result, _1 == old_value, new_value);
thrust::detail::equal_to_value<T> pred(old_value);
return thrust::replace_copy_if(exec, first, last, result, pred, new_value);
} // end replace_copy()


Expand Down Expand Up @@ -165,9 +164,8 @@ __host__ __device__
const T &old_value,
const T &new_value)
{
using thrust::placeholders::_1;

return thrust::replace_if(exec, first, last, _1 == old_value, new_value);
thrust::detail::equal_to_value<T> pred(old_value);
return thrust::replace_if(exec, first, last, pred, new_value);
} // end replace()


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

#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 @@ -28,6 +27,30 @@ 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 @@ -61,9 +84,8 @@ __host__ __device__
T init,
T step)
{
using thrust::placeholders::_1;

thrust::tabulate(exec, first, last, init + step * _1);
// XXX TODO use a placeholder expression here
thrust::tabulate(exec, first, last, sequence_detail::sequence_functor<T>(init, step));
} // end sequence()


Expand Down

0 comments on commit c3c368a

Please sign in to comment.