Skip to content

Incorrect comparison function - violates strict weak ordering #3

Description

@ineedanaccounttosearch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions