Quantity.opOpAssign

Addition/substraction of a quantity with the same unit.

  1. Quantity opOpAssign(Quantity!(Unit, RhsV) rhs)
    struct Quantity(Unit, ValueType = double)
    ref
    static if(!is(Unit.LinearBaseUnit BaseUnit))
    opOpAssign
    (
    string op
    RhsV
    )
    (
    Quantity!(Unit, RhsV) rhs
    )
    if (
    (
    op == "+" ||
    op == "-"
    )
    &&
    __traits(compiles, ())
    )
    if (
    isUnit!Unit
    )
  2. Quantity opOpAssign(T rhs)
  3. Quantity opOpAssign(Quantity!(BaseUnit, RhsV) rhs)
  4. auto opBinary(Quantity!(Unit, RhsV) rhs)

Examples

auto a = 3 * metre;
auto b = 2 * metre;
assert(a + b == 5 * metre);
a -= b;
assert(a == 1 * metre);

Meta