SIFormatWrapper

Helper struct that formats a SI quantity.

struct SIFormatWrapper (
Q
) if (
isQuantity!Q ||
isQVariant!Q
) {}

Constructors

this
this(string fmt)

Creates a new formatter from a format string.

Members

Functions

opCall
auto opCall(Q quantity)

Returns a wrapper struct that can be formatted by std.string.format or std.format functions.

Examples

import std.string;

auto sf = SIFormatWrapper!Speed("%.1f km/h");
auto speed = 343.4 * meter/second;
assert("Speed: %s".format(sf(speed)) == "Speed: 1236.2 km/h");

Meta