Lower_bound not found for vector of pairs in c++

I am trying to find lower_bound on vector of pair of int. But my IDE, as well my compiler throws an error. Please someone help.

Lower_bound works for normal single dimensional vector. But fails for vector of pairs.

Please help me find a solution.

LB is the macro which is defined as lower_bound .

Here you can see can see screenshot

enter image description here

>Solution :

Here’s how it works. Tell the type of the 3rd argument.

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main()
    vector<pair<int, int> > v;
    lower_bound(v.begin(), v.end(), std::pair<int, int>{10,1});

    return 0;

Leave a Reply