The OpenD Programming Language

Checked.opBinary

Defines binary operators +, -, *, /, %, ^^, &, |, ^, <<, >>, and >>>. If Hook defines hookOpBinary, opBinary forwards to Checked!(typeof(hook.hookOpBinary!op(get, rhs)), Hook)(hook.hookOpBinary!op(get, rhs)).

If Hook does not define hookOpBinary but defines onOverflow, opBinary forwards to hook.onOverflow!op(get, rhs) in case an overflow occurs.

If two Checked instances are involved in a binary operation and both define hookOpBinary, the left-hand side hook has priority. If both define onOverflow, a compile-time error occurs.

  1. auto opBinary(Rhs rhs)
    struct Checked(T, Hook = Abort)
    opBinary
    (
    string op
    Rhs
    )
    (
    const Rhs rhs
    )
    if (
    is(Rhs == bool)
    )
    if (
    is(T == Checked!(U, H),
    U
    H
    )
    )
  2. auto opBinary(Rhs rhs)
  3. auto opBinary(Checked!(U, Hook1) rhs)
  4. auto opBinary(Checked!(U, Hook1) rhs)

Parameters

op

The binary operator

rhs Rhs

The right hand side operand

Return Value

Type: auto

A Checked instance representing the result of the binary operation

Meta