[utility.intcmp] # 22 General utilities library [[utilities]](./#utilities) ## 22.2 Utility components [[utility]](utility#intcmp) ### 22.2.7 Integer comparison functions [utility.intcmp] [🔗](#lib:cmp_equal) `template constexpr bool cmp_equal(T t, U u) noexcept; ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L546) *Mandates*: Both T and U are standard integer types or extended integer types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#1.sentence-1) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L551) *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); [🔗](#lib:cmp_not_equal) `template constexpr bool cmp_not_equal(T t, U u) noexcept; ` [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L573) *Effects*: Equivalent to: return !cmp_equal(t, u); [🔗](#lib:cmp_less) `template constexpr bool cmp_less(T t, U u) noexcept; ` [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L585) *Mandates*: Both T and U are standard integer types or extended integer types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#4.sentence-1) [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L590) *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); [🔗](#lib:cmp_greater) `template constexpr bool cmp_greater(T t, U u) noexcept; ` [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L612) *Effects*: Equivalent to: return cmp_less(u, t); [🔗](#lib:cmp_less_equal) `template constexpr bool cmp_less_equal(T t, U u) noexcept; ` [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L624) *Effects*: Equivalent to: return !cmp_greater(t, u); [🔗](#lib:cmp_greater_equal) `template constexpr bool cmp_greater_equal(T t, U u) noexcept; ` [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L636) *Effects*: Equivalent to: return !cmp_less(t, u); [🔗](#lib:in_range) `template constexpr bool in_range(T t) noexcept; ` [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L648) *Mandates*: Both T and R are standard integer types or extended integer types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#9.sentence-1) [10](#10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L653) *Effects*: Equivalent to:return cmp_greater_equal(t, numeric_limits::min()) && cmp_less_equal(t, numeric_limits::max()); [11](#11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L662) [*Note [1](#note-1)*: These function templates cannot be used to comparebyte,char,char8_t,char16_t,char32_t,wchar_t, andbool[.](#11.sentence-1) — *end note*]