First question: is it possible to \"force\" a const_iterator
using auto?
For example:
map usa
Sorry, but I just think the best suggestion is not using auto
at all, since you want to perform a (implicitly valid) type conversion. auto
is meant for deducing the exact type, which is not what you want here.
Just write it this way:
std::map::const_iterator city_it = usa.find("New York");
As correctly pointed out by MooingDuck, using type aliases can improve the readability and maintainability of your code:
typedef std::map my_map;
my_map::const_iterator city_it = usa.find("New York");