Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-11-02 03:44:46


David Abrahams wrote:
> Pavol Droba <droba_at_[hidden]> writes:
> > Is "iterator_range" ok, or should it be renamed to "range"?
> > There is a set of support utilities, which has currently names like
> > make_range, copy_range and etc.
> > Either these functions are renamed to make_iterator_range (and etc.),
> > or the class will have to be renamed to "range".
> >
> > My question to public is: What is prefered solution?
>
> It should only be called "range" if it's meant to work on ranges of
> non-iterators.

Yep. In particular, a general purpose range wouldn't necessarily have
'begin'/'end' (for instance, ours here at work doesn't), and if it would,
they would do quite a different thing.

> But then, you should call it half_open_range ;-)

Not necessarily :). Here's what we have:

    template< typename Tag >
    struct range_traits
    {
        template< typename Range > static typename Range::value_type
size(Range const&);
        template< typename Range > static typename Range::value_type
front(Range const&);
        template< typename Range > static typename Range::value_type
back(Range const&);
    };

    namespace tag {
    struct half_open;
    struct closed;
    }

    template< typename T, typename Tag = tag::half_open >
    struct range
    {
        // use range_traits<Tag> to implement variability aspects of open,
        // half-open and closed ranges
        // ...
    };

Aleksey


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