aboutsummaryrefslogtreecommitdiff
path: root/src/operation/math.h
blob: d8558937dfa5ec83af7836f01256510965d53508 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef TYPEASVALUE_SRC_OPERATION_MATH_H_
#define TYPEASVALUE_SRC_OPERATION_MATH_H_

#include "type.h"
#include "logic.h"

namespace tav {

template <
	typename X,
	typename Y
>
using Add = std::integral_constant<
	decltype(X::value + Y::value),
	X::value + Y::value
>;

template <
	typename X,
	typename Y
>
using Substract = std::integral_constant<
	decltype(X::value - Y::value),
	X::value - Y::value
>;

template <
	typename X,
	typename Y
>
using Multiply = std::integral_constant<
	decltype(X::value * Y::value),
	X::value * Y::value
>;

template <
	typename X,
	typename Y
>
using Divide = std::integral_constant<
	decltype(X::value / Y::value),
	X::value / Y::value
>;

template <typename Base>
using Square = Multiply<Base, Base>;

template <
	typename X,
	typename Y
>
using Modulo = std::integral_constant<
	decltype(X::value % Y::value),
	X::value % Y::value
>;

template <typename X>
using Even = EqualValue<
	Modulo<X, Size<2>>,
	Size<0>
>;

template <typename X>
using Odd = Not<Even<X>>;

template <
	typename X,
	typename Y
>
using GreaterThan = Boolean<(X::value > Y::value)>;

template <
	typename X,
	typename Y
>
using LowerThan = Boolean<(X::value < Y::value)>;

}

#endif  // TYPEASVALUE_SRC_OPERATION_MATH_H_