diff --git a/include/boost/compute/iterator/strided_iterator.hpp b/include/boost/compute/iterator/strided_iterator.hpp index bb695c8c5..7a629a4ef 100644 --- a/include/boost/compute/iterator/strided_iterator.hpp +++ b/include/boost/compute/iterator/strided_iterator.hpp @@ -184,7 +184,7 @@ class strided_iterator : reference dereference() const { - return reference(); + return *super_type::base_reference(); } bool equal(const strided_iterator &other) const diff --git a/test/test_strided_iterator.cpp b/test/test_strided_iterator.cpp index e05e8b2ee..e932757d4 100644 --- a/test/test_strided_iterator.cpp +++ b/test/test_strided_iterator.cpp @@ -113,6 +113,13 @@ BOOST_AUTO_TEST_CASE(copy) CHECK_RANGE_EQUAL(boost::compute::int_, 3, result, (1, 4, 7)); } +BOOST_AUTO_TEST_CASE(dereference) +{ + boost::compute::int_ data[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; + auto it = boost::compute::make_strided_iterator(data, 3); + BOOST_CHECK_EQUAL(*it, 1); +} + BOOST_AUTO_TEST_CASE(make_strided_iterator_end) { boost::compute::int_ data[] = { 1, 2, 3, 4, 5, 6, 7, 8 };