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