Boost logo

Boost :

Subject: Re: [boost] AlRangeExandrescu?
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-07-28 11:44:44


Andrei Alexandrescu skrev:
> Thorsten Ottosen wrote:
>> Stewart, Robert skrev:
>>> Steven Watanabe wrote:
>>
>>>>> How about another try: traversing a range with changing criteria?
>>>>> A particular range class can take a predicate or some other
>>>>> traversal influencing argument that can change with each
>>>>> advance. How would you express that with iterator pairs?
>>>> Easily. First of all, consider what's possible if the two iterators
>>>> are allowed to be different types. Then all the actual state can
>>>> be put in the first iterator and comparison to the second iterator
>>>> can just check whether the range is empty. Once you have that,
>>>> you can use boost::variant to store both iterators as the same type.
>>>> This will not be efficient, but it will work.
>>>
>>> That may well work, but the range version would certainly be more
>>> straightforward and,
>> >as you noted, efficient. Of course, once you permit the iterators
>> to have different types,
>> >you also increase the opportunity for mixing them incorrectly, which
>> won't happen with an Alexandrescu range.
>>
>> I think we all agree that Alexandrescu ranges are conceptually simpler
>> to implement and specify; however, from a user perspective the two
>> approaches should be be similar.
>
> Well ranges seem to make functional composition easier because one
> object represents what you need, not two.

By the other approach I meant what Boost.Range and RangeEx is offering.
Not the iterator approach.

-Thorsten


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk