di 0.1.0
Loading...
Searching...
No Matches
cmp_less.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/meta/language.h"
4
5namespace di::math {
6namespace detail {
7 struct CmpLessFunction {
8 template<concepts::Integer T, concepts::Integer U>
9 constexpr auto operator()(T a, U b) const -> bool {
10 using UT = meta::MakeUnsigned<T>;
11 using UU = meta::MakeUnsigned<U>;
12 if constexpr (concepts::Signed<T> == concepts::Signed<U>) {
13 return a < b;
14 } else if constexpr (concepts::Signed<T>) {
15 return a < 0 ? true : UT(a) < b;
16 } else {
17 return b < 0 ? false : a < UU(b);
18 }
19 }
20 };
21}
22
23constexpr inline auto cmp_less = detail::CmpLessFunction {};
24}
Definition abs.h:10
constexpr auto cmp_less
Definition cmp_less.h:23
detail::MakeUnsignedHelper< RemoveCV< T > >::Type MakeUnsigned
Definition language.h:362