5#error "Do not include qcomparehelpers.h directly. Use qcompare.h instead."
8#ifndef QCOMPAREHELPERS_H
9#define QCOMPAREHELPERS_H
12#pragma qt_no_master_include
13#pragma qt_sync_skip_header_check
14#pragma qt_sync_stop_processing
17#include <QtCore/qflags.h>
18#include <QtCore/qoverload.h>
19#include <QtCore/qttypetraits.h>
20#include <QtCore/qtypeinfo.h>
21#include <QtCore/qtypes.h>
23#ifdef __cpp_lib_three_way_comparison
26#include <QtCore/q20type_traits.h>
32class QPartialOrdering;
53template <
typename StdOrdering>
struct QtOrdering;
55#ifdef __cpp_lib_three_way_comparison
57 template <> struct StdOrdering< Qt::x##_ordering> : q20::type_identity<std::x##_ordering> {};
58 template <> struct StdOrdering<std::x##_ordering> : q20::type_identity<std::x##_ordering> {};
59 template <> struct QtOrdering<std::x##_ordering> : q20::type_identity< Qt::x##_ordering> {};
60 template <> struct QtOrdering< Qt::x##_ordering> : q20::type_identity< Qt::x##_ordering> {};
61 template <> struct is_std_ordering_type<std::x##_ordering> : std::true_type {};
62 template <> struct is_qt_ordering_type< Qt::x##_ordering> : std::true_type {};
94 Qt::partial_ordering convertedOrder(t);
95 if constexpr (std::is_same_v<T, Qt::strong_ordering>)
97 else if constexpr (std::is_same_v<T, Qt::partial_ordering>)
99 else if constexpr (std::is_same_v<T, Qt::weak_ordering>)
109 return QtOrderingTypeFlag(flags
110 | QtOrderingPrivate::orderingFlagsFor(QtOrderingPrivate::to_Qt(t)));
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
148
149
150
151
152
153
154
155
156
157#if defined(__cpp_lib_three_way_comparison) || !(defined(Q_OS_QNX) || defined(Q_CC_GHS))
158# define QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, Func)
159 constexpr auto f = []() Noexcept {};
160 static_assert(!noexcept(f()) || noexcept(Func(lhs, rhs)),
161 "Use *_NON_NOEXCEPT version of the macro, "
162 "or make the helper function noexcept")
164# define QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, Func)
172#if defined(__cpp_lib_three_way_comparison) && !defined(Q_QDOC)
175#define QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr,
178 friend Constexpr bool operator
==(LeftType const &lhs, RightType const &rhs) Noexcept
180 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, comparesEqual);
181 return comparesEqual(lhs, rhs);
184#define QT_DECLARE_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr, Noexcept, ...)
186 friend Constexpr std::strong_ordering
187 operator
<=>(LeftType const &lhs, RightType const &rhs) Noexcept
189 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, compareThreeWay);
190 return compareThreeWay(lhs, rhs);
193#define QT_DECLARE_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr, Noexcept, ...)
195 friend Constexpr std::weak_ordering
196 operator
<=>(LeftType const &lhs, RightType const &rhs) Noexcept
198 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, compareThreeWay);
199 return compareThreeWay(lhs, rhs);
202#define QT_DECLARE_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr, Noexcept, ...)
204 friend Constexpr std::partial_ordering
205 operator
<=>(LeftType const &lhs, RightType const &rhs) Noexcept
207 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, compareThreeWay);
208 return compareThreeWay(lhs, rhs);
211#define QT_DECLARE_ORDERING_HELPER_AUTO(LeftType, RightType, Constexpr, Noexcept, ...)
213 friend Constexpr auto
214 operator
<=>(LeftType const &lhs, RightType const &rhs) Noexcept
216 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, compareThreeWay);
217 return QtOrderingPrivate::to_std(compareThreeWay(lhs, rhs));
220#define QT_DECLARE_ORDERING_OPERATORS_HELPER(OrderingType, LeftType, RightType, Constexpr,
222 QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr, Noexcept, __VA_ARGS__)
223 QT_DECLARE_ORDERING_HELPER_ ## OrderingType (LeftType, RightType, Constexpr, Noexcept,
226#ifdef Q_COMPILER_LACKS_THREE_WAY_COMPARE_SYMMETRY
229#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr,
232 friend Constexpr bool operator
==(RightType const &lhs, LeftType const &rhs) Noexcept
233 { return comparesEqual(rhs, lhs); }
235#define QT_DECLARE_REVERSED_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr,
238 friend Constexpr std::strong_ordering
239 operator
<=>(RightType const &lhs, LeftType const &rhs) Noexcept
241 const auto r = compareThreeWay(rhs, lhs);
242 return QtOrderingPrivate::reversed(r);
245#define QT_DECLARE_REVERSED_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr,
248 friend Constexpr std::weak_ordering
249 operator
<=>(RightType const &lhs, LeftType const &rhs) Noexcept
251 const auto r = compareThreeWay(rhs, lhs);
252 return QtOrderingPrivate::reversed(r);
255#define QT_DECLARE_REVERSED_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr,
258 friend Constexpr std::partial_ordering
259 operator
<=>(RightType const &lhs, LeftType const &rhs) Noexcept
261 const auto r = compareThreeWay(rhs, lhs);
262 return QtOrderingPrivate::reversed(r);
265#define QT_DECLARE_REVERSED_ORDERING_HELPER_AUTO(LeftType, RightType, Constexpr, Noexcept, ...)
267 friend Constexpr auto
268 operator
<=>(RightType const &lhs, LeftType const &rhs) Noexcept
270 const auto r = compareThreeWay(rhs, lhs);
271 return QtOrderingPrivate::to_std(QtOrderingPrivate::reversed(r));
274#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType,
275 Constexpr, Noexcept, ...)
276 QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr,
277 Noexcept, __VA_ARGS__)
278 QT_DECLARE_REVERSED_ORDERING_HELPER_ ## OrderingString (LeftType, RightType, Constexpr,
279 Noexcept, __VA_ARGS__)
284#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr,
286#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType,
287 Constexpr, Noexcept, ...)
295#define QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr,
298 friend Constexpr bool operator
==(LeftType const &lhs, RightType const &rhs) Noexcept
301 return comparesEqual(lhs, rhs);
304 friend Constexpr bool operator
!=(LeftType const &lhs, RightType const &rhs) Noexcept
305 { return !comparesEqual(lhs, rhs); }
308#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr,
311 friend Constexpr bool operator
==(RightType const &lhs, LeftType const &rhs) Noexcept
312 { return comparesEqual(rhs, lhs); }
314 friend Constexpr bool operator
!=(RightType const &lhs, LeftType const &rhs) Noexcept
315 { return !comparesEqual(rhs, lhs); }
317#define QT_DECLARE_ORDERING_HELPER_TEMPLATE(OrderingType, LeftType, RightType, Constexpr,
320 friend Constexpr bool operator
<(LeftType const &lhs, RightType const &rhs) Noexcept
323 return is_lt(compareThreeWay(lhs, rhs));
326 friend Constexpr bool operator
>(LeftType const &lhs, RightType const &rhs) Noexcept
327 { return is_gt(compareThreeWay(lhs, rhs)); }
329 friend Constexpr bool operator
<=(LeftType const &lhs, RightType const &rhs) Noexcept
330 { return is_lteq(compareThreeWay(lhs, rhs)); }
332 friend Constexpr bool operator
>=(LeftType const &lhs, RightType const &rhs) Noexcept
333 { return is_gteq(compareThreeWay(lhs, rhs)); }
335#define QT_DECLARE_ORDERING_HELPER_AUTO(LeftType, RightType, Constexpr, Noexcept, ...)
339#define QT_DECLARE_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr, Noexcept, ...)
341 Noexcept, __VA_ARGS__)
343#define QT_DECLARE_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr, Noexcept, ...)
345 Noexcept, __VA_ARGS__)
347#define QT_DECLARE_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr, Noexcept, ...)
349 Noexcept, __VA_ARGS__)
351#define QT_DECLARE_ORDERING_OPERATORS_HELPER(OrderingString, LeftType, RightType, Constexpr,
354 QT_DECLARE_ORDERING_HELPER_ ## OrderingString (LeftType, RightType, Constexpr, Noexcept,
358#define QT_DECLARE_REVERSED_ORDERING_HELPER_TEMPLATE(OrderingType, LeftType, RightType, Constexpr,
361 friend Constexpr bool operator
<(RightType const &lhs, LeftType const &rhs) Noexcept
362 { return is_gt(compareThreeWay(rhs, lhs)); }
364 friend Constexpr bool operator
>(RightType const &lhs, LeftType const &rhs) Noexcept
365 { return is_lt(compareThreeWay(rhs, lhs)); }
367 friend Constexpr bool operator
<=(RightType const &lhs, LeftType const &rhs) Noexcept
368 { return is_gteq(compareThreeWay(rhs, lhs)); }
370 friend Constexpr bool operator
>=(RightType const &lhs, LeftType const &rhs) Noexcept
371 { return is_lteq(compareThreeWay(rhs, lhs)); }
373#define QT_DECLARE_REVERSED_ORDERING_HELPER_AUTO(LeftType, RightType, Constexpr, Noexcept, ...)
377#define QT_DECLARE_REVERSED_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr, Noexcept, ...)
379 Constexpr, Noexcept, __VA_ARGS__)
381#define QT_DECLARE_REVERSED_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr, Noexcept, ...)
383 Constexpr, Noexcept, __VA_ARGS__)
385#define QT_DECLARE_REVERSED_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr, Noexcept, ...)
387 Constexpr, Noexcept, __VA_ARGS__)
389#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType,
390 Constexpr, Noexcept, ...)
393 QT_DECLARE_REVERSED_ORDERING_HELPER_ ## OrderingString (LeftType, RightType, Constexpr,
394 Noexcept, __VA_ARGS__)
401#define QT_DECLARE_EQUALITY_COMPARABLE_1(Type)
405#define QT_DECLARE_EQUALITY_COMPARABLE_2(LeftType, RightType)
411#define QT_DECLARE_EQUALITY_COMPARABLE_3(LeftType, RightType, ...)
413 noexcept(true), __VA_ARGS__)
415 noexcept(true), __VA_ARGS__)
417#define QT_DECLARE_EQUALITY_COMPARABLE_4(...)
419#define QT_DECLARE_EQUALITY_COMPARABLE_5(...)
421#define QT_DECLARE_EQUALITY_COMPARABLE_6(...)
423#define QT_DECLARE_EQUALITY_COMPARABLE_7(...)
425#define QT_DECLARE_EQUALITY_COMPARABLE_8(...)
427#define QT_DECLARE_EQUALITY_COMPARABLE_9(...)
430#define Q_DECLARE_EQUALITY_COMPARABLE(...)
431 QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE, __VA_ARGS__)
433#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_1(Type)
437#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_2(LeftType, RightType)
443#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_3(LeftType, RightType, ...)
449#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_4(...)
451#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_5(...)
453#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_6(...)
455#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_7(...)
457#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_8(...)
459#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_9(...)
462#define Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE(...)
463 QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE, __VA_ARGS__)
465#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_1(Type)
469#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_2(LeftType, RightType)
475#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_3(LeftType, RightType, ...)
477 noexcept(false), __VA_ARGS__)
479 noexcept(false), __VA_ARGS__)
481#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_4(...)
483#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_5(...)
485#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_6(...)
487#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_7(...)
489#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_8(...)
491#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_9(...)
494#define Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(...)
495 QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT, __VA_ARGS__)
498#define QT_DECLARE_ORDERED_1(Type)
502#define QT_DECLARE_ORDERED_2(LeftType, RightType)
508#define QT_DECLARE_ORDERED_3(LeftType, RightType, ...)
510 noexcept(true), __VA_ARGS__)
512 noexcept(true), __VA_ARGS__)
521#define Q_DECLARE_ORDERED(...) QT_OVERLOADED_MACRO(QT_DECLARE_ORDERED, __VA_ARGS__)
523#define QT_DECLARE_ORDERED_LITERAL_TYPE_1(Type)
527#define QT_DECLARE_ORDERED_LITERAL_TYPE_2(LeftType, RightType)
533#define QT_DECLARE_ORDERED_LITERAL_TYPE_3(LeftType, RightType, ...)
535 noexcept(true), __VA_ARGS__)
537 noexcept(true), __VA_ARGS__)
539#define QT_DECLARE_ORDERED_LITERAL_TYPE_4(...)
541#define QT_DECLARE_ORDERED_LITERAL_TYPE_5(...)
543#define QT_DECLARE_ORDERED_LITERAL_TYPE_6(...)
545#define QT_DECLARE_ORDERED_LITERAL_TYPE_7(...)
547#define QT_DECLARE_ORDERED_LITERAL_TYPE_8(...)
549#define QT_DECLARE_ORDERED_LITERAL_TYPE_9(...)
552#define Q_DECLARE_ORDERED_LITERAL_TYPE(...)
553 QT_OVERLOADED_MACRO(QT_DECLARE_ORDERED_LITERAL_TYPE, __VA_ARGS__)
555#define QT_DECLARE_ORDERED_NON_NOEXCEPT_1(Type)
559#define QT_DECLARE_ORDERED_NON_NOEXCEPT_2(LeftType, RightType)
565#define QT_DECLARE_ORDERED_NON_NOEXCEPT_3(LeftType, RightType, ...)
567 noexcept(false), __VA_ARGS__)
569 noexcept(false), __VA_ARGS__)
571#define QT_DECLARE_ORDERED_NON_NOEXCEPT_4(...)
573#define QT_DECLARE_ORDERED_NON_NOEXCEPT_5(...)
575#define QT_DECLARE_ORDERED_NON_NOEXCEPT_6(...)
577#define QT_DECLARE_ORDERED_NON_NOEXCEPT_7(...)
579#define QT_DECLARE_ORDERED_NON_NOEXCEPT_8(...)
581#define QT_DECLARE_ORDERED_NON_NOEXCEPT_9(...)
584#define Q_DECLARE_ORDERED_NON_NOEXCEPT(...)
585 QT_OVERLOADED_MACRO(QT_DECLARE_ORDERED_NON_NOEXCEPT, __VA_ARGS__)
588#define QT_DECLARE_PARTIALLY_ORDERED_1(Type)
592#define QT_DECLARE_PARTIALLY_ORDERED_2(LeftType, RightType)
599#define QT_DECLARE_PARTIALLY_ORDERED_3(LeftType, RightType, ...)
601 noexcept(true), __VA_ARGS__)
603 , noexcept(true), __VA_ARGS__)
605#define QT_DECLARE_PARTIALLY_ORDERED_4(...)
607#define QT_DECLARE_PARTIALLY_ORDERED_5(...)
609#define QT_DECLARE_PARTIALLY_ORDERED_6(...)
611#define QT_DECLARE_PARTIALLY_ORDERED_7(...)
613#define QT_DECLARE_PARTIALLY_ORDERED_8(...)
615#define QT_DECLARE_PARTIALLY_ORDERED_9(...)
618#define Q_DECLARE_PARTIALLY_ORDERED(...)
619 QT_OVERLOADED_MACRO(QT_DECLARE_PARTIALLY_ORDERED, __VA_ARGS__)
621#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_1(Type)
625#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_2(LeftType, RightType)
631#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType, ...)
635 noexcept(true), __VA_ARGS__)
637#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_4(...)
639#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_5(...)
641#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_6(...)
643#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_7(...)
645#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_8(...)
647#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_9(...)
650#define Q_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE(...)
651 QT_OVERLOADED_MACRO(QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE, __VA_ARGS__)
653#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_1(Type)
657#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_2(LeftType, RightType)
664#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_3(LeftType, RightType, ...)
666 noexcept(false), __VA_ARGS__)
668 , noexcept(false), __VA_ARGS__)
670#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_4(...)
672#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_5(...)
674#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_6(...)
676#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_7(...)
678#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_8(...)
680#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_9(...)
683#define Q_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT(...)
684 QT_OVERLOADED_MACRO(QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT, __VA_ARGS__)
687#define QT_DECLARE_WEAKLY_ORDERED_1(Type)
691#define QT_DECLARE_WEAKLY_ORDERED_2(LeftType, RightType)
697#define QT_DECLARE_WEAKLY_ORDERED_3(LeftType, RightType, ...)
699 noexcept(true), __VA_ARGS__)
701 noexcept(true), __VA_ARGS__)
703#define QT_DECLARE_WEAKLY_ORDERED_4(...)
705#define QT_DECLARE_WEAKLY_ORDERED_5(...)
707#define QT_DECLARE_WEAKLY_ORDERED_6(...)
709#define QT_DECLARE_WEAKLY_ORDERED_7(...)
711#define QT_DECLARE_WEAKLY_ORDERED_8(...)
713#define QT_DECLARE_WEAKLY_ORDERED_9(...)
716#define Q_DECLARE_WEAKLY_ORDERED(...)
717 QT_OVERLOADED_MACRO(QT_DECLARE_WEAKLY_ORDERED, __VA_ARGS__)
719#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_1(Type)
723#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_2(LeftType, RightType)
729#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType, ...)
733 noexcept(true), __VA_ARGS__)
735#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_4(...)
737#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_5(...)
739#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_6(...)
741#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_7(...)
743#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_8(...)
745#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_9(...)
748#define Q_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE(...)
749 QT_OVERLOADED_MACRO(QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE, __VA_ARGS__)
751#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_1(Type)
755#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_2(LeftType, RightType)
761#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_3(LeftType, RightType, ...)
763 noexcept(false), __VA_ARGS__)
765 noexcept(false), __VA_ARGS__)
767#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_4(...)
769#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_5(...)
771#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_6(...)
773#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_7(...)
775#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_8(...)
777#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_9(...)
780#define Q_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT(...)
781 QT_OVERLOADED_MACRO(QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT, __VA_ARGS__)
784#define QT_DECLARE_STRONGLY_ORDERED_1(Type)
788#define QT_DECLARE_STRONGLY_ORDERED_2(LeftType, RightType)
795#define QT_DECLARE_STRONGLY_ORDERED_3(LeftType, RightType, ...)
797 noexcept(true), __VA_ARGS__)
799 , noexcept(true), __VA_ARGS__)
801#define QT_DECLARE_STRONGLY_ORDERED_4(...)
803#define QT_DECLARE_STRONGLY_ORDERED_5(...)
805#define QT_DECLARE_STRONGLY_ORDERED_6(...)
807#define QT_DECLARE_STRONGLY_ORDERED_7(...)
809#define QT_DECLARE_STRONGLY_ORDERED_8(...)
811#define QT_DECLARE_STRONGLY_ORDERED_9(...)
814#define Q_DECLARE_STRONGLY_ORDERED(...)
815 QT_OVERLOADED_MACRO(QT_DECLARE_STRONGLY_ORDERED, __VA_ARGS__)
817#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_1(Type)
821#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_2(LeftType, RightType)
827#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType, ...)
831 noexcept(true), __VA_ARGS__)
833#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_4(...)
835#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_5(...)
837#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_6(...)
839#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_7(...)
841#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_8(...)
843#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_9(...)
846#define Q_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE(...)
847 QT_OVERLOADED_MACRO(QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE, __VA_ARGS__)
849#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_1(Type)
853#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_2(LeftType, RightType)
860#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_3(LeftType, RightType, ...)
862 noexcept(false), __VA_ARGS__)
864 , noexcept(false), __VA_ARGS__)
866#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_4(...)
868#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_5(...)
870#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_6(...)
872#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_7(...)
874#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_8(...)
876#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_9(...)
879#define Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(...)
880 QT_OVERLOADED_MACRO(QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT, __VA_ARGS__)
891#if QFLOAT16_IS_NATIVE
900template <
typename T,
typename U>
904#ifdef __cpp_lib_three_way_comparison
908 return Qt::strong_ordering::equivalent;
910 return Qt::strong_ordering::less;
912 return Qt::strong_ordering::greater;
926template <
typename T,
typename U>
933template <
typename Enum>
936template <
typename LeftInt,
typename RightInt,
937 if_integral<LeftInt> =
true,
938 if_integral<RightInt> =
true>
941 static_assert(
std::is_signed_v<LeftInt> ==
std::is_signed_v<RightInt>,
942 "Qt::compareThreeWay() does not allow mixed-sign comparison.");
944#ifdef __cpp_lib_three_way_comparison
948 return Qt::strong_ordering::equivalent;
950 return Qt::strong_ordering::less;
952 return Qt::strong_ordering::greater;
956template <
typename LeftFloat,
typename RightFloat,
957 if_floating_point<LeftFloat> =
true,
958 if_floating_point<RightFloat> =
true>
962QT_WARNING_DISABLE_FLOAT_COMPARE
963#ifdef __cpp_lib_three_way_comparison
967 return Qt::partial_ordering::less;
969 return Qt::partial_ordering::greater;
971 return Qt::partial_ordering::equivalent;
973 return Qt::partial_ordering::unordered;
978template <
typename IntType,
typename FloatType,
979 if_integral<IntType> =
true,
980 if_floating_point<FloatType> =
true>
983 return compareThreeWay(FloatType(lhs), rhs);
986template <
typename FloatType,
typename IntType,
987 if_floating_point<FloatType> =
true,
988 if_integral<IntType> =
true>
991 return compareThreeWay(lhs, FloatType(rhs));
994#if QT_DEPRECATED_SINCE(6
, 8
)
1001#ifdef __cpp_lib_three_way_comparison
1013template <
typename T>
1020template <
typename T>
1029template <
class Enum, if_enum<Enum> =
true>
1032 return compareThreeWay(qToUnderlying(lhs), qToUnderlying(rhs));
1038template <
typename Head,
typename...Tail,
std::size_t...Is>
1042 return std::tuple<Tail...>(
std::get<Is + 1>(t)...);
1045template <
typename Head,
typename...Tail>
1048 return qt_tuple_pop_front_impl(t, std::index_sequence_for<Tail...>{});
1051template <
typename LhsHead,
typename...LhsTail,
typename RhsHead,
typename...RhsTail>
1053 const std::tuple<RhsHead, RhsTail...> &rhs)
noexcept
1055 static_assert(
sizeof...(LhsTail) ==
sizeof...(RhsTail),
1057 "The tuple arguments have to have the same size.");
1059 using Qt::compareThreeWay;
1060 using R = std::common_type_t<
1061 decltype(compareThreeWay(std::declval<LhsHead>(), std::declval<RhsHead>())),
1062 decltype(compareThreeWay(std::declval<LhsTail>(), std::declval<RhsTail>()))...
1065 const auto &l =
std::get<0>(lhs);
1066 const auto &r =
std::get<0>(rhs);
1067 static_assert(
noexcept(compareThreeWay(l, r)),
1068 "This function requires all relational operators to be noexcept.");
1069 const auto res = compareThreeWay(l, r);
1070 if constexpr (
sizeof...(LhsTail) > 0) {
1072 return R{compareThreeWayMulti(qt_tuple_pop_front(lhs), qt_tuple_pop_front(rhs))};
1086template <
typename P>
1089 static_assert(
std::is_pointer_v<P>);
1100 constexpr P
get()
const noexcept {
return ptr; }
1101 constexpr void reset(P p)
noexcept { ptr = p; }
1103 template <
typename U =
T, std::enable_if_t<!std::is_void_v<U>,
bool> =
true>
1111 template <
typename T,
typename U>
1119#define MAKE_RELOP(Ret, op, Op)
1120 template <typename U = P, if_compatible_types<P, U> = true>
1121 friend constexpr Ret operator
op (const totally_ordered_wrapper<P> &lhs, const totally_ordered_wrapper<U> &rhs) noexcept
1122 { return std:: Op {}(lhs.ptr, rhs.get()); }
1123 template <typename U = P, if_compatible_types<P, U> = true>
1124 friend constexpr Ret operator
op (const totally_ordered_wrapper<P> &lhs, const U &rhs) noexcept
1125 { return std:: Op {}(lhs.ptr, rhs ); }
1126 template <typename U = P, if_compatible_types<P, U> = true>
1127 friend constexpr Ret operator
op (const U &lhs, const totally_ordered_wrapper<P> &rhs) noexcept
1128 { return std:: Op {}(lhs, rhs.ptr); }
1129 friend constexpr Ret operator
op (const totally_ordered_wrapper &lhs, std::nullptr_t) noexcept
1130 { return std:: Op {}(lhs.ptr, P(nullptr)); }
1131 friend constexpr Ret operator
op (std::nullptr_t, const totally_ordered_wrapper &rhs) noexcept
1132 { return std:: Op {}(P(nullptr), rhs.ptr); }
1140#ifdef __cpp_lib_three_way_comparison
1145 { qt_ptr_swap(lhs.ptr, rhs.ptr); }
1147 { qt_ptr_swap(lhs, rhs); }
1149 {
return qHash(key.ptr, seed); }
1152template <
typename T,
typename U, if_compatible_pointers<T, U> =
true>
1159template <
typename T,
typename U, if_compatible_pointers<T, U> =
true>
1166template <
typename T,
typename U, if_compatible_pointers<T, U> =
true>
1173template <
typename T>
1180template <
typename T>
1189template <
typename P>
1196using Qt::compareThreeWay;
1198template <
typename T>
1203template <
typename LT,
typename RT,
typename =
void>
1206template <
typename LT,
typename RT>
1211template <
typename LT,
typename RT>
1218template <
typename LT,
typename RT>
1226template <
typename LT,
typename RT,
1227 std::enable_if_t<hasCompareThreeWay_v<LT, RT>,
bool> =
true>
1229{
return noexcept(compareThreeWay(
std::declval<LT>(),
std::declval<RT>())); }
1231template <
typename LT,
typename RT,
1240#ifdef __cpp_lib_three_way_comparison
1242 template <
typename LT,
typename RT =
LT>
1272template <
typename LT,
typename RT = LT,
typename =
void>
1275template <
typename LT,
typename RT>
1281template <
typename InputIt1,
typename InputIt2,
typename Compare>
1283 InputIt2 first2, InputIt2 last2,
1286 using R =
decltype(cmp(*first1, *first2));
1288 while (first1 != last1) {
1289 if (first2 == last2)
1291 const auto r = cmp(*first1, *first2);
1297 return first2 == last2 ? R::equivalent : R::less;
1300template <
typename InputIt1,
typename InputIt2>
1302 InputIt2 first2, InputIt2 last2)
1304 using LT =
typename std::iterator_traits<InputIt1>::value_type;
1305 using RT =
typename std::iterator_traits<InputIt2>::value_type;
1310 constexpr bool UseWrapper =
1311 std::conjunction_v<std::is_pointer<LT>, std::is_pointer<RT>,
1312 std::negation<HasCustomCompareThreeWay<LT, RT>>,
1313 std::negation<HasCustomCompareThreeWay<RT, LT>>>;
1314 using WrapLT = std::conditional_t<UseWrapper,
1315 Qt::totally_ordered_wrapper<LT>,
1317 using WrapRT = std::conditional_t<UseWrapper,
1318 Qt::totally_ordered_wrapper<RT>,
1321 auto cmp = [](LT
const &lhs, RT
const &rhs) {
1322 using Qt::compareThreeWay;
1326 if constexpr (Test::hasCompareThreeWay_v<WrapLT, WrapRT>)
1327 return compareThreeWay(WrapLT(lhs), WrapRT(rhs));
1329 return QtOrderingPrivate::reversed(compareThreeWay(WrapRT(rhs), WrapLT(lhs)));
1331 return lexicographicalCompareThreeWay(first1, last1, first2, last2, cmp);
1338template <
typename T,
typename U>
1350 template <
typename P>
\inmodule QtCore \inheaderfile QtCompare
constexpr void reset(P p) noexcept
totally_ordered_wrapper() noexcept=default
constexpr operator bool() const noexcept
friend void qt_ptr_swap(totally_ordered_wrapper &lhs, totally_ordered_wrapper &rhs) noexcept
friend void swap(totally_ordered_wrapper &lhs, totally_ordered_wrapper &rhs) noexcept
constexpr U & operator*() const noexcept
constexpr P get() const noexcept
constexpr P operator->() const noexcept
friend size_t qHash(totally_ordered_wrapper key, size_t seed=0) noexcept
constexpr totally_ordered_wrapper(P p) noexcept
constexpr bool compareThreeWayNoexcept() noexcept
constexpr bool hasCompareThreeWay_v
auto lexicographicalCompareThreeWay(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
constexpr std::tuple< Tail... > qt_tuple_pop_front(const std::tuple< Head, Tail... > &t) noexcept
auto lexicographicalCompareThreeWay(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare cmp)
constexpr auto compareThreeWayMulti(const std::tuple< LhsHead, LhsTail... > &lhs, const std::tuple< RhsHead, RhsTail... > &rhs) noexcept
constexpr std::tuple< Tail... > qt_tuple_pop_front_impl(const std::tuple< Head, Tail... > &t, std::index_sequence< Is... >) noexcept
constexpr std::enable_if_t< is_qt_ordering_type_v< T >, QtOrderingTypeFlag > orderingFlagsFor(T t) noexcept
constexpr bool is_std_ordering_type_v
constexpr Qt::strong_ordering strongOrderingCompareDefaultImpl(T lhs, U rhs) noexcept
constexpr bool is_qt_ordering_type_v
constexpr bool IsFloatType_v
constexpr bool IsIntegralType_v
constexpr Qt::strong_ordering compareThreeWay(Enum lhs, Enum rhs) noexcept
constexpr Qt::strong_ordering compareThreeWay(Qt::totally_ordered_wrapper< T * > lhs, Qt::totally_ordered_wrapper< U * > rhs) noexcept
constexpr Qt::strong_ordering compareThreeWay(std::nullptr_t lhs, Qt::totally_ordered_wrapper< T * > rhs) noexcept
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
constexpr Qt::strong_ordering compareThreeWay(U *lhs, Qt::totally_ordered_wrapper< T * > rhs) noexcept
constexpr Qt::strong_ordering compareThreeWay(Qt::totally_ordered_wrapper< T * > lhs, std::nullptr_t rhs) noexcept
constexpr Qt::strong_ordering compareThreeWay(Qt::totally_ordered_wrapper< T * > lhs, U *rhs) noexcept
#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType,...)
#define QT_DECLARE_ORDERING_OPERATORS_HELPER(OrderingString, LeftType, RightType, Constexpr, Noexcept,...)
#define QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr, Noexcept,...)
#define QT_DECLARE_PARTIALLY_ORDERED_3(LeftType, RightType,...)
#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_3(LeftType, RightType,...)
#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType,...)
#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_3(LeftType, RightType,...)
#define QT_DECLARE_ORDERED_NON_NOEXCEPT_3(LeftType, RightType,...)
#define QT_DECLARE_ORDERED_LITERAL_TYPE_3(LeftType, RightType,...)
#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType, Constexpr, Noexcept,...)
#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_3(LeftType, RightType,...)
#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_3(LeftType, RightType,...)
#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType,...)
#define QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, Func)
#define QT_DECLARE_EQUALITY_COMPARABLE_3(LeftType, RightType,...)
#define QT_DECLARE_ORDERING_HELPER_TEMPLATE(OrderingType, LeftType, RightType, Constexpr, Noexcept,...)
#define QT_DECLARE_ORDERED_3(LeftType, RightType,...)
#define QT_DECLARE_REVERSED_ORDERING_HELPER_TEMPLATE(OrderingType, LeftType, RightType, Constexpr, Noexcept,...)
#define QT_DECLARE_STRONGLY_ORDERED_3(LeftType, RightType,...)
#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_3(LeftType, RightType,...)
#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr, Noexcept,...)
#define MAKE_RELOP(Ret, op, Op)
#define QT_DECLARE_WEAKLY_ORDERED_3(LeftType, RightType,...)