Created
January 2, 2020 19:25
-
-
Save RoyBellingan/1f1b20154c816a70998ee2a819cca752 to your computer and use it in GitHub Desktop.
QMap operator <
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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