aboutsummaryrefslogtreecommitdiff
path: root/src/operation/math.h
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-15 20:12:46 +0100
committerAdrian Kummerlaender2015-01-15 20:12:46 +0100
commit8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c (patch)
treea39d6438fff1d01361b92573a99a76363712f1c3 /src/operation/math.h
parent2ebabfd7ef48660213286f5f55ebfcdd8fca0d91 (diff)
downloadTypeAsValue-8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c.tar
TypeAsValue-8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c.tar.gz
TypeAsValue-8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c.tar.bz2
TypeAsValue-8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c.tar.lz
TypeAsValue-8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c.tar.xz
TypeAsValue-8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c.tar.zst
TypeAsValue-8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c.zip
Extracted basic math operations into separate header
Diffstat (limited to 'src/operation/math.h')
-rw-r--r--src/operation/math.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/operation/math.h b/src/operation/math.h
new file mode 100644
index 0000000..64a5cdb
--- /dev/null
+++ b/src/operation/math.h
@@ -0,0 +1,54 @@
+#ifndef TYPEASVALUE_SRC_OPERATION_MATH_H_
+#define TYPEASVALUE_SRC_OPERATION_MATH_H_
+
+#include "type.h"
+
+namespace tav {
+
+template <
+ typename X,
+ typename Y
+>
+struct add {
+ typedef std::integral_constant<
+ decltype(X::value + Y::value),
+ X::value + Y::value
+ > type;
+};
+
+template <
+ typename X,
+ typename Y
+>
+struct substract {
+ typedef std::integral_constant<
+ decltype(X::value - Y::value),
+ X::value - Y::value
+ > type;
+};
+
+template <
+ typename X,
+ typename Y
+>
+struct multiply {
+ typedef std::integral_constant<
+ decltype(X::value * Y::value),
+ X::value * Y::value
+ > type;
+};
+
+template <
+ typename X,
+ typename Y
+>
+struct divide {
+ typedef std::integral_constant<
+ decltype(X::value / Y::value),
+ X::value / Y::value
+ > type;
+};
+
+}
+
+#endif // TYPEASVALUE_SRC_OPERATION_MATH_H_