Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-07-25 16:00:20

----- Original Message -----
From: "Vesa Karvonen" <vesa.karvonen_at_[hidden]>

> In fact, you don't need a "range interface", which I assume means a pair
> iterators, to separate enumeration from containment. A single object is
> sufficient for describing a range.

And there is a boost/half_open_range.hpp file which has been in-progress for
some time in your latest boost release. If someone would like to take up the
job of finishing it, I'm sure it would be widely appreciated.

> The reason why C++ uses a pair of iterators
> is due to the legacy pointer syntax.
> > IMHO, the decision to shortcut from (c.begin(),c.end()) to (c) should be
> > done consciously, not as the default practice; otherwise, a program
> > end up stuck in a design that cannot exploit the flexibility of the
> > abstraction.
> How? If you can write '(c)', then you can always write '(c.begin(),
> as long as 'c' is a container. I don't see how support for '(c)' could
> prevent using '(c.begin(), c.end())'.

I think the poster is referring to the possibility of using subranges of a
container. Of course you can always construct a range object from a couple
of iterators.

> As related issue, it is possible to write functions that return an object
> has a container-like interface (has begin() and end()), but refers to the
> elements of the container differently. In particular, I'm thinking about
> functions 'drop', 'take' and 'filter' (but there are many more, such as
> that you can find in many functional languages.

Yes, see also the View Template Library (VTL)


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