Skip to content

Commit a873317

Browse files
committed
Fix boostorg#851: properly dereference a strided_iterator
1 parent 36c8913 commit a873317

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

include/boost/compute/iterator/strided_iterator.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class strided_iterator :
184184

185185
reference dereference() const
186186
{
187-
return reference();
187+
return *super_type::base_reference();
188188
}
189189

190190
bool equal(const strided_iterator<Iterator> &other) const

test/test_strided_iterator.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ BOOST_AUTO_TEST_CASE(copy)
113113
CHECK_RANGE_EQUAL(boost::compute::int_, 3, result, (1, 4, 7));
114114
}
115115

116+
BOOST_AUTO_TEST_CASE(dereference)
117+
{
118+
boost::compute::int_ data[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
119+
auto it = boost::compute::make_strided_iterator(data, 3);
120+
BOOST_CHECK_EQUAL(*it, 1);
121+
}
122+
116123
BOOST_AUTO_TEST_CASE(make_strided_iterator_end)
117124
{
118125
boost::compute::int_ data[] = { 1, 2, 3, 4, 5, 6, 7, 8 };

0 commit comments

Comments
 (0)