From 488653602d0636a1fa5ef6e64cabb9b903dce42a Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 25 Aug 2023 10:10:51 +0200 Subject: Renamed src folder to c++ --- c++/unit.tmpl.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 c++/unit.tmpl.h (limited to 'c++/unit.tmpl.h') diff --git a/c++/unit.tmpl.h b/c++/unit.tmpl.h new file mode 100644 index 0000000..d89e0c1 --- /dev/null +++ b/c++/unit.tmpl.h @@ -0,0 +1,53 @@ +#include + +namespace kelun { + +template +unit...>::unit(const value_type& value_): + value{value_}{} + +template +unit...>::unit(value_type&& value_):value{std::move(value_)}{} + +template +unit...>& unit...>::operator=(const typename unit...>::value_type& value_){ + value = value_; + return *this; +} + +template +unit...>& unit...>::operator=(typename unit...>::value_type&& value_){ + value = std::move(value_); + return *this; +} + +template +unit...> unit...>::operator+(const unit...>& rhs){ + return value + rhs.value; +} + +template +unit...> unit...>::operator-(const unit...>& rhs){ + return value - rhs.value; +} + +template +template +typename unit_multiplication...>, unit>::type +unit...>::operator*(const unit& rhs){ + return value * rhs.data(); +} + +template +template +typename unit_multiplication...>, typename unit_invert::type>::type +unit...>::operator/(const unit& rhs){ + typename unit_invert::type rhs_inverted{static_cast(1)/rhs.data()}; + return value * rhs_inverted.data(); +} + +template +typename unit...>::value_type unit...>::data() const { + return value; +} +} -- cgit v1.2.3