Is comparison of const_iterator with iterator well-defined?

Surprisingly, C++98 and C++11 didn’t say that you can compare a iterator with a const_iterator. This leads to LWG issue 179 and LWG issue 2263. Now in C++14, this is explicitly permitted by ยง 23.2.1[container.requirements.general]p7

In the expressions

i == j
i != j
i < j
i <= j
i >= j
i > j
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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)