Files
2025-10-25 03:02:53 +03:00

3.7 KiB

[utility.intcmp]

22 General utilities library [utilities]

22.2 Utility components [utility]

22.2.7 Integer comparison functions [utility.intcmp]

🔗

template<class T, class U> constexpr bool cmp_equal(T t, U u) noexcept;

1

#

Mandates: Both T and U are standard integer types or extended integer types ([basic.fundamental]).

2

#

Effects: Equivalent to:using UT = make_unsigned_t;using UU = make_unsigned_t;if constexpr (is_signed_v == is_signed_v)return t == u;else if constexpr (is_signed_v)return t < 0 ? false : UT(t) == u;elsereturn u < 0 ? false : t == UU(u);

🔗

template<class T, class U> constexpr bool cmp_not_equal(T t, U u) noexcept;

3

#

Effects: Equivalent to: return !cmp_equal(t, u);

🔗

template<class T, class U> constexpr bool cmp_less(T t, U u) noexcept;

4

#

Mandates: Both T and U are standard integer types or extended integer types ([basic.fundamental]).

5

#

Effects: Equivalent to:using UT = make_unsigned_t;using UU = make_unsigned_t;if constexpr (is_signed_v == is_signed_v)return t < u;else if constexpr (is_signed_v)return t < 0 ? true : UT(t) < u;elsereturn u < 0 ? false : t < UU(u);

🔗

template<class T, class U> constexpr bool cmp_greater(T t, U u) noexcept;

6

#

Effects: Equivalent to: return cmp_less(u, t);

🔗

template<class T, class U> constexpr bool cmp_less_equal(T t, U u) noexcept;

7

#

Effects: Equivalent to: return !cmp_greater(t, u);

🔗

template<class T, class U> constexpr bool cmp_greater_equal(T t, U u) noexcept;

8

#

Effects: Equivalent to: return !cmp_less(t, u);

🔗

template<class R, class T> constexpr bool in_range(T t) noexcept;

9

#

Mandates: Both T and R are standard integer types or extended integer types ([basic.fundamental]).

10

#

Effects: Equivalent to:return cmp_greater_equal(t, numeric_limits::min()) && cmp_less_equal(t, numeric_limits::max());

11

#

[Note 1:

These function templates cannot be used to comparebyte,char,char8_t,char16_t,char32_t,wchar_t, andbool.

— end note]