From 613cfebc0b2a2968260e5f9122d7b5e7ba3755c3 Mon Sep 17 00:00:00 2001 From: Claudius Holeksa Date: Tue, 23 May 2023 16:38:43 +0200 Subject: c++: Renamed class and fixed namespace naming --- src/kelunit/distance/meter.h | 6 ++--- src/kelunit/time/second.h | 4 ++-- src/kelunit/unit.h | 28 +++++++++++------------ src/kelunit/unit.tmpl.h | 22 +++++++++--------- src/kelunit/unit_reduction.h | 54 ++++++++++++++++++++++---------------------- 5 files changed, 57 insertions(+), 57 deletions(-) (limited to 'src/kelunit') diff --git a/src/kelunit/distance/meter.h b/src/kelunit/distance/meter.h index 57ca58e..0d9fb3b 100644 --- a/src/kelunit/distance/meter.h +++ b/src/kelunit/distance/meter.h @@ -4,7 +4,7 @@ #include -namespace kelun { +namespace kel { namespace unit_type { struct meter{ static constexpr std::string_view name = "meter"; @@ -13,8 +13,8 @@ struct meter{ } template -using meter = unit>; +using meter = unit>; template -using square_meter = unit>; +using square_meter = unit>; } diff --git a/src/kelunit/time/second.h b/src/kelunit/time/second.h index 07145ca..6dca456 100644 --- a/src/kelunit/time/second.h +++ b/src/kelunit/time/second.h @@ -2,7 +2,7 @@ #include "../unit.h" -namespace kelun { +namespace kel { namespace unit_type { struct second{ static constexpr std::string_view name = "second"; @@ -11,5 +11,5 @@ struct second{ } template -using second = unit>; +using second = unit>; } diff --git a/src/kelunit/unit.h b/src/kelunit/unit.h index 4958eb9..a8e8320 100644 --- a/src/kelunit/unit.h +++ b/src/kelunit/unit.h @@ -1,41 +1,41 @@ #pragma once -#include "./unit_reduction.h" +#include "unit_reduction.h" -namespace kelun { +namespace kel { template -struct unit_base {}; +struct unit_component {}; template class unit; template -class unit...> { +class unit...> { public: using value_type = StorageT; unit() = default; - unit(const unit...>&) = default; - unit(unit...>&&) = default; + unit(const unit...>&) = default; + unit(unit...>&&) = default; - unit...>& operator=(const unit...>&) = default; - unit...>& operator=(unit...>&&) = default; + unit...>& operator=(const unit...>&) = default; + unit...>& operator=(unit...>&&) = default; unit(const value_type&); unit(value_type&&); - unit...>& operator=(const value_type&); - unit...>& operator=(value_type&&); + unit...>& operator=(const value_type&); + unit...>& operator=(value_type&&); - unit...> operator+(const unit...>& rhs); - unit...> operator-(const unit...>& rhs); + unit...> operator+(const unit...>& rhs); + unit...> operator-(const unit...>& rhs); template - typename unit_multiplication...>, unit>::type operator*(const unit& rhs); + typename unit_multiplication...>, unit>::type operator*(const unit& rhs); template - typename unit_multiplication...>, typename unit_invert::type>::type operator/(const unit& rhs); + typename unit_multiplication...>, typename unit_invert::type>::type operator/(const unit& rhs); value_type data() const; private: diff --git a/src/kelunit/unit.tmpl.h b/src/kelunit/unit.tmpl.h index 42b96ef..d89e0c1 100644 --- a/src/kelunit/unit.tmpl.h +++ b/src/kelunit/unit.tmpl.h @@ -3,51 +3,51 @@ namespace kelun { template -unit...>::unit(const value_type& value_): +unit...>::unit(const value_type& value_): value{value_}{} template -unit...>::unit(value_type&& value_):value{std::move(value_)}{} +unit...>::unit(value_type&& value_):value{std::move(value_)}{} template -unit...>& unit...>::operator=(const typename unit...>::value_type& value_){ +unit...>& unit...>::operator=(const typename unit...>::value_type& value_){ value = value_; return *this; } template -unit...>& unit...>::operator=(typename unit...>::value_type&& value_){ +unit...>& unit...>::operator=(typename unit...>::value_type&& value_){ value = std::move(value_); return *this; } template -unit...> unit...>::operator+(const unit...>& rhs){ +unit...> unit...>::operator+(const unit...>& rhs){ return value + rhs.value; } template -unit...> unit...>::operator-(const unit...>& rhs){ +unit...> unit...>::operator-(const unit...>& rhs){ return value - rhs.value; } template template -typename unit_multiplication...>, unit>::type -unit...>::operator*(const unit& rhs){ +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_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 { +typename unit...>::value_type unit...>::data() const { return value; } } diff --git a/src/kelunit/unit_reduction.h b/src/kelunit/unit_reduction.h index d3299ff..d9060d2 100644 --- a/src/kelunit/unit_reduction.h +++ b/src/kelunit/unit_reduction.h @@ -8,7 +8,7 @@ template constexpr bool is_always_false = false; template -struct unit_base; +struct unit_component; template class unit; @@ -26,8 +26,8 @@ class unit_redux_list { }; template -struct unit_redux_list, unit_base...> { - using reduced_type = typename unit_matching, unit_base...>, unit_redux_list<>>::type; +struct unit_redux_list, unit_component...> { + using reduced_type = typename unit_matching, unit_component...>, unit_redux_list<>>::type; }; template @@ -37,24 +37,24 @@ public: }; template -class unit_matching_reduce, unit_redux_list,unit_base...>, unit_redux_list...>> { +class unit_matching_reduce, unit_redux_list,unit_component...>, unit_redux_list...>> { public: static constexpr bool is_same = std::is_same_v; - using match_reduce_type = typename std::conditional, unit_base>::type; - using match_reduce_unit_redux_list = typename std::conditional...>, unit_redux_list..., unit_base>>::type; + using match_reduce_type = typename std::conditional, unit_component>::type; + using match_reduce_unit_redux_list = typename std::conditional...>, unit_redux_list..., unit_component>>::type; - using value_type = typename unit_matching_reduce...>, match_reduce_unit_redux_list>::value_type; - using unit_redux_list_type = typename unit_matching_reduce...>, match_reduce_unit_redux_list>::unit_redux_list_type; + using value_type = typename unit_matching_reduce...>, match_reduce_unit_redux_list>::value_type; + using unit_redux_list_type = typename unit_matching_reduce...>, match_reduce_unit_redux_list>::unit_redux_list_type; - static constexpr int64_t value_num = unit_matching_reduce...>, match_reduce_unit_redux_list>::value_num; + static constexpr int64_t value_num = unit_matching_reduce...>, match_reduce_unit_redux_list>::value_num; }; template -class unit_matching_reduce, unit_redux_list<>, unit_redux_list...>> { +class unit_matching_reduce, unit_redux_list<>, unit_redux_list...>> { public: - using value_type = unit_base; - using unit_redux_list_type = unit_redux_list...>; + using value_type = unit_component; + using unit_redux_list_type = unit_redux_list...>; static constexpr int64_t value_num = E; }; @@ -65,20 +65,20 @@ class unit_matching { }; template -class unit_matching,unit_redux_list...>> { +class unit_matching,unit_redux_list...>> { public: - using type = unit_redux_list...>; + using type = unit_redux_list...>; }; template -class unit_matching,unit_base...>, unit_redux_list...>> { +class unit_matching,unit_component...>, unit_redux_list...>> { public: - using reduced_value_type = typename unit_matching_reduce, unit_redux_list...>, unit_redux_list<>>::value_type; - using reduced_unit_redux_list_type = typename unit_matching_reduce, unit_redux_list...>, unit_redux_list<>>::unit_redux_list_type; + using reduced_value_type = typename unit_matching_reduce, unit_redux_list...>, unit_redux_list<>>::value_type; + using reduced_unit_redux_list_type = typename unit_matching_reduce, unit_redux_list...>, unit_redux_list<>>::unit_redux_list_type; - static constexpr int64_t reduced_value_num = unit_matching_reduce, unit_redux_list...>, unit_redux_list<>>::value_num; - using reduced_result_unit_redux_list = typename std::conditional...>, unit_redux_list...,reduced_value_type>>::type; + static constexpr int64_t reduced_value_num = unit_matching_reduce, unit_redux_list...>, unit_redux_list<>>::value_num; + using reduced_result_unit_redux_list = typename std::conditional...>, unit_redux_list...,reduced_value_type>>::type; using type = typename unit_matching::type; }; @@ -90,9 +90,9 @@ public: }; template -class unit_matching_add_storage...>, StorageT> { +class unit_matching_add_storage...>, StorageT> { public: - using type = unit...>; + using type = unit...>; }; } @@ -103,9 +103,9 @@ class unit_reduction { }; template -class unit_reduction...> { +class unit_reduction...> { public: - using list_type = typename impl::unit_matching...>, impl::unit_redux_list<>>::type; + using list_type = typename impl::unit_matching...>, impl::unit_redux_list<>>::type; using type = typename impl::unit_matching_add_storage::type; }; @@ -115,9 +115,9 @@ class unit_invert { }; template -class unit_invert...> { +class unit_invert...> { public: - using type = unit...>; + using type = unit...>; }; template @@ -126,8 +126,8 @@ class unit_multiplication{ }; template -class unit_multiplication...>, unit...>> { +class unit_multiplication...>, unit...>> { public: - using type = typename unit_reduction..., unit_base...>::type; + using type = typename unit_reduction..., unit_component...>::type; }; } -- cgit v1.2.3