[Development] QVariant comparison in Qt6
ville.voutilainen at gmail.com
Sat Sep 19 20:41:08 CEST 2020
On Fri, 18 Sep 2020 at 21:58, Thiago Macieira <thiago.macieira at intel.com> wrote:
> 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.
Well, if we envision making it convertible to something later on, then
*PLEASE* use a class type.
I have recent experience on a particular codebase that wanted to
migrate from custom allocators
to standard allocators, and one significant part of it was converting
standard allocators to the custom
ones. But that didn't work because the API vocabulary type was CustomAllocator*.
You can't write a conversion from a type you don't own to an int, or
vice versa. Don't fall into that trap, it's impossible
to dig yourself out of it.
More information about the Development