digitalmars.D.learn - How do you append to a dynamic array using move semantics?
- cy (13/13) Mar 23 2016 struct Thing {
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) ...?
Mar 23 2016
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 disableYou got the order of arguments wrong here. Source goes first, target second. Works for me with `move(item, items[$-1]);`.
Mar 23 2016
On 24.03.2016 00:44, ag0aep6g wrote:On 24.03.2016 00:26, cy wrote:Though it should compile the other way around, too. And it does for me.++items.length move(items[$-1],item); // Error: struct Thing is not copyable because it is annotated with disableYou got the order of arguments wrong here. Source goes first, target second. Works for me with `move(item, items[$-1]);`.
Mar 23 2016
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.
Mar 23 2016