ScaledUnit

Shorthands for defining base units with a single conversion factor to another base unit.

The conversion is done by simply multiplying/dividing the value by the passed factor, which thus has to be defined for all value types this scaled unit is used with.

Note that a generic alias is accepted as scaling factor, which makes it possible to use runtime values as scale factors without writing a custom unit type.

Members

Aliases

Conversions
alias Conversions = AliasSeq!(Conversion!(BaseUnit, toBase, fromBase))
Undocumented in source.

Mixins

__anonymous
mixin UnitImpl
Undocumented in source.

Static functions

fromBase
V fromBase(V v)
Undocumented in source. Be warned that the author may not have intended to support it.
toBase
V toBase(V v)
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString(UnitString type)
Undocumented in source. Be warned that the author may not have intended to support it.

Mixed In Members

From mixin UnitImpl

opBinary
auto opBinary(Rhs rhs)

Multiplication/division of two unit instances, yielding a unit instance representing the product/quotient unit.

opBinary
auto opBinary(V rhs)
opBinaryRight
auto opBinaryRight(V lhs)

Multiplication/division of an unit and a value type, constructing a Quantity instance.

SuperSecretAliasToMarkThisAsUnit
alias SuperSecretAliasToMarkThisAsUnit = void
Undocumented in source.

Examples

// The following three lines define the same unit. Most of the time, the
// third syntax is the preferred one because it directly declares a unit
// instance.
alias ScaledUnit!(Metre, 0.0254, "inch", "in") Inch;
alias ScaledUnit!(metre, 0.0254, "inch", "in") Inch;
enum inch = scale!(metre, 0.0254, "inch", "in");

Meta