Function Vector.opAssign
Assigns a new value rhs
to the vector, replacing its current contents.
void opAssign
(
typeof(null) rhs
) scope;
void opAssign(R)
(
R range
) scope
if (isBtlInputRange!R && is(ElementEncodingType!R : ElementType));
void opAssign(Rhs)
(
auto scope ref Rhs rhs
) scope
if (isVector!Rhs && isAssignable!(Rhs, typeof(this)));
Parameter rhs
can by type of null
, Vector
or input range of ElementType elements.
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]);
}