The type of the value type stored in the Quantity struct.
A prefilled SymbolList struct that contains all units and prefixes.
A function that can parse the beginning of a string to return a numeric value of type N. After this function returns, it must have consumed the numeric part and leave only the unit part.
import std.bigint; enum bit = unit!(BigInt, "bit"); alias BinarySize = typeof(bit); SymbolList!BigInt symbolList; symbolList.addUnit("bit", bit); symbolList.addPrefix("hob", BigInt("1234567890987654321")); static BigInt parseFun(ref string input) { import std.exception, std.regex; enum rgx = ctRegex!`^(\d*)\s*(.*)$`; auto m = enforce(match(input, rgx)); input = m.captures[2]; return BigInt(m.captures[1]); } alias parse = rtQuantityParser!(BigInt, symbolList, parseFun); auto foo = BigInt("1234567890987654300") * bit; foo += BigInt(21) * bit; assert(foo == parse!BinarySize("1 hobbit"));
Creates a runtime parser capable of working on user-defined units and prefixes.