Skip to content

Commit

Permalink
Default transform_iterator's copy ctor (#3395)
Browse files Browse the repository at this point in the history
Fixes: #2393
  • Loading branch information
bernhardmgruber authored Jan 21, 2025
1 parent e556a83 commit 8da3ace
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
2 changes: 1 addition & 1 deletion cub/test/catch2_large_array_sort_helper.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ template <typename KeyType>
class key_sort_ref_key_transform
{
static constexpr double max_key = static_cast<double>(::cuda::std::numeric_limits<KeyType>::max());
const double m_conversion;
double m_conversion;
std::size_t m_num_items;
bool m_is_descending;

Expand Down
35 changes: 1 addition & 34 deletions thrust/thrust/iterator/transform_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ class transform_iterator
/*! \endcond
*/

public:
/*! Null constructor does nothing.
*/
transform_iterator() = default;
Expand Down Expand Up @@ -239,20 +238,7 @@ class transform_iterator
, m_f(other.functor())
{}

/*! Copy assignment operator copies from another \p transform_iterator.
* \p other The other \p transform_iterator to copy
* \return <tt>*this</tt>
*
* \note If the type of this \p transform_iterator's functor is not copy assignable
* (for example, if it is a lambda) it is not an error to call this function.
* In this case, however, the functor will not be modified.
*
* In any case, this \p transform_iterator's underlying iterator will be copy assigned.
*/
_CCCL_HOST_DEVICE transform_iterator& operator=(const transform_iterator& other)
{
return do_assign(other, ::cuda::std::is_copy_assignable<AdaptableUnaryFunction>());
}
transform_iterator& operator=(const transform_iterator&) = default;

/*! This method returns a copy of this \p transform_iterator's \c AdaptableUnaryFunction.
* \return A copy of this \p transform_iterator's \c AdaptableUnaryFunction.
Expand All @@ -266,25 +252,6 @@ class transform_iterator
*/

private:
_CCCL_HOST_DEVICE transform_iterator& do_assign(const transform_iterator& other, thrust::detail::true_type)
{
super_t::operator=(other);

// do assign to m_f
m_f = other.functor();

return *this;
}

_CCCL_HOST_DEVICE transform_iterator& do_assign(const transform_iterator& other, thrust::detail::false_type)
{
super_t::operator=(other);

// don't assign to m_f

return *this;
}

// MSVC 2013 and 2015 incorrectly warning about returning a reference to
// a local/temporary here.
// See goo.gl/LELTNp
Expand Down

0 comments on commit 8da3ace

Please sign in to comment.