From 5415ecfbdc5078826e09cf6525ff5c0289cedfd4 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 15 Jan 2015 19:50:40 +0100 Subject: Added basic value type alias and math operations --- src/operation.h | 36 ++++++++++++++++++++++++++++++++++++ src/type.h | 25 +++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/operation.h create mode 100644 src/type.h (limited to 'src') diff --git a/src/operation.h b/src/operation.h new file mode 100644 index 0000000..c906b55 --- /dev/null +++ b/src/operation.h @@ -0,0 +1,36 @@ +#ifndef TYPEASVALUE_SRC_OPERATION_H_ +#define TYPEASVALUE_SRC_OPERATION_H_ + +#include "type.h" + +namespace tav { + +template < + typename X, + typename Y +> +struct add { + static_assert( + equal_type::value, + "only values of the same type may be added" + ); + + typedef Int type; +}; + +template < + typename X, + typename Y +> +struct substract { + static_assert( + equal_type::value, + "only values of the same type may be substracted" + ); + + typedef Int type; +}; + +} + +#endif // TYPEASVALUE_SRC_OPERATION_H_ diff --git a/src/type.h b/src/type.h new file mode 100644 index 0000000..1149520 --- /dev/null +++ b/src/type.h @@ -0,0 +1,25 @@ +#ifndef TYPEASVALUE_SRC_TYPE_H_ +#define TYPEASVALUE_SRC_TYPE_H_ + +#include + +namespace tav { + +template +using Int = typename std::integral_constant::type; + +template +using Boolean = typename std::integral_constant::type; + +template < + typename X, + typename Y +> +using equal_type = typename std::integral_constant< + bool, + std::is_same::value +>::type; + +} + +#endif // TYPEASVALUE_SRC_TYPE_H_ -- cgit v1.2.3