SList.opAssign - multiple declarations
Function SList.opAssign
Assigns another list.
ref typeof(this) opAssign(R)
(
ref R that
)
if (is(Unqual!R == SList));
ref typeof(this) opAssign(R)
(
R that
)
if (is(R == SList));
If that is passed by value, it won't be copied, but moved. This list will take the ownership over that's storage and the allocator.
If that is passed by reference, it will be copied.
Parameters
Name | Description |
---|---|
R | Content type. |
that | The value should be assigned. |
Returns
this.
Example
{
auto l1 = SList!int([5, 4, 9]);
auto l2 = SList!int([9, 4]);
l1 = l2;
assert(l1 == l2);
}
{
auto l1 = SList!int([5, 4, 9]);
auto l2 = SList!int([9, 4]);
l1 = SList!int([9, 4]);
assert(l1 == l2);
}
Function SList.opAssign
Assigns an input range.
ref typeof(this) opAssign(R)
(
scope R that
) @trusted
if (!isInfinite!R && isInputRange!R && isImplicitlyConvertible!(ElementType!R, T));
Parameters
Name | Description |
---|---|
R | Type of the initial range. |
that | Values to initialize the list with. |
Returns
this.
Example
auto l1 = SList!int([5, 4, 9]);
auto l2 = SList!int([9, 4]);
l1 = l2[];
assert(l1 == l2);
Function SList.opAssign
Assigns a static array.
ref typeof(this) opAssign(size_t R)
(
T[R] that
);
Parameters
Name | Description |
---|---|
R | Static array size. |
that | Values to initialize the list with. |
Returns
this.
Example
auto l1 = SList!int([5, 4, 9]);
auto l2 = SList!int([9, 4]);
l1 = [9, 4];
assert(l1 == l2);