aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-16 19:52:36 +0100
committerAdrian Kummerlaender2015-01-16 19:52:36 +0100
commit5a9e048c1efc3d0697debf968b4aeb056c04c391 (patch)
tree4b31470e09f53f06a3621afd6d59d6e0bb321259
parent8d2a11dc86f5eb0e8db2d1a88e58a562f1e07a9c (diff)
downloadTypeAsValue-5a9e048c1efc3d0697debf968b4aeb056c04c391.tar
TypeAsValue-5a9e048c1efc3d0697debf968b4aeb056c04c391.tar.gz
TypeAsValue-5a9e048c1efc3d0697debf968b4aeb056c04c391.tar.bz2
TypeAsValue-5a9e048c1efc3d0697debf968b4aeb056c04c391.tar.lz
TypeAsValue-5a9e048c1efc3d0697debf968b4aeb056c04c391.tar.xz
TypeAsValue-5a9e048c1efc3d0697debf968b4aeb056c04c391.tar.zst
TypeAsValue-5a9e048c1efc3d0697debf968b4aeb056c04c391.zip
Redefined function template structs as template aliases
-rw-r--r--src/operation/math.h40
-rw-r--r--test.cc8
2 files changed, 20 insertions, 28 deletions
diff --git a/src/operation/math.h b/src/operation/math.h
index 64a5cdb..82740b6 100644
--- a/src/operation/math.h
+++ b/src/operation/math.h
@@ -9,45 +9,37 @@ template <
typename X,
typename Y
>
-struct add {
- typedef std::integral_constant<
- decltype(X::value + Y::value),
- X::value + Y::value
- > type;
-};
+using add = typename 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;
-};
+using substract = typename 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;
-};
+using multiply = typename 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;
-};
+using divide = typename std::integral_constant<
+ decltype(X::value / Y::value),
+ X::value / Y::value
+>::type;
}
diff --git a/test.cc b/test.cc
index 5a7a6eb..219bfe5 100644
--- a/test.cc
+++ b/test.cc
@@ -10,10 +10,10 @@ TEST_F(TypeAsValueTest, Value) {
}
TEST_F(TypeAsValueTest, BasicMath) {
- EXPECT_EQ(3, ( tav::add<tav::Int<1>, tav::Int<2>>::type::value ));
- EXPECT_EQ(4, ( tav::substract<tav::Int<10>, tav::Int<6>>::type::value ));
- EXPECT_EQ(42, ( tav::multiply<tav::Int<2>, tav::Int<21>>::type::value ));
- EXPECT_EQ(5, ( tav::divide<tav::Int<10>, tav::Int<2>>::type::value ));
+ EXPECT_EQ(3, ( tav::add<tav::Int<1>, tav::Int<2>>::value ));
+ EXPECT_EQ(4, ( tav::substract<tav::Int<10>, tav::Int<6>>::value ));
+ EXPECT_EQ(42, ( tav::multiply<tav::Int<2>, tav::Int<21>>::value ));
+ EXPECT_EQ(5, ( tav::divide<tav::Int<10>, tav::Int<2>>::value ));
}
int main(int argc, char **argv) {