operator== missing on std::__debug::map<>::iterator

Jonathan Wakely jwakely.gcc@gmail.com
Mon Dec 10 21:06:00 GMT 2012


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.



More information about the Libstdc++ mailing list