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/qoverload.h>
18#include <QtCore/qttypetraits.h>
19#include <QtCore/qtypeinfo.h>
20#include <QtCore/qtypes.h>
22#ifdef __cpp_lib_three_way_comparison
25#include <QtCore/q20type_traits.h>
34#ifdef __cpp_lib_three_way_comparison
36template <
typename QtOrdering>
struct StdOrdering;
37template <
typename StdOrdering>
struct QtOrdering;
39#define QT_STD_MAP(x) \
40 template <> struct StdOrdering< Qt::x##_ordering> : q20::type_identity<std::x##_ordering> {};\
41 template <> struct StdOrdering<std::x##_ordering> : q20::type_identity<std::x##_ordering> {};\
42 template <> struct QtOrdering<std::x##_ordering> : q20::type_identity< Qt::x##_ordering> {};\
43 template <> struct QtOrdering< Qt::x##_ordering> : q20::type_identity< Qt::x##_ordering> {};\
53template <
typename In>
constexpr auto to_std(In
in)
noexcept
54 ->
typename QtOrderingPrivate::StdOrdering<In>::type
57template <
typename In>
constexpr auto to_Qt(In
in)
noexcept
58 ->
typename QtOrderingPrivate::QtOrdering<In>::type
92#if defined(__cpp_lib_three_way_comparison) && !defined(Q_QDOC)
95#define QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr, Attributes) \
97 friend Constexpr bool operator==(LeftType const &lhs, RightType const &rhs) \
98 noexcept(noexcept(comparesEqual(lhs, rhs))) \
99 { return comparesEqual(lhs, rhs); }
101#define QT_DECLARE_3WAY_HELPER_STRONG(LeftType, RightType, Constexpr, Attributes) \
103 friend Constexpr std::strong_ordering \
104 operator<=>(LeftType const &lhs, RightType const &rhs) \
105 noexcept(noexcept(compareThreeWay(lhs, rhs))) \
107 return compareThreeWay(lhs, rhs); \
110#define QT_DECLARE_3WAY_HELPER_WEAK(LeftType, RightType, Constexpr, Attributes) \
112 friend Constexpr std::weak_ordering \
113 operator<=>(LeftType const &lhs, RightType const &rhs) \
114 noexcept(noexcept(compareThreeWay(lhs, rhs))) \
116 return compareThreeWay(lhs, rhs); \
119#define QT_DECLARE_3WAY_HELPER_PARTIAL(LeftType, RightType, Constexpr, Attributes) \
121 friend Constexpr std::partial_ordering \
122 operator<=>(LeftType const &lhs, RightType const &rhs) \
123 noexcept(noexcept(compareThreeWay(lhs, rhs))) \
125 return compareThreeWay(lhs, rhs); \
128#define QT_DECLARE_ORDERING_OPERATORS_HELPER(OrderingType, LeftType, RightType, Constexpr, \
130 QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr, Attributes) \
131 QT_DECLARE_3WAY_HELPER_ ## OrderingType (LeftType, RightType, Constexpr, Attributes)
133#ifdef Q_COMPILER_LACKS_THREE_WAY_COMPARE_SYMMETRY
136#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr, Attributes) \
138 friend Constexpr bool operator==(RightType const &lhs, LeftType const &rhs) \
139 noexcept(noexcept(comparesEqual(rhs, lhs))) \
140 { return comparesEqual(rhs, lhs); }
142#define QT_DECLARE_REVERSED_3WAY_HELPER_STRONG(LeftType, RightType, Constexpr, Attributes) \
144 friend Constexpr std::strong_ordering \
145 operator<=>(RightType const &lhs, LeftType const &rhs) \
146 noexcept(noexcept(compareThreeWay(rhs, lhs))) \
148 const auto r = compareThreeWay(rhs, lhs); \
149 if (is_gt(r)) return std::strong_ordering::less; \
150 if (is_lt(r)) return std::strong_ordering::greater; \
154#define QT_DECLARE_REVERSED_3WAY_HELPER_WEAK(LeftType, RightType, Constexpr, Attributes) \
156 friend Constexpr std::weak_ordering \
157 operator<=>(RightType const &lhs, LeftType const &rhs) \
158 noexcept(noexcept(compareThreeWay(rhs, lhs))) \
160 const auto r = compareThreeWay(rhs, lhs); \
161 if (is_gt(r)) return std::weak_ordering::less; \
162 if (is_lt(r)) return std::weak_ordering::greater; \
166#define QT_DECLARE_REVERSED_3WAY_HELPER_PARTIAL(LeftType, RightType, Constexpr, Attributes) \
168 friend Constexpr std::partial_ordering \
169 operator<=>(RightType const &lhs, LeftType const &rhs) \
170 noexcept(noexcept(compareThreeWay(rhs, lhs))) \
172 const auto r = compareThreeWay(rhs, lhs); \
173 if (is_gt(r)) return std::partial_ordering::less; \
174 if (is_lt(r)) return std::partial_ordering::greater; \
178#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType, \
179 Constexpr, Attributes) \
180 QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr, Attributes) \
181 QT_DECLARE_REVERSED_3WAY_HELPER_ ## OrderingString (LeftType, RightType, Constexpr, Attributes)
186#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr, Attributes)
187#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType, \
188 Constexpr, Attributes)
196#define QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr, Attributes) \
198 friend Constexpr bool operator==(LeftType const &lhs, RightType const &rhs) \
199 noexcept(noexcept(comparesEqual(lhs, rhs))) \
200 { return comparesEqual(lhs, rhs); } \
202 friend Constexpr bool operator!=(LeftType const &lhs, RightType const &rhs) \
203 noexcept(noexcept(comparesEqual(lhs, rhs))) \
204 { return !comparesEqual(lhs, rhs); }
207#define QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr, Attributes) \
209 friend Constexpr bool operator==(RightType const &lhs, LeftType const &rhs) \
210 noexcept(noexcept(comparesEqual(rhs, lhs))) \
211 { return comparesEqual(rhs, lhs); } \
213 friend Constexpr bool operator!=(RightType const &lhs, LeftType const &rhs) \
214 noexcept(noexcept(comparesEqual(rhs, lhs))) \
215 { return !comparesEqual(rhs, lhs); }
217#define QT_DECLARE_ORDERING_HELPER_TEMPLATE(OrderingType, LeftType, RightType, Constexpr, \
220 friend Constexpr bool operator<(LeftType const &lhs, RightType const &rhs) \
221 noexcept(noexcept(compareThreeWay(lhs, rhs))) \
222 { return is_lt(compareThreeWay(lhs, rhs)); } \
224 friend Constexpr bool operator>(LeftType const &lhs, RightType const &rhs) \
225 noexcept(noexcept(compareThreeWay(lhs, rhs))) \
226 { return is_gt(compareThreeWay(lhs, rhs)); } \
228 friend Constexpr bool operator<=(LeftType const &lhs, RightType const &rhs) \
229 noexcept(noexcept(compareThreeWay(lhs, rhs))) \
230 { return is_lteq(compareThreeWay(lhs, rhs)); } \
232 friend Constexpr bool operator>=(LeftType const &lhs, RightType const &rhs) \
233 noexcept(noexcept(compareThreeWay(lhs, rhs))) \
234 { return is_gteq(compareThreeWay(lhs, rhs)); }
236#define QT_DECLARE_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr, Attributes) \
237 QT_DECLARE_ORDERING_HELPER_TEMPLATE(Qt::partial_ordering, LeftType, RightType, Constexpr, \
240#define QT_DECLARE_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr, Attributes) \
241 QT_DECLARE_ORDERING_HELPER_TEMPLATE(Qt::weak_ordering, LeftType, RightType, Constexpr, \
244#define QT_DECLARE_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr, Attributes) \
245 QT_DECLARE_ORDERING_HELPER_TEMPLATE(Qt::strong_ordering, LeftType, RightType, Constexpr, \
248#define QT_DECLARE_ORDERING_OPERATORS_HELPER(OrderingString, LeftType, RightType, Constexpr, \
250 QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, Constexpr, Attributes) \
251 QT_DECLARE_ORDERING_HELPER_ ## OrderingString (LeftType, RightType, Constexpr, Attributes)
254#define QT_DECLARE_REVERSED_ORDERING_HELPER_TEMPLATE(OrderingType, LeftType, RightType, Constexpr, \
257 friend Constexpr bool operator<(RightType const &lhs, LeftType const &rhs) \
258 noexcept(noexcept(compareThreeWay(rhs, lhs))) \
259 { return is_gt(compareThreeWay(rhs, lhs)); } \
261 friend Constexpr bool operator>(RightType const &lhs, LeftType const &rhs) \
262 noexcept(noexcept(compareThreeWay(rhs, lhs))) \
263 { return is_lt(compareThreeWay(rhs, lhs)); } \
265 friend Constexpr bool operator<=(RightType const &lhs, LeftType const &rhs) \
266 noexcept(noexcept(compareThreeWay(rhs, lhs))) \
267 { return is_gteq(compareThreeWay(rhs, lhs)); } \
269 friend Constexpr bool operator>=(RightType const &lhs, LeftType const &rhs) \
270 noexcept(noexcept(compareThreeWay(rhs, lhs))) \
271 { return is_lteq(compareThreeWay(rhs, lhs)); }
273#define QT_DECLARE_REVERSED_ORDERING_HELPER_PARTIAL(LeftType, RightType, Constexpr, Attributes) \
274 QT_DECLARE_REVERSED_ORDERING_HELPER_TEMPLATE(Qt::partial_ordering, LeftType, RightType, \
275 Constexpr, Attributes)
277#define QT_DECLARE_REVERSED_ORDERING_HELPER_WEAK(LeftType, RightType, Constexpr, Attributes) \
278 QT_DECLARE_REVERSED_ORDERING_HELPER_TEMPLATE(Qt::weak_ordering, LeftType, RightType, \
279 Constexpr, Attributes)
281#define QT_DECLARE_REVERSED_ORDERING_HELPER_STRONG(LeftType, RightType, Constexpr, Attributes) \
282 QT_DECLARE_REVERSED_ORDERING_HELPER_TEMPLATE(Qt::strong_ordering, LeftType, RightType, \
283 Constexpr, Attributes)
285#define QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(OrderingString, LeftType, RightType, \
286 Constexpr, Attributes) \
287 QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, Constexpr, Attributes) \
288 QT_DECLARE_REVERSED_ORDERING_HELPER_ ## OrderingString (LeftType, RightType, Constexpr, \
296#define QT_DECLARE_EQUALITY_COMPARABLE_1(Type) \
297 QT_DECLARE_EQUALITY_OPERATORS_HELPER(Type, Type, , )
299#define QT_DECLARE_EQUALITY_COMPARABLE_2(LeftType, RightType) \
300 QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, , \
302 QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, , \
305#define QT_DECLARE_EQUALITY_COMPARABLE_3(LeftType, RightType, Attributes) \
306 QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, , Attributes) \
307 QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, , \
310#define Q_DECLARE_EQUALITY_COMPARABLE(...) \
311 QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE, __VA_ARGS__)
313#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_1(Type) \
314 QT_DECLARE_EQUALITY_OPERATORS_HELPER(Type, Type, constexpr, )
316#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_2(LeftType, RightType) \
317 QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, constexpr, ) \
318 QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, constexpr, \
321#define QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE_3(LeftType, RightType, Attributes) \
322 QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, constexpr, Attributes) \
323 QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, constexpr, Attributes)
325#define Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE(...) \
326 QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE, __VA_ARGS__)
329#define QT_DECLARE_PARTIALLY_ORDERED_1(Type) \
330 QT_DECLARE_ORDERING_OPERATORS_HELPER(PARTIAL, Type, Type, , \
333#define QT_DECLARE_PARTIALLY_ORDERED_2(LeftType, RightType) \
334 QT_DECLARE_ORDERING_OPERATORS_HELPER(PARTIAL, LeftType, RightType, , \
336 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(PARTIAL, LeftType, RightType, \
339#define QT_DECLARE_PARTIALLY_ORDERED_3(LeftType, RightType, Attributes) \
340 QT_DECLARE_ORDERING_OPERATORS_HELPER(PARTIAL, LeftType, RightType, , \
342 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(PARTIAL, LeftType, RightType, \
345#define Q_DECLARE_PARTIALLY_ORDERED(...) \
346 QT_OVERLOADED_MACRO(QT_DECLARE_PARTIALLY_ORDERED, __VA_ARGS__)
348#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_1(Type) \
349 QT_DECLARE_ORDERING_OPERATORS_HELPER(PARTIAL, Type, Type, constexpr, )
351#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_2(LeftType, RightType) \
352 QT_DECLARE_ORDERING_OPERATORS_HELPER(PARTIAL, LeftType, RightType, constexpr, \
354 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(PARTIAL, LeftType, RightType, constexpr, \
357#define QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType, Attributes) \
358 QT_DECLARE_ORDERING_OPERATORS_HELPER(PARTIAL, LeftType, RightType, constexpr, Attributes) \
359 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(PARTIAL, LeftType, RightType, constexpr, \
362#define Q_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE(...) \
363 QT_OVERLOADED_MACRO(QT_DECLARE_PARTIALLY_ORDERED_LITERAL_TYPE, __VA_ARGS__)
366#define QT_DECLARE_WEAKLY_ORDERED_1(Type) \
367 QT_DECLARE_ORDERING_OPERATORS_HELPER(WEAK, Type, Type, , )
369#define QT_DECLARE_WEAKLY_ORDERED_2(LeftType, RightType) \
370 QT_DECLARE_ORDERING_OPERATORS_HELPER(WEAK, LeftType, RightType, , \
372 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(WEAK, LeftType, RightType, , \
375#define QT_DECLARE_WEAKLY_ORDERED_3(LeftType, RightType, Attributes) \
376 QT_DECLARE_ORDERING_OPERATORS_HELPER(WEAK, LeftType, RightType, , \
378 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(WEAK, LeftType, RightType, , \
381#define Q_DECLARE_WEAKLY_ORDERED(...) \
382 QT_OVERLOADED_MACRO(QT_DECLARE_WEAKLY_ORDERED, __VA_ARGS__)
384#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_1(Type) \
385 QT_DECLARE_ORDERING_OPERATORS_HELPER(WEAK, Type, Type, constexpr, )
387#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_2(LeftType, RightType) \
388 QT_DECLARE_ORDERING_OPERATORS_HELPER(WEAK, LeftType, RightType, constexpr, \
390 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(WEAK, LeftType, RightType, constexpr, \
393#define QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType, Attributes) \
394QT_DECLARE_ORDERING_OPERATORS_HELPER(WEAK, LeftType, RightType, constexpr, Attributes) \
395 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(WEAK, LeftType, RightType, constexpr, \
398#define Q_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE(...) \
399 QT_OVERLOADED_MACRO(QT_DECLARE_WEAKLY_ORDERED_LITERAL_TYPE, __VA_ARGS__)
402#define QT_DECLARE_STRONGLY_ORDERED_1(Type) \
403 QT_DECLARE_ORDERING_OPERATORS_HELPER(STRONG, Type, Type, , \
406#define QT_DECLARE_STRONGLY_ORDERED_2(LeftType, RightType) \
407 QT_DECLARE_ORDERING_OPERATORS_HELPER(STRONG, LeftType, RightType, , \
409 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(STRONG, LeftType, RightType, \
412#define QT_DECLARE_STRONGLY_ORDERED_3(LeftType, RightType, Attributes) \
413 QT_DECLARE_ORDERING_OPERATORS_HELPER(STRONG, LeftType, RightType, , \
415 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(STRONG, LeftType, RightType, \
418#define Q_DECLARE_STRONGLY_ORDERED(...) \
419 QT_OVERLOADED_MACRO(QT_DECLARE_STRONGLY_ORDERED, __VA_ARGS__)
421#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_1(Type) \
422 QT_DECLARE_ORDERING_OPERATORS_HELPER(STRONG, Type, Type, constexpr, )
424#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_2(LeftType, RightType) \
425 QT_DECLARE_ORDERING_OPERATORS_HELPER(STRONG, LeftType, RightType, constexpr, \
427 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(STRONG, LeftType, RightType, constexpr, \
430#define QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE_3(LeftType, RightType, Attributes) \
431 QT_DECLARE_ORDERING_OPERATORS_HELPER(STRONG, LeftType, RightType, constexpr, Attributes) \
432 QT_DECLARE_ORDERING_OPERATORS_REVERSED_HELPER(STRONG, LeftType, RightType, constexpr, \
435#define Q_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE(...) \
436 QT_OVERLOADED_MACRO(QT_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE, __VA_ARGS__)
441constexpr bool IsIntegralType_v = std::numeric_limits<std::remove_const_t<T>>::is_specialized
442 && std::numeric_limits<std::remove_const_t<T>>::is_integer;
447#if QFLOAT16_IS_NATIVE
449constexpr bool IsFloatType_v<QtPrivate::NativeFloat16Type> =
true;
456template <
typename T,
typename U>
460#ifdef __cpp_lib_three_way_comparison
477using if_integral = std::enable_if_t<QtPrivate::IsIntegralType_v<T>,
bool>;
482template <
typename T,
typename U>
484 std::enable_if_t<std::disjunction_v<std::is_same<T, U>,
485 std::is_base_of<T, U>,
486 std::is_base_of<U, T>>,
489template <
typename Enum>
490using if_enum = std::enable_if_t<std::is_enum_v<Enum>,
bool>;
492template <
typename LeftInt,
typename RightInt,
493 if_integral<LeftInt> =
true,
494 if_integral<RightInt> =
true>
497 static_assert(std::is_signed_v<LeftInt> == std::is_signed_v<RightInt>,
498 "Qt::compareThreeWay() does not allow mixed-sign comparison.");
500#ifdef __cpp_lib_three_way_comparison
512template <
typename LeftFloat,
typename RightFloat,
513 if_floating_point<LeftFloat> =
true,
514 if_floating_point<RightFloat> =
true>
519#ifdef __cpp_lib_three_way_comparison
534template <
typename IntType,
typename FloatType,
535 if_integral<IntType> =
true,
536 if_floating_point<FloatType> =
true>
542template <
typename FloatType,
typename IntType,
543 if_floating_point<FloatType> =
true,
544 if_integral<IntType> =
true>
550#if QT_DEPRECATED_SINCE(6, 8)
552template <
typename LeftType,
typename RightType,
553 if_compatible_pointers<LeftType, RightType> =
true>
555constexpr
Qt::strong_ordering compareThreeWay(const LeftType *lhs, const RightType *rhs) noexcept
557#ifdef __cpp_lib_three_way_comparison
558 return std::compare_three_way{}(lhs, rhs);
562 else if (std::less<>{}(lhs, rhs))
571constexpr
Qt::strong_ordering compareThreeWay(const T *lhs,
std::nullptr_t rhs) noexcept
578constexpr
Qt::strong_ordering compareThreeWay(
std::nullptr_t lhs, const T *rhs) noexcept
585template <
class Enum, if_enum<Enum> = true>
594template <
typename Head,
typename...Tail, std::size_t...Is>
596 std::index_sequence<Is...>)
noexcept
598 return std::tuple<Tail...>(std::get<Is + 1>(
t)...);
601template <
typename Head,
typename...Tail>
607template <
typename LhsHead,
typename...LhsTail,
typename RhsHead,
typename...RhsTail>
609 const std::tuple<RhsHead, RhsTail...> &rhs)
noexcept
611 static_assert(
sizeof...(LhsTail) ==
sizeof...(RhsTail),
613 "The tuple arguments have to have the same size.");
616 using R = std::common_type_t<
617 decltype(
compareThreeWay(std::declval<LhsHead>(), std::declval<RhsHead>())),
618 decltype(
compareThreeWay(std::declval<LhsTail>(), std::declval<RhsTail>()))...
621 const auto &l = std::get<0>(lhs);
622 const auto &
r = std::get<0>(rhs);
624 "This function requires all relational operators to be noexcept.");
626 if constexpr (
sizeof...(LhsTail) > 0) {
645 static_assert(std::is_pointer_v<P>);
646 using T = std::remove_pointer_t<P>;
656 constexpr P
get() const noexcept {
return ptr; }
657 constexpr void reset(P
p)
noexcept { ptr =
p; }
661 explicit constexpr operator bool() const noexcept {
return get(); }
666 template <
typename T,
typename U>
667 using if_compatible_types =
668 std::enable_if_t<std::conjunction_v<std::is_pointer<T>,
670 std::disjunction<std::is_convertible<T, U>,
671 std::is_convertible<U, T>>>,
674#define MAKE_RELOP(Ret, op, Op) \
675 template <typename U = P, if_compatible_types<P, U> = true> \
676 friend constexpr Ret operator op (const totally_ordered_wrapper<P> &lhs, const totally_ordered_wrapper<U> &rhs) noexcept \
677 { return std:: Op {}(lhs.ptr, rhs.get()); } \
678 template <typename U = P, if_compatible_types<P, U> = true> \
679 friend constexpr Ret operator op (const totally_ordered_wrapper<P> &lhs, const U &rhs) noexcept \
680 { return std:: Op {}(lhs.ptr, rhs ); } \
681 template <typename U = P, if_compatible_types<P, U> = true> \
682 friend constexpr Ret operator op (const U &lhs, const totally_ordered_wrapper<P> &rhs) noexcept \
683 { return std:: Op {}(lhs, rhs.ptr); } \
684 friend constexpr Ret operator op (const totally_ordered_wrapper &lhs, std::nullptr_t) noexcept \
685 { return std:: Op {}(lhs.ptr, P(nullptr)); } \
686 friend constexpr Ret operator op (std::nullptr_t, const totally_ordered_wrapper &rhs) noexcept \
687 { return std:: Op {}(P(nullptr), rhs.ptr); } \
695#ifdef __cpp_lib_three_way_comparison
707template <
typename T,
typename U, if_compatible_po
inters<T, U> = true>
714template <
typename T,
typename U, if_compatible_po
inters<T, U> = true>
721template <
typename T,
typename U, if_compatible_po
inters<T, U> = true>
750 template <
typename P>
751 struct hash<QT_PREPEND_NAMESPACE(
Qt::totally_ordered_wrapper)<P>>
756 {
return std::hash<P>{}(
w.get()); }
\variable Qt::partial_ordering::less
\variable Qt::weak_ordering::less
static const partial_ordering equivalent
static const partial_ordering unordered
static const partial_ordering greater
static const partial_ordering less
\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare
static const strong_ordering greater
static const strong_ordering less
static const strong_ordering equivalent
\inmodule QtCore \inheaderfile QtCompare
constexpr void reset(P p) noexcept
totally_ordered_wrapper() noexcept=default
constexpr T & operator*() 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 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
QHash< int, QWidget * > hash
[35multi]
Combined button and popup list for selecting options.
constexpr std::tuple< Tail... > qt_tuple_pop_front(const std::tuple< Head, Tail... > &t) noexcept
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 Qt::strong_ordering strongOrderingCompareDefaultImpl(T lhs, U rhs) noexcept
constexpr bool IsFloatType_v
constexpr bool IsIntegralType_v
std::enable_if_t< std::disjunction_v< std::is_same< T, U >, std::is_base_of< T, U >, std::is_base_of< U, T > >, bool > if_compatible_pointers
std::enable_if_t< QtPrivate::IsIntegralType_v< T >, bool > if_integral
std::enable_if_t< std::is_enum_v< Enum >, bool > if_enum
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
std::enable_if_t< QtPrivate::IsFloatType_v< T >, bool > if_floating_point
#define MAKE_RELOP(Ret, op, Op)
#define QT_WARNING_DISABLE_FLOAT_COMPARE
GLfloat GLfloat GLfloat w
[0]
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
#define QT_DEPRECATED_VERSION_X_6_8(text)
QT_BEGIN_NAMESPACE constexpr std::underlying_type_t< Enum > qToUnderlying(Enum e) noexcept
Qt::weak_ordering compareThreeWay(const QUrl &lhs, const QUrl &rhs)
QT_PREPEND_NAMESPACE(Qt::totally_ordered_wrapper)< P > argument_type
constexpr result_type operator()(argument_type w) const noexcept