[Development] QVariant comparison in Qt6

Lars Knoll lars.knoll at qt.io
Fri Sep 18 15:48:50 CEST 2020



On 18 Sep 2020, at 14:19, Albert Astals Cid <albert.astals.cid at kdab.com<mailto:albert.astals.cid at kdab.com>> wrote:
[snip]

I’m not really in favour of adding an operator<() to QVariant again, as it
would need to provide some decent ordering, and that would probably cause
conflicts with operator=() that does somewhat loose comparisons for numeric
types.

But we could provide a compare() method similar to QMetaType. I don’t think
we can provide total ordering here as some types stored in a QVariant do
not provide comparison operators, but we could basically provide the same
as QMetaType:

std::optional<int> QVariant::compare(const QVariant &other);

Would that be good enough?

I think that would solve some (probably even most) of the pain, yes :)

Here we go:

https://codereview.qt-project.org/c/qt/qtbase/+/314463

Cheers,
Lars
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200918/01296399/attachment-0001.html>


More information about the Development mailing list