Boost logo

Boost :

From: David A. Greene (greened_at_[hidden])
Date: 2002-11-05 15:02:22


I've been playing with iterator_adaptors lately -- great work
by all involved. I do have a question about the mechanics
of the library, though.

In the iterator_adaptor class we have this member (simplified
by removing Metrowerks special cases):

    self& operator--() {
         return *this;

We then have the filter_iterator policies that look like this:

template <class Predicate, class Iterator>
class filter_iterator_policies
     template <class IteratorAdaptor>
     void increment(IteratorAdaptor& x) {

     template <class IteratorAdaptor>
     typename IteratorAdaptor::reference
     dereference(const IteratorAdaptor& x) const
         { return *x.base(); }

     template <class IteratorAdaptor1, class IteratorAdaptor2>
     bool equal(const IteratorAdaptor1& x, const IteratorAdaptor2& y)
         { return x.base() == y.base(); }

     void satisfy_predicate(Iterator& iter);
     Predicate m_predicate;
     Iterator m_end;

Nowhere is "decrement" declared or defined in the filter_iterator
policies yet it can still be used with iterator_adaptor. How
does this work? Shouldn't the compiler complain that
iterator_adaptor::operator--() can't find
filter_iterator_policies::decrement? I could understand if
operator-- were a template member but it's not. I'm obviously
missing something. What is it?


"Some little people have music in them, but Fats, he was all music,
  and you know how big he was."  --  James P. Johnson

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