SList.this - multiple declarations
Function SList.this
Creates a new SList with the elements from a static array.
this(size_t R)
(
T[R] init,
shared Allocator allocator = defaultAllocator
);
Parameters
Name | Description |
---|---|
R | Static array size. |
init | Values to initialize the list with. |
allocator | Allocator. |
Example
auto l = SList!int([5, 8, 15]);
assert(l .front == 5);
Function SList.this
Creates a new SList with the elements from an input range.
this(R)
(
scope R init,
shared Allocator allocator = defaultAllocator
)
if (!isInfinite!R && isInputRange!R && isImplicitlyConvertible!(ElementType!R, T));
Parameters
Name | Description |
---|---|
R | Type of the initial range. |
init | Values to initialize the list with. |
allocator | Allocator. |
Function SList.this
Creates a new SList.
this
(
size_t len,
auto ref T init,
shared Allocator allocator = defaultAllocator
);
this
(
size_t len,
shared Allocator allocator = defaultAllocator
);
this
(
shared Allocator allocator
);
Parameters
Name | Description |
---|---|
len | Initial length of the list. |
init | Initial value to fill the list with. |
allocator | Allocator. |
Example
auto l = SList!int(2, 3);
assert(l .front == 3);
Example
auto l = SList!int(2);
assert(l .front == 0);
Function SList.this
Initializes this list from another one.
this(R)
(
ref R init,
shared Allocator allocator = defaultAllocator
)
if (is(Unqual!R == SList));
this(R)
(
R init,
shared Allocator allocator = defaultAllocator
) @trusted
if (is(R == SList));
If init is passed by value, it won't be copied, but moved. If the allocator of ($D_PARAM init) matches allocator, this will just take the ownership over init's storage, otherwise, the storage will be allocated with allocator and all elements will be moved; init will be destroyed at the end.
If init is passed by reference, it will be copied.
Parameters
Name | Description |
---|---|
R | Source list type. |
init | Source list. |
allocator | Allocator. |
Example
auto l1 = SList!int([5, 1, 234]);
auto l2 = SList!int(l1);
assert(l1 == l2);