Hi Ian again, Great, I haven't noticed that deffect report, which I found at http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#179 Now it's clear! It's explicitly allowed and that's was I was trying to understand. Before, I have taken a look at the last working draft (n3090) but didn't find the answer. Now with the clue of what's reported in that DR, I found clause 7 from "23.2.1 General container requirements" which says what you say: "In the expressions ... i - j ... where i and j denote objects of a container’s iterator type, either or both may be replaced by an object of the container’s const_iterator type referring to the same element with no change in semantics." Regarding the implementation, I saw that the operator- was forwarding the call. What I understood was that if any conversion was taking place then I wouldn't be in the actual iterator (or const_iterator) type (which in the guts is normal_iterator) but in some other type, which may be the base, for instance; but what the standard talked about was conversion between iterator and const_iterator, but not between their base classes. Now, it's another issue (of the C++ standard) that std::distance is not interchangable with operator-. Also that added paragraph 7 talks about iterators in general, whereas some of the quoted operations are only presented in random-access ones (among them operator-). Cheers, and thanks a lot for your clarifications and responses. -- Rodolfo Federico Gamarra On Wed, Aug 25, 2010 at 01:34, Ian Lance Taylor <iant@xxxxxxxxxx> wrote: > rgamarra <rgamarra@xxxxxxxxx> 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 >