|
Boost : |
From: Greg Colvin (gcolvin_at_[hidden])
Date: 1999-08-17 11:50:45
From: Valentin Bonnard <Bonnard.V_at_[hidden]>
> A priori, writing a skiping iterator seems trivial:
>
> template <typename It, typename Predicate>
> class SkipingIterator {
> mutable It pos;
> Predicate pred;
>
> void skip () const
> { while (pred (*pos)) ++pos; }
>
> public:
> value_type& operator* () const
> { skip (); return *pos; }
>
> void operator++ ()
> { skip(); ++pos; }
> };
>
> Except that the semantic near the end is ugly (the precondition
> is that there are non skiped elements before the end).
I think the precondition is just that pred(*last) is false.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk