Can lower_bound and upper_bound work with vector of pair<pair<int, int>, int> or nested pairs. I tried doing so but it is showing me error. So, how should we do that?
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | adamant | 152 |
| 3 | Proof_by_QED | 146 |
| 3 | Um_nik | 146 |
| 5 | Dominater069 | 144 |
| 6 | errorgorn | 141 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 9 | TheScrasse | 134 |
Can lower_bound and upper_bound work with vector of pair<pair<int, int>, int> or nested pairs. I tried doing so but it is showing me error. So, how should we do that?
| Name |
|---|



Don`t now how to do this. But I can tell you a substitute for this.
Implement your own struct for this. Like :
Write down a less than operator a separate comparator for it.
This is my code. Have a look.
My code — https://pastebin.com/BMM8f21P
Although I am having a small problem and I will be really happy if a third person can help us both. Lower bound returns the same value if its present in the query range. But in my code if I am searching {1 , 2 , 3} in the vector of particular struct, I am not getting the desired result.
I even implemented an (==) operator for this struct but it was not helpful.
The biggest thing that stands out in your code is that if all of the elements of the 3-tuple are equal, you're not returning anything from your comparison functions, like operator< I believe that's UB in C++, or whatever it is it's not going to be fun behavior.
Your compiler should really be warning about that, -Wall is good practice if you're not already using that.
Oh shit.
I did this by mistake. Thanks for telling me kadoban. :)
I have updated the code.
It works properly now.
Code — https://pastebin.com/qMmEbMKg
What error are you actually getting? It looks to me like it should just work.
For example this doesn't error for me (with --std=c++14 if it matters):
I believe making a custom comparator will solve the problem!