On Friday, 21 February 2014 at 19:13:13 UTC, Chris Williams wrote:
On Thursday, 20 February 2014 at 17:02:15 UTC, Dicebot wrote:
You can't do it without allocation because memory layout is different for int** and int[][] in D - are.ptr in latter points to slice struct (pointer+length) as opposed to raw pointer in former.

You should only have to copy the top list, though.

int*[] temp = new int*[ arr.length ];
for (size_t i = 0; i < arr.length; i++) {
    temp[i] = arr[i].ptr;
}
int** output = temp.ptr;

Untested.

Addendum: Note that bearophile's code probably works out to the same thing.

Reply via email to