AnyIterator and iterator facade enhancement

Is it possible to implement any iterator with an iterator accelerator facade? I do not want to define implementation details in my base class

class Base
{
public:
typedef std::vector<int>::iterator iterator;//implementation detail
...
virtual iterator begin()=0;
virtual iterator end()=0;
};

or do I need to write completely from scratch;

+5
source share
2 answers

The code you posted has fixed the type of iterators returned from Base, and all of its implementations up to std::vector<int>::iterator, which are probably not what you want. Jeremiah's suggestion is one way to go with one drawback: you lose compatibility with STL ... I know three implementations of the polymorphic shell of the iterator:

  • becker any_iterator(which implements boost::iterator_facade)
  • library opaque_iterator(google for her) or
  • Adobe , STL, any_iterator s.

, ... , any_iterators (any_iterator<Derived> any_iterator<Base>), STL . #, Enumerator<T>, (*) ( imho , STL- ), "" STL.

(*) = "", : -)

+9

, , :

any_iterator: Erasure ++

::

any_iterator boost:: . , .

+3

All Articles