Boost logo

Boost :

Subject: Re: [boost] AlRangeExandrescu?
From: Andrei Alexandrescu (andrei_at_[hidden])
Date: 2009-07-23 12:04:45


Mathias Gaunard wrote:
> David Abrahams wrote:
>> Hi Neil,
>>
>> I'm sure someone already spoke to you about this, but just in case:
>> Andrei Alexandrescu gave a very interesting presentation at BoostCon
>> that was based on a "ranges only" approach that should eliminate
>> issues like this one:
>>
>> 2: return type specification for find() etc
>> ===========================================
>> There where no major objection to the mechanism, but some found
>> the syntax ugly. I believe the suggested syntax (e.g.)
>>
>> boost::find[_f,_e]( range, x )
>>
>> boost::find[_f+1,_e]( range, x )
>>
>>
>> He says he's implemented a superset of the STL algorithms with it so
>> we know the expressive power is fairly complete. I was wondering if
>> you had given any thought to making use of his insights? Especially
>> considering that RangeEx hasn't been used to fully cover a generic
>> domain (I think), it might make sense.
>
> First-class ranges would still need to be convertible to iterator pairs,
> since iterators are useful on their own as a mean to express positions.

That would limit ranges because there are ranges that are not pairs of
iterators.

> For example, let's say I write a simple algorithm that takes three
> bidirectional iterators: the begin of the sequence, the end of the
> sequence, and a position anywhere in between.
> That algorithm then returns whether the position in between lies on a
> word boundary by reading what is left and right of it.
>
> How would I express such an algorithm with ranges only?

You would pass two adjacent ranges, like D's bringToFront (a
generalization of STL's rotate, see
http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html) takes.

Andrei


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