Vector.opBinary

Returns a new vector with the results of applying operator against elements of other. If operands dimensions are unequal, copies the values from greater dimension vector.

  1. Vector opBinary(T scalar)
  2. auto opBinary(U scalar)
  3. Vector!(T, max(N, M)) opBinary(T[M] other)
    struct Vector(T, uint N)
    pure const
    Vector!(T, max(N, M))
    opBinary
    (
    string op
    uint M
    )
    (
    const auto ref T[M] other
    )
    if (
    op != "~"
    )
    if (
    N > 0
    )
  4. Vector!(CommonType!(U, T), max(N, M)) opBinary(U[M] other)
  5. Vector!(T, N + 1) opBinary(T scalar)
  6. Vector!(T, N + M) opBinary(T[M] other)

Examples

assert(Vec2(1, 2) + Vec2(3, 4) == [1f+3f, 2f+4f]);
assert(Vec2(1, 2) - Vec2(3, 4) == [1f-3f, 2f-4f]);
assert(Vec2(1, 2) * Vec2(3, 4) == [1f*3f, 2f*4f]);
assert(Vec2(1, 2) / Vec2(3, 4) == [1f/3f, 2f/4f]);
assert(__traits(compiles, Vec2(1, 2) + [3, 4]));

assert(Vec2(1, 2) + Vec1(3) == [1f+3f, 2f]);
assert(Vec2(1, 2) - Vec1(3) == [1f-3f, 2f]);
assert(Vec2(1, 2) * Vec1(3) == [1f*3f, 2f]);
assert(Vec2(1, 2) / Vec1(3) == [1f/3f, 2f]);

assert(Vec2(1, 2) + Vec3(3, 4, 5) == [1f+3f, 2f+4f, 5f]);
assert(Vec2(1, 2) - Vec3(3, 4, 5) == [1f-3f, 2f-4f, 5f]);
assert(Vec2(1, 2) * Vec3(3, 4, 5) == [1f*3f, 2f*4f, 5f]);
assert(Vec2(1, 2) / Vec3(3, 4, 5) == [1f/3f, 2f/4f, 5f]);

assert(Vec2i(1, 2) + Vec2(3, 4) == [1+3f, 2+4f]);

Meta