6#error "Do not include qcomparehelpers.h directly. Use qcompare.h instead."
9#ifndef QCOMPAREHELPERS_H
10#define QCOMPAREHELPERS_H
13#pragma qt_no_master_include
14#pragma qt_sync_skip_header_check
15#pragma qt_sync_stop_processing
18#include <QtCore/qflags.h>
19#include <QtCore/qoverload.h>
20#include <QtCore/qttypetraits.h>
21#include <QtCore/qtypeinfo.h>
22#include <QtCore/qtypes.h>
24#ifdef __cpp_lib_three_way_comparison
27#include <QtCore/q20type_traits.h>
33class QPartialOrdering;
56#ifdef __cpp_lib_three_way_comparison
58 template <> struct StdOrdering< Qt::x##_ordering> : q20::type_identity<std::x##_ordering> {};
59 template <> struct StdOrdering<std::x##_ordering> : q20::type_identity<std::x##_ordering> {};
60 template <> struct QtOrdering<std::x##_ordering> : q20::type_identity< Qt::x##_ordering> {};
61 template <> struct QtOrdering< Qt::x##_ordering> : q20::type_identity< Qt::x##_ordering> {};
62 template <> struct is_std_ordering_type<std::x##_ordering> : std::true_type {};
63 template <> struct is_qt_ordering_type< Qt::x##_ordering> : std::true_type {};
95 Qt::partial_ordering convertedOrder(t);
96 if constexpr (std::is_same_v<T, Qt::strong_ordering>)
98 else if constexpr (std::is_same_v<T, Qt::partial_ordering>)
100 else if constexpr (std::is_same_v<T, Qt::weak_ordering>)
110 return QtOrderingTypeFlag(flags
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
146
149
150
151
152
153
154
155
156
157
158#if defined(__cpp_lib_three_way_comparison) || !(defined(Q_OS_QNX) || defined(Q_CC_GHS))
159# define QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, Func)
160 constexpr auto f = []() Noexcept {};
161 static_assert(!noexcept(f()) || noexcept(Func(lhs, rhs)),
162 "Use *_NON_NOEXCEPT version of the macro, "
163 "or make the helper function noexcept")
165# define QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, Func)
173#if defined(__cpp_lib_three_way_comparison) && !defined(Q_QDOC)
176#define QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr,
179 friend Constexpr bool operator
==(LeftType const &lhs, RightType const &rhs) Noexcept
181 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, comparesEqual);
182 return comparesEqual(lhs, rhs);
185#define QT_DECLARE_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr, Noexcept, ...)
187 friend Constexpr std::strong_ordering
188 operator
<=>(LeftType const &lhs, RightType const &rhs) Noexcept
190 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, compareThreeWay);
191 return compareThreeWay(lhs, rhs);
194#define QT_DECLARE_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr, Noexcept, ...)
196 friend Constexpr std::weak_ordering
197 operator
<=>(LeftType const &lhs, RightType const &rhs) Noexcept
199 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, compareThreeWay);
200 return compareThreeWay(lhs, rhs);
203#define QT_DECLARE_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr, Noexcept, ...)
205 friend Constexpr std::partial_ordering
206 operator
<=>(LeftType const &lhs, RightType const &rhs) Noexcept
208 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, compareThreeWay);
209 return compareThreeWay(lhs, rhs);
212#define QT_DECLARE_ORDERING_HELPER_AUTO(LeftType, RightType, Constexpr, Noexcept, ...)
214 friend Constexpr auto
215 operator
<=>(LeftType const &lhs, RightType const &rhs) Noexcept
217 QT_COMPARISON_NOEXCEPT_CHECK(Noexcept, compareThreeWay);
218 return QtOrderingPrivate::to_std(compareThreeWay(lhs, rhs));
221#define QT_DECLARE_ORDERING_OPERATORS_HELPER(OrderingType, LeftType, RightType, Constexpr,
223 QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr, Noexcept, __VA_ARGS__)
224 QT_DECLARE_ORDERING_HELPER_ ## OrderingType (LeftType, RightType, Constexpr, Noexcept,
227#ifdef Q_COMPILER_LACKS_THREE_WAY_COMPARE_SYMMETRY
230#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr,
233 friend Constexpr bool operator
==(RightType const &lhs, LeftType const &rhs) Noexcept
234 { return comparesEqual(rhs, lhs); }
236#define QT_DECLARE_REVERSED_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr,
239 friend Constexpr std::strong_ordering
240 operator
<=>(RightType const &lhs, LeftType const &rhs) Noexcept
242 const auto r = compareThreeWay(rhs, lhs);
243 return QtOrderingPrivate::reversed(r);
246#define QT_DECLARE_REVERSED_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr,
249 friend Constexpr std::weak_ordering
250 operator
<=>(RightType const &lhs, LeftType const &rhs) Noexcept
252 const auto r = compareThreeWay(rhs, lhs);
253 return QtOrderingPrivate::reversed(r);
256#define QT_DECLARE_REVERSED_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr,
259 friend Constexpr std::partial_ordering
260 operator
<=>(RightType const &lhs, LeftType const &rhs) Noexcept
262 const auto r = compareThreeWay(rhs, lhs);
263 return QtOrderingPrivate::reversed(r);
266#define QT_DECLARE_REVERSED_ORDERING_HELPER_AUTO(LeftType, RightType, Constexpr, Noexcept, ...)
268 friend Constexpr auto
269 operator
<=>(RightType const &lhs, LeftType const &rhs) Noexcept
271 const auto r = compareThreeWay(rhs, lhs);
272 return QtOrderingPrivate::to_std(QtOrderingPrivate::reversed(r));
275#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType,
276 Constexpr, Noexcept, ...)
277 QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr,
278 Noexcept, __VA_ARGS__)
279 QT_DECLARE_REVERSED_ORDERING_HELPER_ ## OrderingString (LeftType, RightType, Constexpr,
280 Noexcept, __VA_ARGS__)
285#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr,
287#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType,
288 Constexpr, Noexcept, ...)
296#define QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr,
299 friend Constexpr bool operator
==(LeftType const &lhs, RightType const &rhs) Noexcept
302 return comparesEqual(lhs, rhs);
305 friend Constexpr bool operator
!=(LeftType const &lhs, RightType const &rhs) Noexcept
306 { return !comparesEqual(lhs, rhs); }
309#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr,
312 friend Constexpr bool operator
==(RightType const &lhs, LeftType const &rhs) Noexcept
313 { return comparesEqual(rhs, lhs); }
315 friend Constexpr bool operator
!=(RightType const &lhs, LeftType const &rhs) Noexcept
316 { return !comparesEqual(rhs, lhs); }
318#define QT_DECLARE_ORDERING_HELPER_TEMPLATE(OrderingType, LeftType, RightType, Constexpr,
321 friend Constexpr bool operator
<(LeftType const &lhs, RightType const &rhs) Noexcept
324 return is_lt(compareThreeWay(lhs, rhs));
327 friend Constexpr bool operator
>(LeftType const &lhs, RightType const &rhs) Noexcept
328 { return is_gt(compareThreeWay(lhs, rhs)); }
330 friend Constexpr bool operator
<=(LeftType const &lhs, RightType const &rhs) Noexcept
331 { return is_lteq(compareThreeWay(lhs, rhs)); }
333 friend Constexpr bool operator
>=(LeftType const &lhs, RightType const &rhs) Noexcept
334 { return is_gteq(compareThreeWay(lhs, rhs)); }
336#define QT_DECLARE_ORDERING_HELPER_AUTO(LeftType, RightType, Constexpr, Noexcept, ...)
340#define QT_DECLARE_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr, Noexcept, ...)
342 Noexcept, __VA_ARGS__)
344#define QT_DECLARE_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr, Noexcept, ...)
346 Noexcept, __VA_ARGS__)
348#define QT_DECLARE_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr, Noexcept, ...)
350 Noexcept, __VA_ARGS__)
352#define QT_DECLARE_ORDERING_OPERATORS_HELPER(OrderingString, LeftType, RightType, Constexpr,
355 QT_DECLARE_ORDERING_HELPER_ ## OrderingString (LeftType, RightType, Constexpr, Noexcept,
359#define QT_DECLARE_REVERSED_ORDERING_HELPER_TEMPLATE(OrderingType, LeftType, RightType, Constexpr,
362 friend Constexpr bool operator
<(RightType const &lhs, LeftType const &rhs) Noexcept
363 { return is_gt(compareThreeWay(rhs, lhs)); }
365 friend Constexpr bool operator
>(RightType const &lhs, LeftType const &rhs) Noexcept
366 { return is_lt(compareThreeWay(rhs, lhs)); }
368 friend Constexpr bool operator
<=(RightType const &lhs, LeftType const &rhs) Noexcept
369 { return is_gteq(compareThreeWay(rhs, lhs)); }
371 friend Constexpr bool operator
>=(RightType const &lhs, LeftType const &rhs) Noexcept
372 { return is_lteq(compareThreeWay(rhs, lhs)); }
374#define QT_DECLARE_REVERSED_ORDERING_HELPER_AUTO(LeftType, RightType, Constexpr, Noexcept, ...)
378#define QT_DECLARE_REVERSED_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr, Noexcept, ...)
380 Constexpr, Noexcept, __VA_ARGS__)
382#define QT_DECLARE_REVERSED_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr, Noexcept, ...)
384 Constexpr, Noexcept, __VA_ARGS__)
386#define QT_DECLARE_REVERSED_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr, Noexcept, ...)
388 Constexpr, Noexcept, __VA_ARGS__)
390#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType,
391 Constexpr, Noexcept, ...)
394 QT_DECLARE_REVERSED_ORDERING_HELPER_ ## OrderingString (LeftType, RightType, Constexpr,
395 Noexcept, __VA_ARGS__)
402#define QT_DECLARE_EQUALITY_COMPARABLE_1(Type)
406#define QT_DECLARE_EQUALITY_COMPARABLE_2(LeftType, RightType)
412#define QT_DECLARE_EQUALITY_COMPARABLE_3(LeftType, RightType, ...)
414 noexcept(true), __VA_ARGS__)
416 noexcept(true), __VA_ARGS__)
418#define QT_DECLARE_EQUALITY_COMPARABLE_4(...)
420#define QT_DECLARE_EQUALITY_COMPARABLE_5(...)
422#define QT_DECLARE_EQUALITY_COMPARABLE_6(...)
424#define QT_DECLARE_EQUALITY_COMPARABLE_7(...)
426#define QT_DECLARE_EQUALITY_COMPARABLE_8(...)
428#define QT_DECLARE_EQUALITY_COMPARABLE_9(...)
431#define Q_DECLARE_EQUALITY_COMPARABLE(...)
432 QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE, __VA_ARGS__)
434#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_1(Type)
438#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_2(LeftType, RightType)
444#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_3(LeftType, RightType, ...)
450#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_4(...)
452#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_5(...)
454#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_6(...)
456#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_7(...)
458#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_8(...)
460#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_9(...)
463#define Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE(...)
464 QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE, __VA_ARGS__)
466#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_1(Type)
470#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_2(LeftType, RightType)
476#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_3(LeftType, RightType, ...)
478 noexcept(false), __VA_ARGS__)
480 noexcept(false), __VA_ARGS__)
482#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_4(...)
484#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_5(...)
486#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_6(...)
488#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_7(...)
490#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_8(...)
492#define QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT_9(...)
495#define Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(...)
496 QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT, __VA_ARGS__)
499#define QT_DECLARE_ORDERED_1(Type)
503#define QT_DECLARE_ORDERED_2(LeftType, RightType)
509#define QT_DECLARE_ORDERED_3(LeftType, RightType, ...)
511 noexcept(true), __VA_ARGS__)
513 noexcept(true), __VA_ARGS__)
522#define Q_DECLARE_ORDERED(...) QT_OVERLOADED_MACRO(QT_DECLARE_ORDERED, __VA_ARGS__)
524#define QT_DECLARE_ORDERED_LITERAL_TYPE_1(Type)
528#define QT_DECLARE_ORDERED_LITERAL_TYPE_2(LeftType, RightType)
534#define QT_DECLARE_ORDERED_LITERAL_TYPE_3(LeftType, RightType, ...)
536 noexcept(true), __VA_ARGS__)
538 noexcept(true), __VA_ARGS__)
540#define QT_DECLARE_ORDERED_LITERAL_TYPE_4(...)
542#define QT_DECLARE_ORDERED_LITERAL_TYPE_5(...)
544#define QT_DECLARE_ORDERED_LITERAL_TYPE_6(...)
546#define QT_DECLARE_ORDERED_LITERAL_TYPE_7(...)
548#define QT_DECLARE_ORDERED_LITERAL_TYPE_8(...)
550#define QT_DECLARE_ORDERED_LITERAL_TYPE_9(...)
553#define Q_DECLARE_ORDERED_LITERAL_TYPE(...)
554 QT_OVERLOADED_MACRO(QT_DECLARE_ORDERED_LITERAL_TYPE, __VA_ARGS__)
556#define QT_DECLARE_ORDERED_NON_NOEXCEPT_1(Type)
560#define QT_DECLARE_ORDERED_NON_NOEXCEPT_2(LeftType, RightType)
566#define QT_DECLARE_ORDERED_NON_NOEXCEPT_3(LeftType, RightType, ...)
568 noexcept(false), __VA_ARGS__)
570 noexcept(false), __VA_ARGS__)
572#define QT_DECLARE_ORDERED_NON_NOEXCEPT_4(...)
574#define QT_DECLARE_ORDERED_NON_NOEXCEPT_5(...)
576#define QT_DECLARE_ORDERED_NON_NOEXCEPT_6(...)
578#define QT_DECLARE_ORDERED_NON_NOEXCEPT_7(...)
580#define QT_DECLARE_ORDERED_NON_NOEXCEPT_8(...)
582#define QT_DECLARE_ORDERED_NON_NOEXCEPT_9(...)
585#define Q_DECLARE_ORDERED_NON_NOEXCEPT(...)
586 QT_OVERLOADED_MACRO(QT_DECLARE_ORDERED_NON_NOEXCEPT, __VA_ARGS__)
589#define QT_DECLARE_PARTIALLY_ORDERED_1(Type)
593#define QT_DECLARE_PARTIALLY_ORDERED_2(LeftType, RightType)
600#define QT_DECLARE_PARTIALLY_ORDERED_3(LeftType, RightType, ...)
602 noexcept(true), __VA_ARGS__)
604 , noexcept(true), __VA_ARGS__)
606#define QT_DECLARE_PARTIALLY_ORDERED_4(...)
608#define QT_DECLARE_PARTIALLY_ORDERED_5(...)
610#define QT_DECLARE_PARTIALLY_ORDERED_6(...)
612#define QT_DECLARE_PARTIALLY_ORDERED_7(...)
614#define QT_DECLARE_PARTIALLY_ORDERED_8(...)
616#define QT_DECLARE_PARTIALLY_ORDERED_9(...)
619#define Q_DECLARE_PARTIALLY_ORDERED(...)
620 QT_OVERLOADED_MACRO(QT_DECLARE_PARTIALLY_ORDERED, __VA_ARGS__)
622#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_1(Type)
626#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_2(LeftType, RightType)
632#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType, ...)
636 noexcept(true), __VA_ARGS__)
638#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_4(...)
640#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_5(...)
642#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_6(...)
644#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_7(...)
646#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_8(...)
648#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_9(...)
651#define Q_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE(...)
652 QT_OVERLOADED_MACRO(QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE, __VA_ARGS__)
654#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_1(Type)
658#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_2(LeftType, RightType)
665#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_3(LeftType, RightType, ...)
667 noexcept(false), __VA_ARGS__)
669 , noexcept(false), __VA_ARGS__)
671#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_4(...)
673#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_5(...)
675#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_6(...)
677#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_7(...)
679#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_8(...)
681#define QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT_9(...)
684#define Q_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT(...)
685 QT_OVERLOADED_MACRO(QT_DECLARE_PARTIALLY_ORDERED_NON_NOEXCEPT, __VA_ARGS__)
688#define QT_DECLARE_WEAKLY_ORDERED_1(Type)
692#define QT_DECLARE_WEAKLY_ORDERED_2(LeftType, RightType)
698#define QT_DECLARE_WEAKLY_ORDERED_3(LeftType, RightType, ...)
700 noexcept(true), __VA_ARGS__)
702 noexcept(true), __VA_ARGS__)
704#define QT_DECLARE_WEAKLY_ORDERED_4(...)
706#define QT_DECLARE_WEAKLY_ORDERED_5(...)
708#define QT_DECLARE_WEAKLY_ORDERED_6(...)
710#define QT_DECLARE_WEAKLY_ORDERED_7(...)
712#define QT_DECLARE_WEAKLY_ORDERED_8(...)
714#define QT_DECLARE_WEAKLY_ORDERED_9(...)
717#define Q_DECLARE_WEAKLY_ORDERED(...)
718 QT_OVERLOADED_MACRO(QT_DECLARE_WEAKLY_ORDERED, __VA_ARGS__)
720#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_1(Type)
724#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_2(LeftType, RightType)
730#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType, ...)
734 noexcept(true), __VA_ARGS__)
736#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_4(...)
738#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_5(...)
740#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_6(...)
742#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_7(...)
744#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_8(...)
746#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_9(...)
749#define Q_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE(...)
750 QT_OVERLOADED_MACRO(QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE, __VA_ARGS__)
752#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_1(Type)
756#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_2(LeftType, RightType)
762#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_3(LeftType, RightType, ...)
764 noexcept(false), __VA_ARGS__)
766 noexcept(false), __VA_ARGS__)
768#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_4(...)
770#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_5(...)
772#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_6(...)
774#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_7(...)
776#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_8(...)
778#define QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT_9(...)
781#define Q_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT(...)
782 QT_OVERLOADED_MACRO(QT_DECLARE_WEAKLY_ORDERED_NON_NOEXCEPT, __VA_ARGS__)
785#define QT_DECLARE_STRONGLY_ORDERED_1(Type)
789#define QT_DECLARE_STRONGLY_ORDERED_2(LeftType, RightType)
796#define QT_DECLARE_STRONGLY_ORDERED_3(LeftType, RightType, ...)
798 noexcept(true), __VA_ARGS__)
800 , noexcept(true), __VA_ARGS__)
802#define QT_DECLARE_STRONGLY_ORDERED_4(...)
804#define QT_DECLARE_STRONGLY_ORDERED_5(...)
806#define QT_DECLARE_STRONGLY_ORDERED_6(...)
808#define QT_DECLARE_STRONGLY_ORDERED_7(...)
810#define QT_DECLARE_STRONGLY_ORDERED_8(...)
812#define QT_DECLARE_STRONGLY_ORDERED_9(...)
815#define Q_DECLARE_STRONGLY_ORDERED(...)
816 QT_OVERLOADED_MACRO(QT_DECLARE_STRONGLY_ORDERED, __VA_ARGS__)
818#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_1(Type)
822#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_2(LeftType, RightType)
828#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType, ...)
832 noexcept(true), __VA_ARGS__)
834#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_4(...)
836#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_5(...)
838#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_6(...)
840#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_7(...)
842#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_8(...)
844#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_9(...)
847#define Q_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE(...)
848 QT_OVERLOADED_MACRO(QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE, __VA_ARGS__)
850#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_1(Type)
854#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_2(LeftType, RightType)
861#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_3(LeftType, RightType, ...)
863 noexcept(false), __VA_ARGS__)
865 , noexcept(false), __VA_ARGS__)
867#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_4(...)
869#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_5(...)
871#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_6(...)
873#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_7(...)
875#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_8(...)
877#define QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT_9(...)
880#define Q_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT(...)
881 QT_OVERLOADED_MACRO(QT_DECLARE_STRONGLY_ORDERED_NON_NOEXCEPT, __VA_ARGS__)
892#if QFLOAT16_IS_NATIVE
901template <
typename T,
typename U>
905#ifdef __cpp_lib_three_way_comparison
909 return Qt::strong_ordering::equivalent;
911 return Qt::strong_ordering::less;
913 return Qt::strong_ordering::greater;
927template <
typename T,
typename U>
934template <
typename Enum>
937template <
typename LeftInt,
typename RightInt,
938 if_integral<LeftInt> =
true,
939 if_integral<RightInt> =
true>
942 static_assert(
std::is_signed_v<LeftInt> ==
std::is_signed_v<RightInt>,
943 "Qt::compareThreeWay() does not allow mixed-sign comparison.");
945#ifdef __cpp_lib_three_way_comparison
949 return Qt::strong_ordering::equivalent;
951 return Qt::strong_ordering::less;
953 return Qt::strong_ordering::greater;
957template <
typename LeftFloat,
typename RightFloat,
958 if_floating_point<LeftFloat> =
true,
959 if_floating_point<RightFloat> =
true>
963QT_WARNING_DISABLE_FLOAT_COMPARE
964#ifdef __cpp_lib_three_way_comparison
968 return Qt::partial_ordering::less;
970 return Qt::partial_ordering::greater;
972 return Qt::partial_ordering::equivalent;
974 return Qt::partial_ordering::unordered;
979template <
typename IntType,
typename FloatType,
980 if_integral<IntType> =
true,
981 if_floating_point<FloatType> =
true>
984 return compareThreeWay(FloatType(lhs), rhs);
987template <
typename FloatType,
typename IntType,
988 if_floating_point<FloatType> =
true,
989 if_integral<IntType> =
true>
992 return compareThreeWay(lhs, FloatType(rhs));
995#if QT_DEPRECATED_SINCE(6
, 8
)
1002#ifdef __cpp_lib_three_way_comparison
1014template <
typename T>
1021template <
typename T>
1030template <
class Enum, if_enum<Enum> =
true>
1033 return compareThreeWay(qToUnderlying(lhs), qToUnderlying(rhs));
1039template <
typename Head,
typename...Tail,
std::size_t...Is>
1043 return std::tuple<Tail...>(
std::get<Is + 1>(t)...);
1046template <
typename Head,
typename...Tail>
1049 return qt_tuple_pop_front_impl(t, std::index_sequence_for<Tail...>{});
1052template <
typename LhsHead,
typename...LhsTail,
typename RhsHead,
typename...RhsTail>
1054 const std::tuple<RhsHead, RhsTail...> &rhs)
noexcept
1056 static_assert(
sizeof...(LhsTail) ==
sizeof...(RhsTail),
1058 "The tuple arguments have to have the same size.");
1060 using Qt::compareThreeWay;
1061 using R = std::common_type_t<
1062 decltype(compareThreeWay(std::declval<LhsHead>(), std::declval<RhsHead>())),
1063 decltype(compareThreeWay(std::declval<LhsTail>(), std::declval<RhsTail>()))...
1066 const auto &l =
std::get<0>(lhs);
1067 const auto &r =
std::get<0>(rhs);
1068 static_assert(
noexcept(compareThreeWay(l, r)),
1069 "This function requires all relational operators to be noexcept.");
1070 const auto res = compareThreeWay(l, r);
1071 if constexpr (
sizeof...(LhsTail) > 0) {
1073 return R{compareThreeWayMulti(qt_tuple_pop_front(lhs), qt_tuple_pop_front(rhs))};
1087template <
typename P>
1090 static_assert(
std::is_pointer_v<P>);
1101 constexpr P
get()
const noexcept {
return ptr; }
1102 constexpr void reset(P p)
noexcept { ptr = p; }
1104 template <
typename U =
T, std::enable_if_t<!std::is_void_v<U>,
bool> =
true>
1112 template <
typename T,
typename U>
1120#define MAKE_RELOP(Ret, op, Op)
1121 template <typename U = P, if_compatible_types<P, U> = true>
1122 friend constexpr Ret operator
op (const totally_ordered_wrapper<P> &lhs, const totally_ordered_wrapper<U> &rhs) noexcept
1123 { return std:: Op {}(lhs.ptr, rhs.get()); }
1124 template <typename U = P, if_compatible_types<P, U> = true>
1125 friend constexpr Ret operator
op (const totally_ordered_wrapper<P> &lhs, const U &rhs) noexcept
1126 { return std:: Op {}(lhs.ptr, rhs ); }
1127 template <typename U = P, if_compatible_types<P, U> = true>
1128 friend constexpr Ret operator
op (const U &lhs, const totally_ordered_wrapper<P> &rhs) noexcept
1129 { return std:: Op {}(lhs, rhs.ptr); }
1130 friend constexpr Ret operator
op (const totally_ordered_wrapper &lhs, std::nullptr_t) noexcept
1131 { return std:: Op {}(lhs.ptr, P(nullptr)); }
1132 friend constexpr Ret operator
op (std::nullptr_t, const totally_ordered_wrapper &rhs) noexcept
1133 { return std:: Op {}(P(nullptr), rhs.ptr); }
1141#ifdef __cpp_lib_three_way_comparison
1146 { qt_ptr_swap(lhs.ptr, rhs.ptr); }
1148 { qt_ptr_swap(lhs, rhs); }
1150 {
return qHash(key.ptr, seed); }
1153template <
typename T,
typename U, if_compatible_pointers<T, U> =
true>
1160template <
typename T,
typename U, if_compatible_pointers<T, U> =
true>
1167template <
typename T,
typename U, if_compatible_pointers<T, U> =
true>
1174template <
typename T>
1181template <
typename T>
1190template <
typename P>
1196QT_WARNING_DISABLE_DEPRECATED
1200using Qt::compareThreeWay;
1202template <
typename T>
1207template <
typename LT,
typename RT,
typename =
void>
1210template <
typename LT,
typename RT>
1215template <
typename LT,
typename RT>
1222template <
typename LT,
typename RT>
1230template <
typename LT,
typename RT,
1231 std::enable_if_t<hasCompareThreeWay_v<LT, RT>,
bool> =
true>
1233{
return noexcept(compareThreeWay(
std::declval<LT>(),
std::declval<RT>())); }
1235template <
typename LT,
typename RT,
1246#ifdef __cpp_lib_three_way_comparison
1248 template <
typename LT,
typename RT =
LT>
1278template <
typename LT,
typename RT =
LT,
typename =
void>
1281template <
typename LT,
typename RT>
1287template <
typename InputIt1,
typename InputIt2,
typename Compare>
1289 InputIt2 first2, InputIt2 last2,
1292 using R =
decltype(cmp(*first1, *first2));
1294 while (first1 != last1) {
1295 if (first2 == last2)
1297 const auto r = cmp(*first1, *first2);
1303 return first2 == last2 ? R::equivalent : R::less;
1306template <
typename InputIt1,
typename InputIt2>
1308 InputIt2 first2, InputIt2 last2)
1310 using LT =
typename std::iterator_traits<InputIt1>::value_type;
1311 using RT =
typename std::iterator_traits<InputIt2>::value_type;
1316 constexpr bool UseWrapper =
1317 std::conjunction_v<
std::is_pointer<LT>,
std::is_pointer<RT>,
1320 using WrapLT = std::conditional_t<UseWrapper,
1321 Qt::totally_ordered_wrapper<LT>,
1323 using WrapRT = std::conditional_t<UseWrapper,
1324 Qt::totally_ordered_wrapper<RT>,
1327 auto cmp = [](LT
const &lhs, RT
const &rhs) {
1328 using Qt::compareThreeWay;
1332 if constexpr (Test::hasCompareThreeWay_v<WrapLT, WrapRT>)
1333 return compareThreeWay(WrapLT(lhs), WrapRT(rhs));
1335 return QtOrderingPrivate::reversed(compareThreeWay(WrapRT(rhs), WrapLT(lhs)));
1337 return lexicographicalCompareThreeWay(first1, last1, first2, last2, cmp);
1344template <
typename T,
typename U>
1356 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,...)