[Interest] QVariant compare operator

Allan Sandfeld Jensen kde at carewolf.com
Sun Apr 19 13:28:32 CEST 2020


On Sonntag, 19. April 2020 13:05:05 CEST André Pönitz wrote:
> On Sat, Apr 18, 2020 at 09:44:40PM -0300, Thiago Macieira wrote:
> > On Saturday, 18 April 2020 12:57:55 -03 Giuseppe D'Angelo via Interest 
wrote:
> > > I guess that's the reason for dropping the comparisons in 6.0 and,
> > > eventually, reintroduce it in 7.0. With the hope that we've learned the
> > > lesson and proceed at _specifying_ the behaviour before implementing it.
> > 
> > Indeed, and implement the QVariant comparator on top of each underlying
> > type's spaceship operator. That way, we could order elements of the same
> > type. For mismatched types, QVariant can return
> > std::partial_ordering::unordered.
> > 
> > We can't do that right now because we can't rely on C++20. In fact, no
> > current compiler supports the spaceship operator. So that has to be Qt 7.
> 
> How comes the spaceship operator comes into play here?
> 
> It's syntactical sugar and in some cases an optimization, but has no
> concepual powers exceeding those of operator<().
> 
It has the concept of weak ordering, it isn't just returning true or false, 
but an enum of a specific type, which so we can report two elements as 
incomparable if they are not of comparable types. 

'Allan




More information about the Interest mailing list