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

Commit

Permalink
Use reference to force value conversion.
Browse files Browse the repository at this point in the history
Previously, the transform_iterator implementation would make a copy
of the adapted iterators value when dereferencing it in order to
force conversion to the value_type. This prevented transform_iterators
over non-copyable types. Using a reference instead allows for forcing
the conversion without invoking a copy ctor.
  • Loading branch information
jrhemstad committed May 5, 2021
1 parent fa54f2c commit 2860ca3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion thrust/iterator/transform_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ template <class AdaptableUnaryFunction, class Iterator, class Reference = use_de
// Create a temporary to allow iterators with wrapped references to
// convert to their value type before calling m_f. Note that this
// disallows non-constant operations through m_f.
typename thrust::iterator_value<Iterator>::type x = *this->base();
typename thrust::iterator_value<Iterator>::type const& x = *this->base();
return m_f(x);
}

Expand Down

0 comments on commit 2860ca3

Please sign in to comment.