operator== missing on std::__debug::map<>::iterator
Marc Glisse
marc.glisse@inria.fr
Mon Dec 10 21:30:00 GMT 2012
On Mon, 10 Dec 2012, Jonathan Wakely wrote:
> On 10 December 2012 16:39, Pedro Larroy wrote:
>> Hi Paolo
>>
>> What do you mean by doesn't exists? It exists in release mode in
>> _Rb_tree_iterator class
>>
>> bool
>> operator==(const _Self& __x) const
>> { return _M_node == __x._M_node; }
>>
>> But I think it doesn't exist in the debug map iterator class, as the
>> compiler error shows.
>>
>> Shouldn't it be added to the debug map iterator class also so the code
>> compiles in both release and debug modes?
>
> No. Your code make non-portable assumptions about the iterator type
> and the debug mode has done you a favour by highlighting that error.
> You should fix your code to only rely on the operations guaranteed to
> work by the standard.
>
> The standard says that if a and b are iterators of the same type then
> a == b is a valid expression, it does not say that a.operator==(b) is
> a valid expression.
By the way, would the standard allow those iterators to be final? (not
suggesting it, just asking, because it doesn't seem forbidden)
--
Marc Glisse
More information about the Libstdc++
mailing list