From 021df4a46f0c992426eefb1d133c2ca613907c6b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 18 Sep 2019 15:32:22 -0600 Subject: [PATCH] dimension_sqrt and dimension_pow support added --- src/include/units/dimension.h | 26 +++++++++++++++++++++++++- test/unit_test/test_custom_units.cpp | 3 +++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/include/units/dimension.h b/src/include/units/dimension.h index 1d5e947d..700452a2 100644 --- a/src/include/units/dimension.h +++ b/src/include/units/dimension.h @@ -130,7 +130,11 @@ namespace std::experimental::units { template struct exp_multiply { - using type = exp; + // todo: provide custom implementation for ratio_add + using r1 = std::ratio; + using r2 = std::ratio; + using r = std::ratio_multiply; + using type = exp; }; template @@ -257,4 +261,24 @@ namespace std::experimental::units { template using dimension_divide_t = dimension_divide::type; + // dimension_sqrt + template + struct dimension_sqrt; + + template + struct dimension_sqrt> : std::type_identity...>>> {}; + + template + using dimension_sqrt_t = dimension_sqrt::type; + + // dimension_pow + template + struct dimension_pow; + + template + struct dimension_pow, N> : std::type_identity...>>> {}; + + template + using dimension_pow_t = dimension_pow::type; + } // namespace std::experimental::units diff --git a/test/unit_test/test_custom_units.cpp b/test/unit_test/test_custom_units.cpp index 1d03c421..f8991953 100644 --- a/test/unit_test/test_custom_units.cpp +++ b/test/unit_test/test_custom_units.cpp @@ -90,6 +90,9 @@ template<> struct downcasting_traits> : downc namespace { + static_assert(std::is_same_v, amplitude_spectral_density>); + static_assert(std::is_same_v, power_spectral_density>); + //static_assert(sqrt(quantity(4)) = quantity(2)); }