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)
    @safe
    convert
    (
    TargetUnit
    Q : Quantity!(U, V)
    U
    V
    )
    (
    Q q
    )
    if (
    isUnit!TargetUnit
    )
  2. auto convert(Q q)

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