std::map find_if condition style confusion

前端 未结 8 1209
星月不相逢
星月不相逢 2021-02-01 23:43

I\'d like to use std::find_if to search for the first element in my map that has a certain value in a specific element of its value structure. I\'m a little confus

8条回答
  •  没有蜡笔的小新
    2021-02-01 23:57

    using Boost.Bind and Boost.Lambda:

    ...
    #include 
    #include 
    ...
    typedef std::map MapType;
    ...
    MapType::iterator pos = std::find_if(myMap.begin(), myMap.end(), 
        boost::bind(&ValueType::y, boost::bind(&MapType::iterator::value_type::second, _1)) == magic_number);
    

提交回复
热议问题