From 8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 15 Jan 2015 20:12:46 +0100 Subject: Extracted basic math operations into separate header --- src/operation.h | 54 ---------------------------------------------------- src/operation/math.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ test.cc | 2 +- 3 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 src/operation.h create mode 100644 src/operation/math.h diff --git a/src/operation.h b/src/operation.h deleted file mode 100644 index 2f3b747..0000000 --- a/src/operation.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef TYPEASVALUE_SRC_OPERATION_H_ -#define TYPEASVALUE_SRC_OPERATION_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_H_ 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_ diff --git a/test.cc b/test.cc index 06f0a17..5a7a6eb 100644 --- a/test.cc +++ b/test.cc @@ -1,7 +1,7 @@ #include "gtest/gtest.h" #include "type.h" -#include "operation.h" +#include "operation/math.h" class TypeAsValueTest : public ::testing::Test { }; -- cgit v1.2.3