As long as the map is not a multimap, one of the most elegant ways would be to use the count method
if (m.count(key))
// key exists
The count would be 1 if the element is indeed present in the map.
As long as the map is not a multimap, one of the most elegant ways would be to use the count method
if (m.count(key))
// key exists
The count would be 1 if the element is indeed present in the map.