[Development] QVariant comparison in Qt6

Ville Voutilainen ville.voutilainen at gmail.com
Tue Sep 22 18:01:05 CEST 2020


On Tue, 22 Sep 2020 at 17:20, Thiago Macieira <thiago.macieira at intel.com> wrote:
> And especially if there's no impact to how the user uses the API.
>
> > 1)
> > std::optional<int> compare();
> >
> > 2)
> > enum class Ordering { Less = -1, Equal = 0, Greater = 1, Unordered = 0xff
> > };
> >  Ordering compare();
> >
> > 3)
> > Implement a Qt replacement for std::partial_ordering (could use the std
> > stuff if C++ 20 is available) and use that.
>
> I'd rather stay simple and allow extending for <compare> where more details
> are necessary.
>
> For that, I think #1.

If this is an API function that users call, make it (2) but make it a
class, not an enum class.
You can then later write a conversion operator that converts the
result to std::partial_ordering.

if this is a private function that no user sees directly, then 1/2 are
both fine. The class I mention
above basically is a Qt replacement for std::partial_ordering, of course.


More information about the Development mailing list