UoB-HPC / BabelStream

STREAM, for lots of devices written in many programming models
Other
313 stars 109 forks source link

std-indices: Use forward iterator tag to align with the implemented operators #157

Closed illuhad closed 9 months ago

illuhad commented 12 months ago

The current implementation of ranged in std-indices exposes an iterator class as random access iterator using the corresponding iterator tag, but does not define all the operators that would be needed for a random access iterator. In particular, operators to decrement (or subtract) are missing.

This causes important iterator-related STL functions to fail, such as std::advance(). https://godbolt.org/z/Go5ojEP7f

The issue can be fixed either by implementing the missing operators, or exposing the iterator as something that matches better the implemented functionality, such as a forward iterator.

It's not clear to me which approach is the right one - this PR changes the tag to a forward iterator, since this seemed like the easiest way to fix the issue, and is a one-line change.