Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-09-13 16:15:30


----- Original Message -----
From: <jsiek_at_[hidden]>

>
> Another approach is the begin(container), end(container) interface
> that is in array_traits. Then you don't really need the Range
> class... just use std::pair and have a range() function that returns a
> pair.
>

I don't think that really solves the problems I'm addressing, specifically:

    range<std::map<std::pair<int, int>, const char*>::iterator>

is much nicer to read/write than

    std::pair<std::map<std::pair<int, int>, const char*>::iterator,
std::map<std::pair<int, int>, const char*>::iterator>

And furthermore, it expresses the intention better. Also, ranges (when you
know you have them) admit all kinds of functionality not admitted by a pair,
for example:

    range<T> r(t1, t2); // assert distance(t1, t2) > 0!
    r |= t3; // extend r to include t3 as well
    r.contains(t4)
    range<T> r2 = r | r1; // r2 covers everything in r and r1

etc...

    Finally, ranges are useful for numbers as well as iterators.

-Dave

P.S. I realize there are issues with ranges of non-random-access iterators.
I think they can be solved.


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