jeudi 11 novembre 2021

how to use find_if to find element in given vector of pairs

For example consider vector<pair<string,int>>

And it contains:

ABC 1
BCD 2
CDE 3
XHZ 4

string s;
cin>>s;
if(find_if(vec.begin(),vec.begin()+3,cmp)!=vec.begin()+3) // I want to check only first 3 values  

I need cmp to find given string is present or not using find_if

EDIT:
How to pass the string s with the comparator (cmp) and the vector will always contains minimum 3 elements

Aucun commentaire:

Enregistrer un commentaire