I would like to use std :: find_if to search for the first element on my map that has a specific value in a specific element of its value structure. Although I'm a little confused. I think I need to use bind1st or bind2nd, but I'm not sure what the correct path is.
Here is some pseudo code:
struct ValueType { int x, int y, int z }; std::map<int, ValueType> myMap; ... {populate map} std::map<int, ValueType>::iterator pos = std::find_if(myMap.begin(), myMap.end(), <?>);
So, let's say that I wanted to find the first element of the map, where the .x member of ValueType was equal to a specific integer value (which every call can change).
What would be the best way to write an object of a function or function to achieve this? I understand that there must be a unary predicate that makes me think that I will need bind1st or bind2nd to provide an integer value that I check, but I'm not sure how to do this. It has been too long since I looked at it !. > & L;
c ++ stl
John Humphreys - w00te
source share