I'm trying to implement cycling iterator, which is quite useful in my problem. According to this thread, I'm using boost::iterator_adaptor for this purpose, and iterator itself works fine. Implementation is much like in this answer.
However, there is some problem when operating both cycle_iterator and "native" IteratorBase in the same sentence, like this:
vector<int> v;
vector<int>::iterator it = v.begin();
cyclic_iterator<vector<int>::iterator> cit(v.begin(), v.end());
if (cit != it) // Don't compile
{
...
}
Compiler generates error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'cyclic_iterator' (or there is no acceptable conversion).
I can resolve it explicitly specifying operator!= in cyclic_iterator for IteratorBase. However, I need to explicitly overload operator==, operator= and so on.
Is there some more convenient way to make this stuff work?