$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: William Kempf (sirwillard_at_[hidden])
Date: 2000-09-13 15:10:08
--- In boost_at_[hidden], "David Abrahams" <abrahams_at_m...> wrote:
> That (layerd iterator) is interesting. I wonder how that might 
interact with
> iterator_adaptor?
> 
> 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.
> 
> -Dave
> 
> template <class T>
> class Range : public std::pair<T, T>
> {
>     typedef std::pair<T, T> Base;
>  public:
>     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);
> }
Why is this derived from pair?  You aren't using it polymorphically 
(and in fact it has a hole in the design since the destructor isn't 
virtual).  I also don't understand how this really buys you much, 
beyond limiting the template parameters to a single type, which 
doesn't matter much if you use the make_pair helper function.
Bill Kempf