diff options
author | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-07-29 14:18:30 +0200 |
---|---|---|
committer | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-07-29 14:18:30 +0200 |
commit | 700cde2d499742160deb361f42b7e861ae1db8ed (patch) | |
tree | ba796243a94578f9c2105080fa19040a341c4482 /c++/unit.hpp | |
parent | fb7dd1c9185da30aed8645c084be0722e061a867 (diff) |
Renaming to new standard
Diffstat (limited to 'c++/unit.hpp')
-rw-r--r-- | c++/unit.hpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/c++/unit.hpp b/c++/unit.hpp new file mode 100644 index 0000000..a8e8320 --- /dev/null +++ b/c++/unit.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include "unit_reduction.h" + +namespace kel { +template<typename UnitType, int64_t Exponent> +struct unit_component {}; + +template<typename StorageT, typename... T> +class unit; + +template<typename StorageT, typename... UnitTypes, int64_t... Exponents> +class unit<StorageT, unit_component<UnitTypes, Exponents>...> { +public: + using value_type = StorageT; + + unit() = default; + + unit(const unit<StorageT,unit_component<UnitTypes, Exponents>...>&) = default; + unit(unit<StorageT,unit_component<UnitTypes,Exponents>...>&&) = default; + + unit<StorageT,unit_component<UnitTypes,Exponents>...>& operator=(const unit<StorageT,unit_component<UnitTypes,Exponents>...>&) = default; + unit<StorageT,unit_component<UnitTypes,Exponents>...>& operator=(unit<StorageT,unit_component<UnitTypes,Exponents>...>&&) = default; + + unit(const value_type&); + unit(value_type&&); + + unit<StorageT,unit_component<UnitTypes,Exponents>...>& operator=(const value_type&); + unit<StorageT,unit_component<UnitTypes,Exponents>...>& operator=(value_type&&); + + unit<StorageT,unit_component<UnitTypes,Exponents>...> operator+(const unit<StorageT,unit_component<UnitTypes,Exponents>...>& rhs); + unit<StorageT,unit_component<UnitTypes,Exponents>...> operator-(const unit<StorageT,unit_component<UnitTypes,Exponents>...>& rhs); + + template<typename... Trhs> + typename unit_multiplication<unit<StorageT,unit_component<UnitTypes,Exponents>...>, unit<StorageT,Trhs...>>::type operator*(const unit<StorageT, Trhs...>& rhs); + + template<typename... Trhs> + typename unit_multiplication<unit<StorageT, unit_component<UnitTypes,Exponents>...>, typename unit_invert<StorageT,Trhs...>::type>::type operator/(const unit<StorageT, Trhs...>& rhs); + + value_type data() const; +private: + value_type value; +}; + +template<typename S> +using scalar = unit<S>; +} + +#include "unit.tmpl.h" |