Vector.opAssign

Assigns a new value rhs to the vector, replacing its current contents.

Parameter rhs can by type of null, Vector or input range of ElementType elements.

  1. void opAssign(typeof(null) rhs)
  2. void opAssign(R range)
  3. void opAssign(Rhs rhs)
    struct Vector
    scope
    void
    opAssign
    (
    Rhs
    )
    (
    scope auto ref Rhs rhs
    )
    if (
    isVector!Rhs &&
    isAssignable!(Rhs, typeof(this))
    )

Examples

{
    Vector!(int, 6) vec = Vector!(int, 6).build(1, 2, 3);
    assert(!vec.empty);

    vec = null;
    assert(vec.empty);

    vec = Vector!(int, 42).build(3, 2, 1);
    assert(vec == [3, 2, 1]);

    vec = Vector!(int, 2).build(4, 2);
    assert(vec == [4, 2]);
}

{
    int[3] tmp = [1, 2, 3];
    Vector!(int, 6) vec = tmp[];
    assert(vec == [1, 2, 3]);
}

{
    struct Range{
        int i;

        bool empty()(){return i == 0;}
        int front()(){return i;}
        void popFront()(){i -= 1;}
        //size_t length(); //no length
    }

    Vector!(int, 6) vec = Range(3);
    assert(vec == [3, 2, 1]);
}

Meta