Quantity.opCast

A quantity is castable to another one with the same unit if the value type can be casted to the new one.

For converting a quantity to another unit, see convert instead.

struct Quantity(Unit, ValueType = double)
Quantity!(Unit, NewV)
opCast
(
T : Quantity!(Unit, NewV)
NewV
)
()
if (
is(typeof(cast(NewV)ValueType.init))
)
if (
isUnit!Unit
)

Examples

auto a = 2.0 * metre;
assert(cast(Quantity!(metre, int))a == 2 * metre);

Meta