tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
cmp_equal.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_UTILITY_CMP_EQUAL_HPP
4
#define TETL_UTILITY_CMP_EQUAL_HPP
5
6
#include <
etl/_concepts/builtin_integer.hpp
>
7
#include <
etl/_type_traits/is_signed.hpp
>
8
#include <
etl/_type_traits/make_unsigned.hpp
>
9
10
namespace
etl
{
11
20
template
<builtin_
int
eger T, builtin_
int
eger U>
21
[[nodiscard]]
constexpr
auto
cmp_equal
(T t, U u)
noexcept
->
bool
22
{
23
using
UT =
etl::make_unsigned_t<T>
;
24
using
UU =
etl::make_unsigned_t<U>
;
25
26
if
constexpr
(
etl::is_signed_v<T>
==
etl::is_signed_v<U>
) {
27
return
t == u;
28
}
else
if
constexpr
(
etl::is_signed_v<T>
) {
29
return
t < 0 ? false : UT(t) == u;
30
}
else
{
31
return
u < 0 ? false : t == UU(u);
32
}
33
}
34
35
}
// namespace etl
36
37
#endif
// TETL_UTILITY_CMP_EQUAL_HPP
builtin_integer.hpp
etl::cmp_equal
constexpr auto cmp_equal(T t, U u) noexcept -> bool
Compare the values of two integers t and u. Unlike builtin comparison operators, negative signed inte...
Definition
cmp_equal.hpp:21
is_signed.hpp
make_unsigned.hpp
etl
Definition
adjacent_find.hpp:8
etl::is_signed_v
constexpr bool is_signed_v
Definition
is_signed.hpp:30
etl::make_unsigned_t
typename make_unsigned< T >::type make_unsigned_t
Definition
make_unsigned.hpp:75
include
etl
_utility
cmp_equal.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0