[Interest] QVariant compare operator
Matthew Woehlke
mwoehlke.floss at gmail.com
Tue Apr 21 15:02:30 CEST 2020
On 20/04/2020 12.21, André Pönitz wrote:
> On Mon, Apr 20, 2020 at 10:04:38AM -0400, Matthew Woehlke wrote:
>> On 19/04/2020 08.23, André Pönitz wrote:
>>> QVariant(TypeA) and QVariant(TypeB) can be ordered for different TypeA and
>>> TypeB based e.g. on alphabetical order of their .typeName().
>>>
>>> If wanted, this can be refined to make e.g. all integral types comparable.
>>
>> No:
>>
>> int{5} <=> JsonObject{...} => lesser
>> int{5} <=> long{3} => greater
>> long{3} <=> JsonObject{...} => greater
>>
>> ...oops.
>
> "make comparable" means lumping them into a common "type", say
> "@integral", with values covering the union set of the values
> of the original type.
...and now your rule for heterogeneous comparisons ***isn't***
'according to the type name'. It's 'according to the type name, *except*
<list of exceptions>'. Yuck.
>> You'd have to make all integral types sort before (or after) all other
>> types, but then you're back to not having a reliable ordering by type name.
>
> No.
Really? Please explain how this is *not* the case.
--
Matthew
More information about the Interest
mailing list