Iterators: distance versus operator- argument types.

Ian Lance Taylor
Wed Aug 25 12:42:00 GMT 2010

rgamarra <> writes:

> To check and see what's going on, I did
> g++ -E
> , got the full sources and modified the operator- by adding (with the
> proper #include <typeinfo>)

The operator- you mentioned before is the one for normal_iterator.  You
can see that it just calls operator- again on the base class.

The standard (at least, DR179) requires that operator- accept a
combination of iterator and const_iterator.  Since this version of
operator- is just going to call operator- again, it needs to accept
different types in the template.


More information about the Gcc-help mailing list