-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Description
A single pass range often can be consumed only once which implies mutability and negates constness, on the first consumption it becomes empty. SinglePassRangeConcept asserts const_constraints which is a requirement that cannot be met by many or most single pass ranges.
I will demonstrate using a boost coroutine with a range adaptor:
#include <boost/range/adaptor/transformed.hpp>
#include <boost/coroutine2/coroutine.hpp>
using boost::adaptors::transformed;
using boost::coroutines2::coroutine;
int main() {
using generator = coroutine<int>;
generator::pull_type g([](auto &yield) {
for (int i = 0; i < 10; i++) {
yield(i);
}
});
for (auto i: g | transformed([](int i) { return i + 10; })) {
}
return 0;
}This code snippet does not compile because SinglePassRangeConcept asserts const_constraints which boost coroutine does not satisfy.
I propose to drop the const requirement for SinglePassRangeConcept because in simple terms, a single pass range isn't required to have a const iterator.
Metadata
Metadata
Assignees
Labels
No labels