boostorg / range

Boost.org range module
http://boost.org/libs/range
43 stars 101 forks source link

irange with a step is not random access #134

Open dvirtz opened 2 years ago

dvirtz commented 2 years ago

The docs say that irange produces a random access range but that's not true for the strided version.

The following code fails to compile:

BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<decltype(boost::irange(0, 10))> ));
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<decltype(boost::irange(0, 10, 1))> )); // fails here

See https://gcc.godbolt.org/z/n4hqjj5bf

The reason is that random access (in fact, even forward) concept requires the iterator to be default constructible which integer_iterator_with_step is not.