alias A = DerivedUnit!(BaseUnitExp!(Foo, Rational!(-2)));
static assert(is(A.BaseUnitExps == AliasSeq!(BaseUnitExp!(Foo,
Rational!(-2)))), "Basic compound unit construction does not work.");
static assert(is(DerivedUnit!(BaseUnitExp!(Foo, Rational!2),
BaseUnitExp!(Bar, Rational!1), BaseUnitExp!(Baz, Rational!3)) == DerivedUnit!(
BaseUnitExp!(Bar, Rational!1), BaseUnitExp!(Baz, Rational!3),
BaseUnitExp!(Foo, Rational!2))), "Base unit sorting does not work.");
// FIXME: Another problem probably related to signed/unsigned integer
// literals, uncomment BarBU-related arguments below to see the assert fail.
static assert(is(DerivedUnit!(BaseUnitExp!(Foo, Rational!2),
BaseUnitExp!(Foo, Rational!1) /+,
BaseUnitExp!(Bar, Rational!(-3)), BaseUnitExp!(Bar, Rational!2)+/
) == DerivedUnit!(BaseUnitExp!(Foo, Rational!3), /+BaseUnitExp!(Bar, Rational!(-1)+/
)), "Base unit joining does not work.");
static assert(is(DerivedUnit!(BaseUnitExp!(Foo, Rational!2),
BaseUnitExp!(Foo, Rational!(-2))) == Dimensionless),
"Zero exponent base unit pruning does not work.");
static assert(is(DerivedUnit!(BaseUnitExp!(Dimensionless, Rational!1),
BaseUnitExp!(Foo, Rational!1)) == Foo),
"Removing Dimensionless during zero exponent pruning does not work.");
static assert(is(DerivedUnit!(BaseUnitExp!(Foo, Rational!1)) == Foo),
"Demotion of trivial compound units to base units does not work.");
Constructs a derived unit, consisting of a number of base units and associated exponents.
Usually, constructing unit types using the operators defined on the unit instances is preferred over using this template directly.
Internally, derived units are represented as DUnit instances, but never try to use it directly – the DerivedUnit template performs canonicalization to ensure that semantically equivalent units share the same underlying types. Also, the result will not actually be a DUnit in some cases, but rather Dimensionless or a single base unit without exponent.