Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
core.internal.array.construction
This module contains compiler support for constructing dynamic arrays
License:
Distributed under the
Boost Software License 1.0.
(See accompanying file LICENSE)
- @trusted Tarr
_d_arrayctor(Tarr : T[], T)(return scope Tarrto, scope Tarrfrom, char*makeWeaklyPure= null); - Does array initialization (not assignment) from another array of the same element type.Parameters:
Tarr towhat array to initialize Tarr fromwhat data the array should be initialized with char* makeWeaklyPureunused; its purpose is to prevent the function from becoming strongly pure and risk being optimised out Returns:The created and initialized arraytoBugs:This function template was ported from a much older runtime hook that bypassed safety, purity, and throwabilty checks. To prevent breaking existing code, this function template is temporarily declared @trusted until the implementation can be brought up to modern D expectations. The third parameter is never used, but is necessary in order for the function be treated as weakly pure, instead of strongly pure. This is needed because constructions such as the one below can be ignored by the compiler if_d_arrayctoris believed to be pure, because purity would mean the call to_d_arrayctorhas no effects (no side effects and the return value is ignored), despite it actually modifying the contents of a. const S[2] b; const S[2] a = b; // this would get lowered to d_arrayctor(a, b) - @trusted void
_d_arraysetctor(Tarr : T[], T)(scope Tarrp, ref scope Tvalue); - Do construction of an array. ti[count] p = value;Parameters:
Tarr pwhat array to initialize T valuewhat data to construct the array with Bugs:This function template was ported from a much older runtime hook that bypassed safety, purity, and throwabilty checks. To prevent breaking existing code, this function template is temporarily declared @trusted until the implementation can be brought up to modern D expectations. - pure nothrow @trusted T[]
_d_newarrayUPureNothrow(T)(size_tlength, boolisShared= false);
@trusted T[]_d_newarrayT(T)(size_tlength, boolisShared= false); - Allocate an array with the garbage collector. Also initalize elements if their type has an initializer. Otherwise, not zero-initialize the array.Has three variants: _d_newarrayU leaves elements uninitialized
_d_newarrayTinitializes to 0 or based on initializerParameters:size_t length. lengthof resulting arrayReturns:newly allocated array - @trusted Tarr
_d_newarraymTX(Tarr : U[], T, U)(size_t[]dims, boolisShared= false); - Create a new multi-dimensional array. Also initalize elements if their type has an initializer. Otherwise, not zero-initialize the array.
void main() { S[][] s = new S[][](2, 3) // lowering: S[] s = _d_newarraymTX!(S[][], S)([2, 3]); }
Parameters:size_t[] dimsarray length values for each dimension bool isSharedwhether the array should be shared Returns:newly allocated array
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Mon Mar 31 10:27:34 2025