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
    range<T> r2 = r | r1; // r2 covers everything in r and r1


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


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, gregod at, cpdaniel at, john at