, . ( const const-) , ( const). const. , , non const thing_map const Map & thing_map.
const Thing * , it- > second Thing * not const Thing *.
:
Thing* find_thing_by_name(const String & name, const Map<String,Thing*> & thing_map)
{
auto it = thing_map.find(name);
return it->second;
}
Thing, :
const Thing* find_thing_by_name(const String & name, const Map<String,Thing*> & thing_map)
{
auto it = thing_map.find(name);
return it->second;
}
:
...
const Map<String, Thing *> constMapObj;
const Map<String, Thing *> nonConstMapObj;
....
auto res1 = find_thing_by_name(someKey, constMapObj);
auto res2 = find_thing_by_name(someOtherKey, nonConstMapObj);