aboutsummaryrefslogtreecommitdiff
path: root/src/operation
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-24 15:24:19 +0100
committerAdrian Kummerlaender2015-01-24 15:24:19 +0100
commit8b0d1c5296c22ce28fd0c8f9b251308b7bbf3090 (patch)
tree188b3f8940ca810a241ca2265da331af105d0d14 /src/operation
parentf9844b741feac35622b9566c6afae9bb686f5149 (diff)
downloadTypeAsValue-8b0d1c5296c22ce28fd0c8f9b251308b7bbf3090.tar
TypeAsValue-8b0d1c5296c22ce28fd0c8f9b251308b7bbf3090.tar.gz
TypeAsValue-8b0d1c5296c22ce28fd0c8f9b251308b7bbf3090.tar.bz2
TypeAsValue-8b0d1c5296c22ce28fd0c8f9b251308b7bbf3090.tar.lz
TypeAsValue-8b0d1c5296c22ce28fd0c8f9b251308b7bbf3090.tar.xz
TypeAsValue-8b0d1c5296c22ce28fd0c8f9b251308b7bbf3090.tar.zst
TypeAsValue-8b0d1c5296c22ce28fd0c8f9b251308b7bbf3090.zip
Added `Modulo` math operator
* redefined `Even` in terms of `Modulo` and removed unnecessary dependent name declarators * added appropriate test case, also for `Square`
Diffstat (limited to 'src/operation')
-rw-r--r--src/operation/math.h37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/operation/math.h b/src/operation/math.h
index 0ede3f5..28a6832 100644
--- a/src/operation/math.h
+++ b/src/operation/math.h
@@ -2,6 +2,7 @@
#define TYPEASVALUE_SRC_OPERATION_MATH_H_
#include "type.h"
+#include "logic.h"
namespace tav {
@@ -9,46 +10,58 @@ template <
typename X,
typename Y
>
-using Add = typename std::integral_constant<
+using Add = std::integral_constant<
decltype(X::value + Y::value),
X::value + Y::value
->::type;
+>;
template <
typename X,
typename Y
>
-using Substract = typename std::integral_constant<
+using Substract = std::integral_constant<
decltype(X::value - Y::value),
X::value - Y::value
->::type;
+>;
template <
typename X,
typename Y
>
-using Multiply = typename std::integral_constant<
+using Multiply = std::integral_constant<
decltype(X::value * Y::value),
X::value * Y::value
->::type;
+>;
template <
typename X,
typename Y
>
-using Divide = typename std::integral_constant<
+using Divide = std::integral_constant<
decltype(X::value / Y::value),
X::value / Y::value
->::type;
+>;
-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 = Boolean<(X::value % 2 == 0)>;
+using Even = EqualValue<
+ Modulo<X, Size<2>>,
+ Size<0>
+>;
template <typename X>
-using Odd = Boolean<!Even<X>::value>;
+using Odd = Not<Even<X>>;
+
+template <typename Base>
+using Square = Multiply<Base, Base>;
}