https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105470

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Roland Hughes from comment #10)
> There is no definition of that map anywhere in the codebase where
> KeyModifiers is declared const.

That's just how std::map works.

std::map<A, B>::value_type is std::pair<const A, B>.
See the definition of value_type at
https://en.cppreference.com/w/cpp/container/map

So when you iterate over a map<A, B> the values you get back are pair<const A,
B>.

> The method being called returns a const & to the entire map, but there is no
> const declared within the map.

There is in the map's value_type though, and that's what you iterate over with
the range-based for loop.

Reply via email to