7#include <QtCore/qttypetraits.h>
31#ifdef __cpp_lib_integer_comparison_functions
41template <
class T,
class U>
46 static_assert(QtPrivate::is_standard_or_extended_integer_type_v<T>,
47 "Integer types should be used for left T class.");
48 static_assert(QtPrivate::is_standard_or_extended_integer_type_v<U>,
49 "Integer types should be used for right U class.");
53template <
class T,
class U>
58 detail::checkTypeCompatibility<T, U>();
60 using UT = std::make_unsigned_t<T>;
61 using UU = std::make_unsigned_t<U>;
62 if constexpr (
std::is_signed_v<T> ==
std::is_signed_v<U>)
64 else if constexpr (
std::is_signed_v<T>)
65 return t < 0 ?
false : UT(t) == u;
67 return u < 0 ?
false : t == UU(u);
70template <
class T,
class U>
73 return !cmp_equal(t, u);
76template <
class T,
class U>
81 detail::checkTypeCompatibility<T, U>();
83 using UT = std::make_unsigned_t<T>;
84 using UU = std::make_unsigned_t<U>;
85 if constexpr (
std::is_signed_v<T> ==
std::is_signed_v<U>)
87 else if constexpr (
std::is_signed_v<T>)
88 return t < 0 ?
true : UT(t) < u;
90 return u < 0 ?
false : t < UU(u);
93template <
class T,
class U>
96 return cmp_less(u, t);
99template <
class T,
class U>
102 return !cmp_greater(t, u);
105template <
class T,
class U>
108 return !cmp_less(t, u);
111template <
class R,
class T>
114 return cmp_less_equal(t, (
std::numeric_limits<R>::max)())
115 && cmp_greater_equal(t, (
std::numeric_limits<R>::min)());
123#ifdef __cpp_lib_constexpr_algorithms
126template <
typename T,
typename U = T>
129 T old =
std::move(obj);
130 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