Hi!
Is someone responsible for iterator_facade? Would be great if I'd be able to clarify this with one of the authors...

Many thanks,
Ovanes

On Wed, Aug 17, 2011 at 2:58 PM, Ovanes Markarian <om_boost@keywallet.com> wrote:
Hello *!

I defined a custom bidi-iterator and assumed it was going to support std::advance(iterator, Difference n), where n can be negative for random access and bidirectional iterators.

The definition of my iterator's facade base looks like:
struct my_iter 
  : boost::iterator_facade
      < my_iter
      , const byte
      , boost::bidirectional_traversal_tag 
      , const byte
      >
{

// some impl stuff follows...
};


My tests show that calling:
advance(instance_of_my_iter, N) works fine (increment implementation is called)

advance(instance_of_my_iter, -N) does not work, because increment (instead of decrement) is called as well

While reading through the docs for iterator facade at http://www.boost.org/doc/libs/1_46_0/libs/iterator/doc/iterator_facade.html I found the section iterator_facade Core Operations.

For the advance implementation is stated there that it is only gets called for Random Access Iterators. C++ Standard clearly defines that N-Parameter to std::advance can be negative to random access and bidi iterators. Implementing void advance member in my_iter still results in the call to increment member. Can someone give me any suggestions or is it a bug in the iterator lib?

My compiler is gcc 4.3 under Debian Linux with Kernal 2.6.26. and Boost 1.42.


With Kind Regards,
Ovanes