Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-09-13 13:57:10

That (layerd iterator) is interesting. I wonder how that might interact with

Also, I've been thinking how unweildy it is to write std::pair<T, T> for
ranges, and how much expressive power is lost by writing "pair" instead of
"range". Instead, I've been using the appended Range<> template (not
boost-ified), which I derived from std::pair for some compatibility with
existing uses of pair as a range. What's really missing from this class are
all the operations for union, intersection, containment, etc. I've
implemented these before, but that code is owned by a previous employer ;(.

Does anyone else think this would be really useful? It might be worth
fleshing out, if so.


template <class T>
class Range : public std::pair<T, T>
    typedef std::pair<T, T> Base;
    Range() {}

    explicit Range(const T& x)
        : Base(x, x) {}

    Range(const T& start, const T& finish)
        : Base(start, finish) {}

    T begin() const;
    T end() const;

template <class T>
inline T Range<T>::begin() const
    return this->first;

template <class T>
inline T Range<T>::end() const
    return this->second;

template <class T>
inline Range<T> make_range(const T& start, const T& finish)
    return Range<T>(start, finish);

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