mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-25 01:01:33 +02:00
unknown_unit
renamed to unknown_coherent_unit
This commit is contained in:
@ -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
|
||||
|
@ -377,7 +377,7 @@ struct dim_power : derived_dimension<dim_power, watt,
|
||||
If as a result of dimensional computation the library framework will generate a derived
|
||||
dimension that was not predefined by the user than the instance of
|
||||
`unknown_dimension<Exponent...>`. The coherent unit of such an unknown dimension is
|
||||
`scaled_unit<ratio<1>, unknown_unit>`.
|
||||
`scaled_unit<ratio<1>, 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<unknown_unit> {};
|
||||
struct unknown_coherent_unit : unit<unknown_coherent_unit> {};
|
||||
|
||||
template<Exponent E, Exponent... ERest>
|
||||
struct unknown_dimension : derived_dimension<unknown_dimension<E, ERest...>,
|
||||
scaled_unit<ratio<1>, unknown_unit>,
|
||||
scaled_unit<ratio<1>, unknown_coherent_unit>,
|
||||
E, ERest...> {
|
||||
using coherent_unit = scaled_unit<ratio<1>, unknown_unit>;
|
||||
using coherent_unit = scaled_unit<ratio<1>, 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::unknown_dimension<units::exp<units::si::dim_length, 2, 1>,
|
||||
units::exp<units::si::dim_time, -1, 1> >, units::unknown_unit, long int>
|
||||
units::exp<units::si::dim_time, -1, 1> >, units::unknown_coherent_unit, long int>
|
||||
```
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -65,15 +65,15 @@ inline constexpr bool equivalent_dim = detail::equivalent_dim_impl<D1, D2>::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<Exponent E, Exponent... ERest>
|
||||
struct unknown_dimension : derived_dimension<unknown_dimension<E, ERest...>, scaled_unit<ratio<1>, unknown_unit>, E, ERest...> {
|
||||
using coherent_unit = scaled_unit<ratio<1>, unknown_unit>;
|
||||
struct unknown_dimension : derived_dimension<unknown_dimension<E, ERest...>, scaled_unit<ratio<1>, unknown_coherent_unit>, E, ERest...> {
|
||||
using coherent_unit = scaled_unit<ratio<1>, unknown_coherent_unit>;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
@ -80,7 +80,7 @@ struct unit : downcast_child<Child, scaled_unit<ratio<1>, Child>> {
|
||||
*
|
||||
* Used as a coherent unit of an unknown dimension.
|
||||
*/
|
||||
struct unknown_unit : unit<unknown_unit> {};
|
||||
struct unknown_coherent_unit : unit<unknown_coherent_unit> {};
|
||||
|
||||
/**
|
||||
* @brief A named unit
|
||||
|
@ -239,12 +239,12 @@ static_assert(
|
||||
static_assert(
|
||||
std::is_same_v<decltype(velocity<metre_per_second, int>() * si::time<hour, int>()), length<scaled_unit<ratio<36, 1, 2>, metre>, int>>);
|
||||
static_assert(std::is_same_v<decltype(length<metre>() * si::time<minute>()),
|
||||
quantity<unknown_dimension<units::exp<dim_length, 1>, units::exp<dim_time, 1>>, scaled_unit<ratio<6, 1, 1>, unknown_unit>>>);
|
||||
quantity<unknown_dimension<units::exp<dim_length, 1>, units::exp<dim_time, 1>>, scaled_unit<ratio<6, 1, 1>, unknown_coherent_unit>>>);
|
||||
static_assert(std::is_same_v<decltype(1 / si::time<second, int>()), frequency<hertz, int>>);
|
||||
static_assert(std::is_same_v<decltype(1 / si::time<minute, int>()), frequency<scaled_unit<ratio<1, 6, -1>, hertz>, int>>);
|
||||
static_assert(std::is_same_v<decltype(1 / frequency<hertz, int>()), si::time<second, int>>);
|
||||
static_assert(std::is_same_v<decltype(1 / length<kilometre>()),
|
||||
quantity<unknown_dimension<units::exp<dim_length, -1>>, scaled_unit<ratio<1, 1, -3>, unknown_unit>>>);
|
||||
quantity<unknown_dimension<units::exp<dim_length, -1>>, scaled_unit<ratio<1, 1, -3>, unknown_coherent_unit>>>);
|
||||
static_assert(std::is_same_v<decltype(length<metre, int>() / 1.0), length<metre, double>>);
|
||||
static_assert(std::is_same_v<decltype(length<metre, int>() / length<metre, double>()), double>);
|
||||
static_assert(std::is_same_v<decltype(length<kilometre, int>() / length<metre, double>()), double>);
|
||||
@ -253,7 +253,7 @@ static_assert(
|
||||
static_assert(
|
||||
std::is_same_v<decltype(length<metre>() / si::time<minute>()), velocity<scaled_unit<ratio<1, 6, -1>, metre_per_second>>>);
|
||||
static_assert(std::is_same_v<decltype(si::time<minute>() / length<metre>()),
|
||||
quantity<unknown_dimension<units::exp<dim_length, -1>, units::exp<dim_time, 1>>, scaled_unit<ratio<6 ,1 , 1>, unknown_unit>>>);
|
||||
quantity<unknown_dimension<units::exp<dim_length, -1>, units::exp<dim_time, 1>>, scaled_unit<ratio<6 ,1 , 1>, unknown_coherent_unit>>>);
|
||||
static_assert(std::is_same_v<decltype(length<metre, int>() % short(1)), length<metre, int>>);
|
||||
static_assert(std::is_same_v<decltype(length<metre, int>() % length<metre, short>(1)), length<metre, int>>);
|
||||
|
||||
|
Reference in New Issue
Block a user