aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/operation/math.h16
-rw-r--r--test.cc48
2 files changed, 62 insertions, 2 deletions
diff --git a/src/operation/math.h b/src/operation/math.h
index 28a6832..d855893 100644
--- a/src/operation/math.h
+++ b/src/operation/math.h
@@ -42,6 +42,9 @@ using Divide = std::integral_constant<
X::value / Y::value
>;
+template <typename Base>
+using Square = Multiply<Base, Base>;
+
template <
typename X,
typename Y
@@ -60,8 +63,17 @@ using Even = EqualValue<
template <typename X>
using Odd = Not<Even<X>>;
-template <typename Base>
-using Square = Multiply<Base, Base>;
+template <
+ typename X,
+ typename Y
+>
+using GreaterThan = Boolean<(X::value > Y::value)>;
+
+template <
+ typename X,
+ typename Y
+>
+using LowerThan = Boolean<(X::value < Y::value)>;
}
diff --git a/test.cc b/test.cc
index 9037e25..65a048b 100644
--- a/test.cc
+++ b/test.cc
@@ -107,6 +107,54 @@ static_assert(
"(square 64) != 4096"
);
+static_assert(
+ std::is_same<
+ tav::Boolean<true>,
+ tav::Odd<tav::Int<1>>::type
+ >::value,
+ "(odd? 1) != #t"
+);
+
+static_assert(
+ std::is_same<
+ tav::Boolean<false>,
+ tav::Odd<tav::Int<2>>::type
+ >::value,
+ "(odd? 2) != #f"
+);
+
+static_assert(
+ std::is_same<
+ tav::Boolean<true>,
+ tav::GreaterThan<tav::Int<2>, tav::Int<1>>::type
+ >::value,
+ "(> 2 1) != #f"
+);
+
+static_assert(
+ std::is_same<
+ tav::Boolean<false>,
+ tav::GreaterThan<tav::Int<1>, tav::Int<2>>::type
+ >::value,
+ "(> 1 2) != #f"
+);
+
+static_assert(
+ std::is_same<
+ tav::Boolean<true>,
+ tav::LowerThan<tav::Int<1>, tav::Int<2>>::type
+ >::value,
+ "(< 1 2) != #t"
+);
+
+static_assert(
+ std::is_same<
+ tav::Boolean<false>,
+ tav::LowerThan<tav::Int<2>, tav::Int<1>>::type
+ >::value,
+ "(< 2 1) != #f"
+);
+
// logic
static_assert(