I would like to search within a vector<std::pair<int, vector<int> > >. This won’t work due to the vector parameters:
std::vector<std::pair<int, std::vector<int> > > myVec;
iterator = find(myVec.begin(), myVec.end(), i);
Search would be on the first std::pair template parameter (int), in order to get the vector associated with it.
You could make do with the following (pretty ugly) functoid:
using it like this ( I couldn’t get bind2nd to work – that’s why I used the c’tor ):
I think what you would like is a map:
You can then add elements, search by key etc:
Looking at the way you’ve done things though, you might be wanting a
std::multimap(which allows multiple values to have the same key) Class docs here