|
bool operator<(const QColor & a, const QColor & b) { |
|
return a.redF() < b.redF() |
|
|| a.greenF() < b.greenF() |
|
|| a.blueF() < b.blueF() |
|
|| a.alphaF() < b.alphaF(); |
This comparison function violates the requirement for Strict Weak Ordering and will cause undefined behaviour/corruption inside the map.
Consider colours A(255, 0, 0) and B(0, 255, 0). Both A < B and B < A will return true.
stackoverflown/questions/qmap-qcolor-32512125/main.cpp
Lines 4 to 8 in b3d59cf
This comparison function violates the requirement for Strict Weak Ordering and will cause undefined behaviour/corruption inside the map.
Consider colours
A(255, 0, 0)andB(0, 255, 0). BothA < BandB < Awill return true.