CompiletimeSI.SIFormatter

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

mixintemplate CompiletimeSI(N)
struct SIFormatter (
string fmt
Q
) {}

Constructors

this
this(Q quantity)

Create a formatter struct.

Members

Functions

toString
void toString(void delegate(const(char)[]) sink)

Manifest constants

unit
enum unit;
Undocumented in source.

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.

Examples

import std.conv : text;

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

Meta