[Interest] QVariant compare operator

Allan Sandfeld Jensen kde at carewolf.com
Sun Apr 19 15:18:25 CEST 2020


On Sonntag, 19. April 2020 14:39:40 CEST André Pönitz wrote:
> On Sun, Apr 19, 2020 at 02:21:39PM +0200, Allan Sandfeld Jensen wrote:
> > > I don't think we need "incomparable" here.
> > > 
> > > 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.
> > 
> > What about non-integral types?
> 
> They are compared by typeName(). So any QChar would be less-than any
> QRegularExpression.
> 
> > QVariants can't really be anything but weakly ordered as I see it,
> > as some of the things it contains are either non- comparable or
> > weakly ordered themselves.
> 
> On the inner level the situation is up to the actual type, that's no
> different than today, and would also not be affected by disallowing
> comparisons between different types.
> 
Yes, but in C++20 terms the comparison operators still need to return types of 
https://en.cppreference.com/w/cpp/utility/compare/partial_ordering[1] 

But all that really isn't possible before C++20 as I see it.

'Allan

--------
[1] https://en.cppreference.com/w/cpp/utility/compare/partial_ordering
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200419/324afd8d/attachment.html>


More information about the Interest mailing list