Thread overview |
---|
March 23, 2016 How do you append to a dynamic array using move semantics? | ||||
---|---|---|---|---|
| ||||
struct Thing { @disable this(this); } ... items ~= move(item); // Error: struct Thing is not copyable because it is annotated with @disable ++items.length move(items[$-1],item); // Error: struct Thing is not copyable because it is annotated with @disable appender(items).put(move(item)); // Error: template std.array.Appender!(Thing[]).Appender.put cannot deduce function from argument types !()(Thing) ...? |
March 24, 2016 Re: How do you append to a dynamic array using move semantics? | ||||
---|---|---|---|---|
| ||||
Posted in reply to cy | On 24.03.2016 00:26, cy wrote:
> ++items.length
> move(items[$-1],item); // Error: struct Thing is not copyable because it
> is annotated with @disable
You got the order of arguments wrong here. Source goes first, target second. Works for me with `move(item, items[$-1]);`.
|
March 24, 2016 Re: How do you append to a dynamic array using move semantics? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ag0aep6g | On 24.03.2016 00:44, ag0aep6g wrote:
> On 24.03.2016 00:26, cy wrote:
>> ++items.length
>> move(items[$-1],item); // Error: struct Thing is not copyable because it
>> is annotated with @disable
>
> You got the order of arguments wrong here. Source goes first, target
> second. Works for me with `move(item, items[$-1]);`.
Though it should compile the other way around, too. And it does for me.
|
March 24, 2016 Re: How do you append to a dynamic array using move semantics? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ag0aep6g | On Wednesday, 23 March 2016 at 23:44:55 UTC, ag0aep6g wrote:
> You got the order of arguments wrong here. Source goes first,
Oh, derp. Thanks. Right then... it works as expected.
|
Copyright © 1999-2021 by the D Language Foundation