Boost logo

Boost Users :

Subject: [Boost-users] [iterator] lazy container
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-06-23 00:47:35


Hi,

I am implementing a lazy container/iterator that represents the
results of certain iterative algorithm.

I have a class (call it solver) that should look like an interator.
First I was using boost.operators to make it look like a pointer but
then I found boost.Iterator. Because of the nature of the algorithm it
can be only traversed forward. I am using it in this way:

class solver :
        //public boost::dereferenceable<solver, result const*>, //replaced
with boost::iterator
        public boost::iterator_facade<solver, result const,
boost::forward_traversal_tag, result const /*noref*/ >{
...
        result dereference() const{ //was result operator*() const
          ...
        }
        void increment() {...} //was operator++
}

note that tipically the last argument is intended to be a reference
but in this case, since there in no underlying data the return can't
be a reference but a new element generated by the algorithm.

Question: is this the intended use of boost::iterator_facade is there
an alternative base class for lazy operators?

Thank you,
Alfredo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net