diff --git a/src/corelib/serialization/qcbormap.cpp b/src/corelib/serialization/qcbormap.cpp index 9367a2ab9b2..00c0bb0b6d2 100644 --- a/src/corelib/serialization/qcbormap.cpp +++ b/src/corelib/serialization/qcbormap.cpp @@ -19,7 +19,7 @@ using namespace QtCbor; \brief The QCborMap class is used to hold an associative container representable in CBOR. \compares strong - \compareswith strong QCborValue + \compareswith strong QCborValue QCborValueConstRef \endcompareswith This class can be used to hold an associative container in CBOR, a map diff --git a/src/corelib/serialization/qcbormap.h b/src/corelib/serialization/qcbormap.h index 55935e113ec..087334fdffe 100644 --- a/src/corelib/serialization/qcbormap.h +++ b/src/corelib/serialization/qcbormap.h @@ -326,6 +326,19 @@ private: } Q_DECLARE_STRONGLY_ORDERED(QCborMap, QCborValue) + friend bool comparesEqual(const QCborMap &lhs, const QCborValueConstRef &rhs) noexcept + { + return lhs.compare(rhs.toMap()) == 0; + } + + friend Qt::strong_ordering compareThreeWay(const QCborMap &lhs, + const QCborValueConstRef &rhs) noexcept + { + int c = lhs.compare(rhs.toMap()); + return Qt::compareThreeWay(c, 0); + } + Q_DECLARE_STRONGLY_ORDERED(QCborMap, QCborValueConstRef) + explicit QCborMap(QCborContainerPrivate &dd) noexcept; QExplicitlySharedDataPointer d; }; diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index e3544a4056e..37f1569bbc8 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -452,17 +452,25 @@ void tst_QCborValue::extendedTypes_data() void tst_QCborValue::compareCompiles() { + // homogeneous types QTestPrivate::testAllComparisonOperatorsCompile(); QTestPrivate::testAllComparisonOperatorsCompile(); QTestPrivate::testAllComparisonOperatorsCompile(); QTestPrivate::testAllComparisonOperatorsCompile(); QTestPrivate::testAllComparisonOperatorsCompile(); + + // QCborValue, Ref and ConstRef QTestPrivate::testAllComparisonOperatorsCompile(); QTestPrivate::testAllComparisonOperatorsCompile(); QTestPrivate::testAllComparisonOperatorsCompile(); - QTestPrivate::testAllComparisonOperatorsCompile(); - QTestPrivate::testAllComparisonOperatorsCompile(); + + // QCbor{Array,Map} <=> QCborValue{,Ref,ConstRef} + QTestPrivate::testAllComparisonOperatorsCompile(); + QTestPrivate::testAllComparisonOperatorsCompile(); + QTestPrivate::testAllComparisonOperatorsCompile(); QTestPrivate::testAllComparisonOperatorsCompile(); + QTestPrivate::testAllComparisonOperatorsCompile(); + QTestPrivate::testAllComparisonOperatorsCompile(); } void tst_QCborValue::extendedTypes()