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.arrayassign

@trusted Tarr _d_arrayassign_l(Tarr : T[], T)(return scope Tarr to, scope Tarr from);
Does array assignment (not construction) from another array of the same element type. Handles overlapping copies. Assumes the right hand side is an lvalue,
Used for static array assignment with non-POD element types:
struct S
{
    ~this() {} // destructor, so not Plain Old Data
}

void main()
{
  S[3] arr;
  S[3] lvalue;

  arr = lvalue;
  // Generates:
  // _d_arrayassign_l(arr[], lvalue[]), arr;
}
Parameters:
Tarr to destination array
Tarr from source array
Returns:
to
@trusted Tarr _d_arrayassign_r(Tarr : T[], T)(return scope Tarr to, scope Tarr from);
Does array assignment (not construction) from another array of the same element type. Does not support overlapping copies. Assumes the right hand side is an rvalue,
Used for static array assignment with non-POD element types:
struct S
{
    ~this() {} // destructor, so not Plain Old Data
}

void main()
{
  S[3] arr;
  S[3] getRvalue() {return lvalue;}

  arr = getRvalue();
  // Generates:
  // (__appendtmp = getRvalue), _d_arrayassign_l(arr[], __appendtmp), arr;
}
Parameters:
Tarr to destination array
Tarr from source array
Returns:
to
@trusted Tarr _d_arraysetassign(Tarr : T[], T)(return scope Tarr to, ref scope T value);
Sets all elements of an array to a single value. Takes into account postblits, copy constructors and destructors. For Plain Old Data elements,rt/memset.d is used.
struct S
{
    ~this() {} // destructor, so not Plain Old Data
}

void main()
{
  S[3] arr;
  S value;

  arr = value;
  // Generates:
  // _d_arraysetassign(arr[], value), arr;
}
Parameters:
Tarr to destination array
T value the element to set
Returns:
to