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
9
10namespace etl {
11
20template <builtin_integer T, builtin_integer 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>;
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
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
Definition adjacent_find.hpp:8
constexpr bool is_signed_v
Definition is_signed.hpp:30
typename make_unsigned< T >::type make_unsigned_t
Definition make_unsigned.hpp:75