Subject: Re: [boost] [coroutine] interface suggestion
From: Eugene Yakubovich (eyakubovich_at_[hidden])
Date: 2012-09-20 13:42:26
On Wed, Sep 19, 2012 at 1:48 PM, Vicente J. Botet Escriba
> Le 19/09/12 09:30, Oliver Kowalke a écrit :
>> 10. generator<> is not a range because
>> - 'A Range provides iterators for accessing a half-open range
>> [first,one_past_last) of elements and provides information
>> about the number of elements in the Range.'
>> -> a generator can not determine how many elements it will return
> I don't see why a range knows about the number of elements !!!
>> - generator<> can only provide a single pass:
>> 'For any Range a, [boost::begin(a),boost::end(a)) is a valid range,
>> that is, boost::end(a) is reachable from boost::begin(a) in a
>> finite number of increments.'
> You are right, and so any finite generator doesn't violates the range
> invariant. Maybe the range requirements could be relaxed or a distinction
> between finite/bounded and infinite/unbounded could be added.
While a generator might not terminate (infinite loop), neither might
standard input. Yet Boost.Range has istream_range. We can also say
that generator<> only satisfies a range concept if it terminates in a
finite number of steps. Now, this not something we can check or infer
from the type but the same can be said about any iterator pair. It's
the user's responsibility to construct a range (for example using
iterator_range class) out of only those iterators that are finite in
I think not having generators work with ranges would be a
disappointment since many, many generators are finite.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk