Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #851: properly dereference a strided_iterator #852

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/compute/iterator/strided_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class strided_iterator :

reference dereference() const
{
return reference();
return *super_type::base_reference();
}

bool equal(const strided_iterator<Iterator> &other) const
Expand Down
7 changes: 7 additions & 0 deletions test/test_strided_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down