Boost logo

Boost :

From: Brian McNamara (lorgon_at_[hidden])
Date: 2003-11-19 21:12:15

On Thu, Nov 20, 2003 at 09:48:34AM -0800, John Torjo wrote:
> >You may be interested to read
> >
> >
> >
> Yup, read it.
> As a matter of fact, the range thing has been on my mind for quite a few
> years as well.
> The crange class is (a little better) interval ;)
> However, I donot think that algorithms should operate on intervals, because
> usually this makes harder for them to work.

The way I see it, an "interval" or "range" or whatever is just an
abstraction for a pair of iterators. You can have "range categories"
just like "iterator categories", so that algorithms can take advantage
of the specific propoerties of iterators/ranges. (E.g., some intervals
may support random access, whereas other might not.)

The main advantage to "intervals" over "iterators" is that I am not
constantly harassed into having to carry two separate objects around all
the time: instead I just carry one. It is tiring to deal with
interfaces which appear to have been designed with no attention to the
common case. Sure,

   std::sort( v.begin(), v.begin()+5 );

is more expressive, as it lets me just sort the first 5 elements.
But 99% of the time, I just want to sort the whole darn thing, and I
hate having to write

   std::sort( v.begin(), v.end() );

instead of

   std::sort( v.interval() );
or just

   std::sort( v );

But anyway, I am just whining/opining. I have not paid much attention
to the specifics of your (or anyone's) designs to address this issue,
but I have great confidence that you-all will create high-quality
libraries along these lines to provide the convenience I desire. :)

-Brian McNamara (lorgon_at_[hidden])

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