convert int[][] to int**
Chris Williams
yoreanon-chrisw at yahoo.co.jp
Fri Feb 21 11:13:11 PST 2014
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.
More information about the Digitalmars-d-learn
mailing list