convert

Converts a quantity to another unit.

The value type of the resulting quantity will be the same as the original one.

  1. auto convert(Q q)
  2. auto convert(Q q)
    @safe
    convert
    (
    alias targetUnit
    Q : Quantity!(U, V)
    U
    V
    )
    (
    Q q
    )
    if (
    isUnitInstance!targetUnit
    )

Examples

writeln(convert!gram(2 * kilogram));
writeln(convert!kilogram(2000 * gram));
writeln(convert!(milli(newton))(2 * newton));
writeln(convert!(kilo(newton))(2000000 * gram * meter / pow!2(second)));
writeln(convert!(micro(newton) / pow!2(milli(metre)))(1234.0 * pascal));

Meta