On Monday, 8 June 2020 at 00:31:10 UTC, Steven Schveighoffer wrote:

This is a bug, please file. What is likely happening is that the template is not moving the data to the underlying C call.

-Steve

That is not a bug, it's a shortcoming of garbage-collected arrays. D arrays are not equipped to deal with non-copyable values. The ~= has to expect to copy contents of arr, since at runtime there may be multiple references to it, i.e:

auto storage = [NonCopyable(a), /* .... */];
auto arr = storage[1 .. 3];

arr ~= NonCopyable(n);

This would need to allocate a new array and copy contents of storage[1 .. 3] into it.

Reply via email to