Iterating through all the keys of an std::map by reference

Here is how I want to retrieve the keys of an std::map;

void processMap(std::map<TexturedModel, Entity>& entities) {

for(auto it = entities.begin(); it != entities.end(); ++it) {
TexturedModel& texturedModel = it->first; /*here it gives an error because it->first returns a "const &" and not a reference.
}

}

So how can I retrieve the keys by reference?
You can get a 'const TexturedModel &', but not a 'TexturedModel &'. Keys in a map cannot be modified because that would allow you to modify them in a way that changes their ordering in the map, invalidating it.

 
const TexturedModel &texturedModel = it->first;
Topic archived. No new replies allowed.