Boost logo

Boost :

From: brangdon_at_[hidden]
Date: 2001-11-04 16:29:11


In-Reply-To: <0d4c01c163ee$0adb6040$eb840380_at_[hidden]>
On Fri, 2 Nov 2001 17:30:06 -0500 David Abrahams (david.abrahams_at_[hidden])
> In that spirit, I think talking about iterator ranges misses a
> significant opportunity for generalization. My half_open_range
> works with integer types as well as iterators. I'm not sure
> there's anything special about iterator ranges as opposed to ranges
> of other things.

Can you give an integer example which does not work with my suggested
concept? I am wondering if we are trying to do different things. Whether a
range is specified as half open or fully open or fully closed, is for me
an implementation detail, or perhaps a detail of how a sequence is
specified or created; it shouldn't effect how the sequence is used.

I see an input sequence as something for which we can get the current
item, advance to the next, and tell whether there are any items left.
Surely this applies to integers?

    class odds {
        int current_;
    public:
        odds() : current(1) {}
        int current() const { return current_; }
        bool at_end() const { return false; }
        void advance() { current_ += 2; }
    };

-- Dave Harris


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