Iros
 
Loading...
Searching...
No Matches
abs_diff.h
Go to the documentation of this file.
1#pragma once
2
4#include "di/meta/language.h"
5#include "di/types/prelude.h"
6
7namespace di::math {
8namespace detail {
10 template<concepts::Integral T, typename U = meta::MakeUnsigned<T>>
11 constexpr auto operator()(T a, T b) const -> U {
12 if (a < b) {
13 return U(b) - U(a);
14 }
15 return U(a) - U(b);
16 }
17
18 template<concepts::Pointer T>
20 constexpr auto operator()(T a, T b) const -> uptr {
21 if (a < b) {
22 return b - a;
23 }
24 return a - b;
25 }
26 };
27}
28
30}
31
32namespace di {
33using math::abs_diff;
34}
Definition language.h:370
constexpr auto curry_back
Definition curry_back.h:141
Definition abs.h:11
Definition abs.h:10
constexpr auto abs_diff
Definition abs_diff.h:29
constexpr auto c_
A value of type Constexpr<val>.
Definition constexpr.h:252
uintptr_t uptr
Definition integers.h:36
Definition zstring_parser.h:9
Definition abs_diff.h:9
constexpr auto operator()(T a, T b) const -> U
Definition abs_diff.h:11