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)
  2. auto opBinary(Rhs rhs)
  3. auto opBinary(Checked!(U, Hook1) rhs)
  4. auto opBinary(Checked!(U, Hook1) rhs)
    struct Checked(T, Hook = Abort)
    const
    opBinary
    (
    string op
    U
    Hook1
    )
    (
    Checked!(U, Hook1) rhs
    )
    if (
    is(T == Checked!(U, H),
    U
    H
    )
    )

Parameters

op

The binary operator

rhs Checked!(U, Hook1)

The right hand side operand

U

If rhs is a Checked instance, U represents the underlying instance type

Hook1

If rhs is a Checked instance, Hook1 represents the instance's behavior hook

Return Value

Type: auto

A Checked instance representing the result of the binary operation

Meta