How to move append to an array?
Stanislav Blinov via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 15 16:36:06 PDT 2017
On Monday, 15 May 2017 at 21:38:52 UTC, Yuxuan Shui wrote:
> Suppose I have a
>
> struct A {
> @disable this(this);
> } x;
>
> How do I append it into an array?
>
> Do I have to do
>
> array.length++;
> moveEmplace(x, array[$-1]);
>
> ?
moveEmplace is for moving an initialized object into an
uninitialized one. Use the two-argument move() function:
move(x, array[$-1]);
More information about the Digitalmars-d-learn
mailing list