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

后端 未结 11 2157
醉梦人生
醉梦人生 2020-12-07 23:55

My use case:

map cars;
bool exists(const string& name) {
  // somehow I should find whether my MAP has a car
  // with the name provid         


        
11条回答
  •  离开以前
    2020-12-08 00:35

    bool exists(const std::map& cars, const std::string& name) {
      return cars.end() != cars.find(name);
    }
    

提交回复
热议问题