I have a sorted vector(according to first.second element)vector pair of following type : vector<pair<pair<int,int>,int>>p;
My Comparator function to sort vector pair
bool sortbysec(pair<pair<int,int>,int>&a,pair<pair<int,int>,int>&b) { if(a.first.second==b.first.second)return a.first.first<b.first.first; else return a.first.second<b.first.second; } I want upper bound of p.first.secondelement on the list of p.first.firstelements.
For example -
2 2 7 1 3 4 1 4 3 4 5 8 5 7 5 4 8 6 5 8 1 6 8 9 8 8 0 8 9 2 In simple words, I want an upper bound of middle element of the vector pair.Searching the upper bound of that particular element should be done in list of first element of the vector pair.
For Example, upper bound of 3 in second row is 4 in the 4th row.
My question is : I dont know how to code this thing. I have tried this syntax(incorrect):
auto it=lower_bound(v.begin(),v.end(),make_pair(make_pair(2,2),7)); This is showing error. I hope you understood the question. Please anyone tell me a way how to code it properly so i get the desired results in c++ only.