Measurement unit for a derived quantity
Synopsis
Declared in <mp‐units/framework/unit.h>
template</* implementation-defined */... Expr>
struct derived_unit final
: /* implementation-defined */
Base Classes
Name |
Description |
|
Description
Derived units are defined as products of powers of the base units.
Instead of using a raw list of exponents this library decided to use expression template syntax to make types more digestable for the user. The positive exponents are ordered first and all negative exponents are put as a list into the per<...>
class template. If a power of exponent is different than 1
the unit type is enclosed in power<Dim, Num, Den>
class template. Otherwise, it is just put directly in the list without any wrapper. There is also one special case. In case all of the exponents are negative then the one
being a coherent unit of a dimensionless quantity is put in the front to increase the readability.
For example:
{.cpp}
static_assert(is_of_type<inverse(second), derived_unit<one, per<second>>>);
static_assert(is_of_type<one / inverse(second), second>);
static_assert(is_of_type<one * second, second>);
static_assert(is_of_type<metre * metre, derived_unit<power<metre, 2>>>);
static_assert(is_of_type<metre * second, derived_unit<metre, second>>);
static_assert(is_of_type<metre / second, derived_unit<metre, per<second>>>);
static_assert(is_of_type<metre / square(second), derived_unit<metre, per<power<second, 2>>>>);
static_assert(is_of_type<watt / joule, derived_unit<watt, per<joule>>>);
Every unit in the library has its internal canonical representation being the list of exponents of named base units (with the exception of kilogram
which is represented as gram
here) and a scaling ratio represented with a magnitude.
Two units are deemed convertible if their canonical version has units of the same type. Two units are equivalent when they are convertible and their canonical versions have the same scaling ratios.
The above means that: ‐ 1/s
and Hz
are both convertible and equal ‐ m
and km
are convertible but not equal ‐ m
and m²
ane not convertible and not equal
Note
|
This also means that units like hertz and becquerel are also considered convertible and equal.
|
Note
|
User should not instantiate this type! It is not exported from the C++ module. The library will instantiate this type automatically based on the unit arithmetic equation provided by the user. |
Template Parameters
Name |
Description |
Us |
a parameter pack consisting tokens allowed in the unit specification (units, |
Created with MrDocs