Quantity.opBinary

Addition/substraction of a quantity with the same unit.

  1. auto opBinary(Quantity!(Unit, RhsV) rhs)
    struct Quantity(Unit, ValueType = double)
    static if(!is(Unit.LinearBaseUnit BaseUnit))
    opBinary
    (
    string op
    RhsV
    )
    (
    Quantity!(Unit, RhsV) rhs
    )
    if (
    (
    op == "+" ||
    op == "-"
    )
    &&
    is(typeof(mixin ("ValueType.init" ~ op ~ "RhsV.init")))
    )
    if (
    isUnit!Unit
    )
  2. auto opBinary(T rhs)
  3. auto opBinary(Rhs rhs)
  4. auto opBinary(RhsU rhs)
  5. auto opBinary(Quantity!(RhsU, RhsV) rhs)
  6. auto opBinary(Quantity!(RhsU, RhsV) rhs)
  7. auto opBinary(Quantity!(Unit, RhsV) rhs)
  8. auto opBinary(Quantity!(BaseUnit, RhsV) rhs)
  9. Quantity opOpAssign(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