I want a custom comparator for following code. However, I cannot overload operator(), std::less, std::greater. I tried to achieve this using lambdas but gcc won't allow me to use auto as non static member. Any other way to make this work?
#include <iostream>
#include <map>
#include <set>
class Test {
public:
// bool operator () (const int lhs, const int rhs) {
// return lhs > rhs;
// };
using list = std::multiset<int /*, Test*/>;
std::map<const char*, list> scripts;
};
int main() {
Test t;
t.scripts["Linux"].insert(5);
t.scripts["Linux"].insert(8);
t.scripts["Linux"].insert(0);
for(auto a: t.scripts["Linux"]) {
std::cout << a << std::endl;
}
std::cout << "end";
}
Aucun commentaire:
Enregistrer un commentaire