A prefix system, used with PrefixedUnit.

Use the DefinePrefixSystem mixin to automatically generate a helper function like kilo() for every prefix in the system.

getPrefixes has to be a parameterless callable returning Prefix[]. This scheme is used (instead of directly passing the prefix array as a parameter) to reduce code bloat, because delegate literals are mangled much shorter than array literals. The effect on the binary size is quite strong because the mangled name of a PrefixSystem instance is part of every symbol in which a PrefixedUnit is involved.

template PrefixSystem (
long systemBase
alias getPrefixes
) if (
is(typeof(getPrefixes()) : Prefix[])
) {
enum base;
enum prefixes;


alias PrefixSystem!(10, { return [
   Prefix(-3, "milli", "m"),
   Prefix(3, "kilo", "k")
]; }) System;