aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-19 17:23:29 +0100
committerAdrian Kummerlaender2015-01-19 17:23:29 +0100
commit17a62b7627551243419d0a85c611eec7e6581e7b (patch)
treee7df53e93686777c858bc0b1d2dd611953c13268
parent3cac56267edfbfd26e203ad674b9b8e74e44b14e (diff)
downloadTypeAsValue-17a62b7627551243419d0a85c611eec7e6581e7b.tar
TypeAsValue-17a62b7627551243419d0a85c611eec7e6581e7b.tar.gz
TypeAsValue-17a62b7627551243419d0a85c611eec7e6581e7b.tar.bz2
TypeAsValue-17a62b7627551243419d0a85c611eec7e6581e7b.tar.lz
TypeAsValue-17a62b7627551243419d0a85c611eec7e6581e7b.tar.xz
TypeAsValue-17a62b7627551243419d0a85c611eec7e6581e7b.tar.zst
TypeAsValue-17a62b7627551243419d0a85c611eec7e6581e7b.zip
Moved `Odd` helper into math operation header
* it may be useful for more than test cases
-rw-r--r--src/operation/math.h6
-rw-r--r--test.cc5
2 files changed, 7 insertions, 4 deletions
diff --git a/src/operation/math.h b/src/operation/math.h
index fd6e031..b06eb35 100644
--- a/src/operation/math.h
+++ b/src/operation/math.h
@@ -41,6 +41,12 @@ using Divide = typename std::integral_constant<
X::value / Y::value
>::type;
+template <typename X>
+using Even = Boolean<(X::value % 2 == 0)>;
+
+template <typename X>
+using Odd = Boolean<!Even<X>::value>;
+
}
#endif // TYPEASVALUE_SRC_OPERATION_MATH_H_
diff --git a/test.cc b/test.cc
index 35126fb..aa98be9 100644
--- a/test.cc
+++ b/test.cc
@@ -14,9 +14,6 @@ class TypeAsValueTest : public ::testing::Test { };
template <typename Element>
using quadruple = tav::Multiply<tav::Int<4>, Element>;
-template <typename Element>
-using odd = tav::Boolean<(Element::value % 2 == 1)>;
-
TEST_F(TypeAsValueTest, BasicMath) {
// (+ 1 2)
EXPECT_EQ(3, ( tav::Add<tav::Int<1>, tav::Int<2>>::value ));
@@ -104,7 +101,7 @@ TEST_F(TypeAsValueTest, ListMap) {
TEST_F(TypeAsValueTest, ListFilter) {
// (filter odd (list 1 2 3))
- EXPECT_TRUE(( std::is_same<tav::List<tav::Int<1>, tav::Int<3>>::type, tav::Filter<odd, tav::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>::type>::type>::value ));
+ EXPECT_TRUE(( std::is_same<tav::List<tav::Int<1>, tav::Int<3>>::type, tav::Filter<tav::Odd, tav::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>::type>::type>::value ));
}
TEST_F(TypeAsValueTest, ListReverse) {