[disclaimer: I don’t know what I’m talking about in this comment]
Could you say like,
auto arr = new int[a*(b+1)];
int \* arr2 = (int\*)arr;
for(int i=0;i<a;i++){
arr2[i]=arr+(i*(b+1))+1;
}
and then be able to say like arr2[j][k] ?
(Assuming that an int and a pointer have the same size).
It still has to do two dereferences rather than doing a little more arithmetic before doing a single dereference, but (other than the interspersed pointers) it’s all contiguous?
But maybe that doesn’t count as being flat in memory.
You can do some trick like that, though arr2 would have to have type int** for that to work, and it wouldn't really work for an int array (though there's no real reason to store the pointers into arr inside arr itself - they could easily go into a separate place).
However, this would still mean that you need to do 2 pointer reads to get to an element (one to get the value of arr2[i], then another to get the value of arr2[i][j]). In C or Fortran or C++ with compile-time known dimensions, say an N by M array, multiArr[i][j] is a single pointer read, as it essentially translates to *(multiArr + i*M + j).
Could you say like,
and then be able to say like arr2[j][k] ?(Assuming that an int and a pointer have the same size).
It still has to do two dereferences rather than doing a little more arithmetic before doing a single dereference, but (other than the interspersed pointers) it’s all contiguous? But maybe that doesn’t count as being flat in memory.