[Development] QVariant comparison in Qt6
thiago.macieira at intel.com
Fri Sep 18 20:56:38 CEST 2020
On Friday, 18 September 2020 09:38:12 PDT Ville Voutilainen wrote:
> > We should use one of the types from <compare>. Yes, it's C++20; we can
> > make our internal API return an integer that is convertible to those
> > types in the front-end API, under #if __has_include(<compare>).
> >  https://en.cppreference.com/w/cpp/header/compare
> Why do people keep pushing C++20 facilities when we decided that C++17
> is our standard
> version? How does the int say "I can't compare this"? partial_ordering
> can do that, but what
> will the int do?
Because we should push our users to adopt new compiler versions. Having
features in Qt only available when they upgrade is a good way to do that. Want
to use old compilers? It costs more.
We can also use this to provide spaceship operator for QVariant and other
Anyway, the int suffices because we only need four values: equal/equivalent,
less than, greater than, unordered. We can even adopt the same values:
// less=0xff, equiv=0x00, greater=0x01, unordered=0x02
or we can use -127 for unordered like libc++ does or -128 like Microsoft STL.
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel DPG Cloud Engineering
More information about the Development