I am new to c++ and I have a question regarding the following piece of code. I have created an unordered map with name (which is of string type) as key and a tuple of int and long defined as catInfection
.
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int,long> catInfection; // infection level, "earlyness"
auto comparison_func = [](const pair<string Key,catInfection Value> &A, const pair<string Key,catInfection Value> &B) {
if (get<0>(A.second) < get<0>(B.second)) {
return true;
}
else if (get<0>(A.second) > get<0>(B.second)) {
return false;
}
else {
if (get<1>(A.second) < get<1>(B.second)) {
return false;
}
else {
return true;
}
}
};
class clinic {
private:
unordered_map <string, catInfection> comp_vector;
.
.
string query() {
return (*max_element(comp_vector.begin(),comp_vector.end(),comparison_func)).first;
}
However, when I try compiling the code, it returns an error saying
main.cpp:7:67: error: wrong number of template arguments (1, should be 2)
7 | auto comparison_func = [](const pair<string Key,catInfection Value> &A, const pair<string Key,catInfection Value> &B) {
| ^
Can anyone explain to me what is wrong? Thanks so much in advance!!