Skip to content

Commit 2860ca3

Browse files
committed
Use reference to force value conversion.
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.
1 parent fa54f2c commit 2860ca3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

thrust/iterator/transform_iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ template <class AdaptableUnaryFunction, class Iterator, class Reference = use_de
312312
// Create a temporary to allow iterators with wrapped references to
313313
// convert to their value type before calling m_f. Note that this
314314
// disallows non-constant operations through m_f.
315-
typename thrust::iterator_value<Iterator>::type x = *this->base();
315+
typename thrust::iterator_value<Iterator>::type const& x = *this->base();
316316
return m_f(x);
317317
}
318318

0 commit comments

Comments
 (0)