fooToMile

Undocumented in source.
version(unittest)
@safe
int fooToMile;

Examples

// Simple conversions should be possible at compile time.
enum millifoo = scale!(foo, 0.001, "millifoo");
static assert(convert!millifoo(1 * foo) == 1000 * millifoo);

static assert(is(typeof(scale!(foo, 2, "millifoo")) ==
                 typeof(scale!(foo, 2, "millifoo"))));

// Test using a global variable as conversion factor (possible because
// ScaledUnit takes an alias).
enum mile = scale!(foo, fooToMile, "mile");
fooToMile = 1852;
assert(convert!Foo(1 * mile) == 1852 * foo);

// Conversion over two hops. This test isn't specific to ScaledUnit.
enum microfoo = scale!(millifoo, 0.001, "microfoo");
static assert(convert!microfoo(1 * foo) == 1000000 * microfoo);

// Conversion over multiple hops in both directions. If A-->B represents
// a conversion defined at A to B, the chain looks like this:
// MicroFoo-->MilliFoo-->Foo<--KiloFoo<--MegaFoo.
enum kilofoo = scale!(foo, 1000, "kilofoo");
enum megafoo = scale!(kilofoo, 1000, "megafoo");
static assert(convert!microfoo(1L * megafoo) == 10L ^^ 12 * microfoo);

Meta