On Wednesday, 8 October 2025 at 07:46:32 UTC, Vindex9 wrote:
On Wednesday, 8 October 2025 at 02:58:15 UTC, Steven
Schveighoffer wrote:
My attempt:
```d
import std.traits;
inout(T)[] copyArray(T)(inout(T)[] arr) {
alias M = Unqual!T;
```
Unfortunately, `Unqual` in your code doesn't do an
Here's a slightly better solution. The lines will be copied.
```d
T[] copyArray(T)(inout(T)[] arr) {
T[] copy = new T[arr.length];
copy.length = arr.length;
static if (is(T == U[], U) && !is(T == immutable(Y)[], Y)) {
foreach(i, ref v; copy) {
v = copyArray(arr[i])
On Tuesday, 7 October 2025 at 18:43:18 UTC, Vindex9 wrote:
What am I doing wrong?
I want a safe copy: `const string[][] -> string[][]`.
I think the approach should be, make a copy, then cast the copy,
recurse if it's a nested array.
What you are likely running into is that D automatically s