From 0c89df3980e548ac92dc47873992ed10ff5f1aa6 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 22 Feb 2020 09:37:40 +0100 Subject: [PATCH] `unknown_unit` renamed to `unknown_coherent_unit` --- CHANGELOG.md | 3 ++- doc/DESIGN.md | 10 +++++----- example/unknown_dimension.cpp | 2 +- src/include/units/bits/dimension_op.h | 6 +++--- src/include/units/unit.h | 2 +- test/unit_test/static/quantity_test.cpp | 6 +++--- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82460a4d..fd1ffe51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ - 0.5.0 ??? - Major refactoring and rewrite of the library - Units are now independent from dimensions - - Dimensions are now depended on units (base or coherent units are provided in a class template) + - Dimensions now depend on units (base or coherent units are provided in a class template) - Quantity gets a Dimension template parameter again (as unit does not provide information about its dimension anymore) - Added official CGS system support @@ -12,6 +12,7 @@ - `ratio` refactored to contain `Exp` template parameter - SI fundamental constants added - `q_` prefix applied to all the UDLs + - `unknown_unit` renamed to `unknown_coherent_unit` - ... - 0.4.0 Nov 17, 2019 diff --git a/doc/DESIGN.md b/doc/DESIGN.md index b19bee64..5cfa73c7 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -377,7 +377,7 @@ struct dim_power : derived_dimension`. The coherent unit of such an unknown dimension is -`scaled_unit, unknown_unit>`. +`scaled_unit, unknown_coherent_unit>`. ## `Quantity` @@ -747,13 +747,13 @@ known one with a correct unit, and also to improve the user experience and clear it is an unknown dimension the library framework will provide an instance of: ```cpp -struct unknown_unit : unit {}; +struct unknown_coherent_unit : unit {}; template struct unknown_dimension : derived_dimension, - scaled_unit, unknown_unit>, + scaled_unit, unknown_coherent_unit>, E, ERest...> { - using coherent_unit = scaled_unit, unknown_unit>; + using coherent_unit = scaled_unit, unknown_coherent_unit>; }; ``` @@ -761,7 +761,7 @@ with this the error log or a debugger breakpoint involving a `temp1` type will i ```text units::quantity, -units::exp >, units::unknown_unit, long int> +units::exp >, units::unknown_coherent_unit, long int> ``` diff --git a/example/unknown_dimension.cpp b/example/unknown_dimension.cpp index ea51227b..3af27ac9 100644 --- a/example/unknown_dimension.cpp +++ b/example/unknown_dimension.cpp @@ -39,7 +39,7 @@ void example() units::Time AUTO t1 = 10q_s; units::Velocity AUTO v1 = avg_speed(d1, t1); - auto temp1 = v1 * 50q_m; // produces intermediate unknown dimension with 'unknown_unit' as its 'coherent_unit' + auto temp1 = v1 * 50q_m; // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' units::Velocity AUTO v2 = temp1 / 100q_m; // back to known dimensions again units::Length AUTO d2 = v2 * 60q_s; diff --git a/src/include/units/bits/dimension_op.h b/src/include/units/bits/dimension_op.h index 9506cb75..f0f54ac1 100644 --- a/src/include/units/bits/dimension_op.h +++ b/src/include/units/bits/dimension_op.h @@ -65,15 +65,15 @@ inline constexpr bool equivalent_dim = detail::equivalent_dim_impl::valu * @brief Unknown dimension * * Sometimes a temporary partial result of a complex calculation may not result in a predefined - * dimension. In such a case an `unknown_dimension` is created with a coherent unit of `unknown_unit` + * dimension. In such a case an `unknown_dimension` is created with a coherent unit of `unknown_coherent_unit` * and ratio<1>. * * @tparam E the list of exponents of ingredient dimensions * @tparam ERest the list of exponents of ingredient dimensions */ template -struct unknown_dimension : derived_dimension, scaled_unit, unknown_unit>, E, ERest...> { - using coherent_unit = scaled_unit, unknown_unit>; +struct unknown_dimension : derived_dimension, scaled_unit, unknown_coherent_unit>, E, ERest...> { + using coherent_unit = scaled_unit, unknown_coherent_unit>; }; namespace detail { diff --git a/src/include/units/unit.h b/src/include/units/unit.h index 2c59ba23..c9c43e4f 100644 --- a/src/include/units/unit.h +++ b/src/include/units/unit.h @@ -80,7 +80,7 @@ struct unit : downcast_child, Child>> { * * Used as a coherent unit of an unknown dimension. */ -struct unknown_unit : unit {}; +struct unknown_coherent_unit : unit {}; /** * @brief A named unit diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index 339ae041..bf87cf9a 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -239,12 +239,12 @@ static_assert( static_assert( std::is_same_v() * si::time()), length, metre>, int>>); static_assert(std::is_same_v() * si::time()), - quantity, units::exp>, scaled_unit, unknown_unit>>>); + quantity, units::exp>, scaled_unit, unknown_coherent_unit>>>); static_assert(std::is_same_v()), frequency>); static_assert(std::is_same_v()), frequency, hertz>, int>>); static_assert(std::is_same_v()), si::time>); static_assert(std::is_same_v()), - quantity>, scaled_unit, unknown_unit>>>); + quantity>, scaled_unit, unknown_coherent_unit>>>); static_assert(std::is_same_v() / 1.0), length>); static_assert(std::is_same_v() / length()), double>); static_assert(std::is_same_v() / length()), double>); @@ -253,7 +253,7 @@ static_assert( static_assert( std::is_same_v() / si::time()), velocity, metre_per_second>>>); static_assert(std::is_same_v() / length()), - quantity, units::exp>, scaled_unit, unknown_unit>>>); + quantity, units::exp>, scaled_unit, unknown_coherent_unit>>>); static_assert(std::is_same_v() % short(1)), length>); static_assert(std::is_same_v() % length(1)), length>);