Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2008-08-30 20:24:06


on Sat Aug 30 2008, Steven Watanabe <watanabesj-AT-gmail.com> wrote:

> How would this work:
>
>
> template<IteratorWithEnd Iterator, class F>
> class filter_iterator<Iterator, F>
> {
> public:
> //...
> filter_iterator(Iterator begin, Iterator end, F f)
> : iter(set_end(begin,end)), f(f)
> {}
>
> filter_iterator& operator++() {
> ++iter;
> while(iter != get_end(iter) && !f(*iter)) ++iter;
> return *this;
> }
>
> friend Iterator get_end(const filter_iterator& self) {
> return
> filter_iterator(
> get_end(self.iter), get_end(self.iter), self.f);
> }
>
> friend Iterator set_end(
> const filter_iterator& self, const filter_iterator& other)
> {
> return filter_iterator(self.iter, get_end(other.iter), f);
> }
>
> private:
> Iterator iter;
> F f;
> };

Hi Steven,

Say for example Iterator is strided_iterator<int>. Then the return type
of set_end above is strided_iterator<int>, right? So how will its body
typecheck? Seems like this needs a little more thought.

PS: I suggest you use more linebreaks, at least in your postings; code
with linebreaks inserted by mailers is even harder to read than code
with too few linebreaks ;-)

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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