Boost logo

Boost :

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

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.

I don't see how having a different type for the end iterator could make
incorrect usage easier; for of all we still want to work on ranges as
much as possible, and second the type should be uniquely defined for
each iterator type such that any misuse is detected at compile time.


Boost list run by bdawes at, gregod at, cpdaniel at, john at