ditto
t { enum meter = unit!("L"); enum liter = 0.001 * meter * meter * meter; mixin MathFunctions!(real, "std.math"); auto surface = 25 * square(meter); auto side = sqrt(surface); assert(side.value(meter).approxEqual(5)); auto volume = 27 * liter; side = cbrt(volume); assert(side.value(meter).approxEqual(0.3)); auto delta = -10 * meter; assert(abs(delta) == 10 * meter
Mixin template that introduces math functions operating on a quantity of value type N in the current scope. Each function imports module_ internally. This module should contain the math primitives that can operate on the variables of type N, such as sqrt, cbrt, pow and fabs.