Iterators: distance versus operator- argument types.

Ian Lance Taylor iant@google.com
Wed Aug 25 12:42:00 GMT 2010


rgamarra <rgamarra@gmail.com> writes:

> To check and see what's going on, I did
>
> g++ -E main.cc
>
> , 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.

Ian



More information about the Gcc-help mailing list