8#include <QtCore/qttypetraits.h>
32#ifdef __cpp_lib_integer_comparison_functions
42template <
class T,
class U>
47 static_assert(QtPrivate::is_standard_or_extended_integer_type_v<T>,
48 "Integer types should be used for left T class.");
49 static_assert(QtPrivate::is_standard_or_extended_integer_type_v<U>,
50 "Integer types should be used for right U class.");
54template <
class T,
class U>
59 detail::checkTypeCompatibility<T, U>();
61 using UT = std::make_unsigned_t<T>;
62 using UU = std::make_unsigned_t<U>;
63 if constexpr (
std::is_signed_v<T> ==
std::is_signed_v<U>)
65 else if constexpr (
std::is_signed_v<T>)
66 return t < 0 ?
false : UT(t) == u;
68 return u < 0 ?
false : t == UU(u);
71template <
class T,
class U>
74 return !cmp_equal(t, u);
77template <
class T,
class U>
82 detail::checkTypeCompatibility<T, U>();
84 using UT = std::make_unsigned_t<T>;
85 using UU = std::make_unsigned_t<U>;
86 if constexpr (
std::is_signed_v<T> ==
std::is_signed_v<U>)
88 else if constexpr (
std::is_signed_v<T>)
89 return t < 0 ?
true : UT(t) < u;
91 return u < 0 ?
false : t < UU(u);
94template <
class T,
class U>
97 return cmp_less(u, t);
100template <
class T,
class U>
103 return !cmp_greater(t, u);
106template <
class T,
class U>
109 return !cmp_less(t, u);
112template <
class R,
class T>
115 return cmp_less_equal(t, (
std::numeric_limits<R>::max)())
116 && cmp_greater_equal(t, (
std::numeric_limits<R>::min)());
124#ifdef __cpp_lib_constexpr_algorithms
127template <
typename T,
typename U = T>
130 T old =
std::move(obj);
131 obj =
std::forward<U>(newValue);
constexpr void checkTypeCompatibility() noexcept
constexpr bool cmp_less_equal(T t, U u) noexcept
constexpr T exchange(T &obj, U &&newValue)
constexpr bool cmp_not_equal(T t, U u) noexcept
constexpr bool cmp_greater(T t, U u) noexcept
constexpr bool cmp_equal(T t, U u) noexcept
constexpr bool cmp_greater_equal(T t, U u) noexcept
constexpr bool in_range(T t) noexcept
constexpr bool cmp_less(T t, U u) noexcept