Skip to content

Instantly share code, notes, and snippets.

@RoyBellingan
Created January 2, 2020 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RoyBellingan/1f1b20154c816a70998ee2a819cca752 to your computer and use it in GitHub Desktop.
Save RoyBellingan/1f1b20154c816a70998ee2a819cca752 to your computer and use it in GitHub Desktop.
QMap operator <
#include <QMap>
using namespace std;
class Something {
public:
string blob1;
int id2 = 0;
};
class Weird1 {
public:
string name;
uint32_t id = 0; //Only this parameter is used to define the UNIQUENESS!!!
bool whatever = false;
Something s1;
};
bool operator<(const Weird1& e1, const Weird1& e2) {
//almost Everything is IGNORED!!!
return e1.id < e2.id;
}
int main() {
QMap<Weird1, string> qtMap;
Weird1 k1;
k1.id = 1;
qtMap.insert(k1, "v1");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment