tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
cmp_less.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_UTILITY_CMP_LESS_HPP
4
#define TETL_UTILITY_CMP_LESS_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_less
(T t, U u)
noexcept
->
bool
22
{
23
using
UT =
etl::make_unsigned_t<T>
;
24
using
UU =
etl::make_unsigned_t<U>
;
25
if
constexpr
(
etl::is_signed_v<T>
==
etl::is_signed_v<U>
) {
26
return
t < u;
27
}
else
if
constexpr
(
etl::is_signed_v<T>
) {
28
return
t < 0 ? true : UT(t) < u;
29
}
else
{
30
return
u < 0 ? false : t < UU(u);
31
}
32
}
33
34
}
// namespace etl
35
36
#endif
// TETL_UTILITY_CMP_LESS_HPP
builtin_integer.hpp
etl::cmp_less
constexpr auto cmp_less(T t, U u) noexcept -> bool
Compare the values of two integers t and u. Unlike builtin comparison operators, negative signed inte...
Definition
cmp_less.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_less.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0