How to find whether an element exists in std::map?

Posted by Vincenzo on Stack Overflow See other posts from Stack Overflow or by Vincenzo
Published on 2010-05-06T14:38:06Z Indexed on 2010/05/06 15:08 UTC
Read the original article Hit count: 119

Filed under:

My use case:

map<string, Car> cars;
bool exists(const string& name) {
  // somehow I should find whether my MAP has a car
  // with the name provided
  return false;
} 

Could you please suggest the best and the most elegant way to do it in C++? Thanks.

© Stack Overflow or respective owner

Related posts about c++