|
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
of
> 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
might
> > end up stuck in a design that cannot exploit the flexibility of the
range
> > abstraction.
>
> How? If you can write '(c)', then you can always write '(c.begin(),
c.end())'
> as long as 'c' is a container. I don't see how support for '(c)' could
ever
> 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
that
> has a container-like interface (has begin() and end()), but refers to the
> elements of the container differently. In particular, I'm thinking about
the
> functions 'drop', 'take' and 'filter' (but there are many more, such as
'rev')
> that you can find in many functional languages.
Yes, see also the View Template Library (VTL) http://www.zib.de/weiser/vtl/
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk