CompiletimeSI.siFormat

Formats a SI quantity according to a format string known at compile time.

mixintemplate CompiletimeSI(N)
siFormat
(
string fmt
Q
)

Parameters

fmt

The format string. Must start with a format specification for the value of the quantity (a numeric type), that must be followed by the symbol of a SI unit.

quantity Q

The quantity that must be formatted.

Examples

import std.conv : text;

enum speed = 12.5 * kilo(meter) / hour;
assert(siFormat!"%.2f m/s"(speed).text == "3.47 m/s");

Meta