aboutsummaryrefslogtreecommitdiff
path: root/src/operation/math.h
blob: 28a6832e0ebf5d7b72ae4c273acf03d662dff195 (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
#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 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 Base>
using Square = Multiply<Base, Base>;

}

#endif  // TYPEASVALUE_SRC_OPERATION_MATH_H_