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

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

Meta