[bind maybe?] find_if of map mapped_type.
If I'm iterating over a map with, say find_if, and my predicate function accepts the mapped_type of the map, is there a mechanism to pick out the pair.second value inline? class C; map< int, C > m; bool pred( const C & ); // correct version of this intent. find_if( m.begin( ), m.end( ), pred( second ) ); Thanks, - Rob.
2009/6/4 Robert Jones
If I'm iterating over a map with, say find_if, and my predicate function accepts the mapped_type of the map, is there a mechanism to pick out the pair.second value inline?
class C;
map< int, C > m;
bool pred( const C & );
// correct version of this intent. find_if( m.begin( ), m.end( ), pred( second ) );
find_if(m.begin(), m.end(), bind(pred, bind(&map
On Thu, Jun 4, 2009 at 10:21 AM, Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote:
2009/6/4 Robert Jones
If I'm iterating over a map with, say find_if, and my predicate function accepts the mapped_type of the map, is there a mechanism to pick out the pair.second value inline?
class C;
map< int, C > m;
bool pred( const C & );
// correct version of this intent. find_if( m.begin( ), m.end( ), pred( second ) );
find_if(m.begin(), m.end(), bind(pred, bind(&map
::value_type::second, _1)))
Many thanks Roman - I find these bind incantations a bit like grasping at smoke, one week I get familiar with it all, and the next week the syntax just slips away! - Rob.
participants (2)
-
Robert Jones
-
Roman Perepelitsa