Use of for_each on map elements

前端 未结 11 1000
北荒
北荒 2021-01-30 10:29

I have a map where I\'d like to perform a call on every data type object member function. I yet know how to do this on any sequence but, is it possible to do it on an associativ

11条回答
  •  自闭症患者
    2021-01-30 11:13

    How about a plain C++? (example fixed according to the note by @Noah Roberts)

    for(std::map::iterator itr = Map.begin(), itr_end = Map.end(); itr != itr_end; ++itr) {
      itr->second.Method();
    }
    

提交回复
热议问题