How to allocate an array of AA? 1) I tried two ways (new, and setting array length), in both cases the code compiles, but the executable seems run into infinite loop, and never finish. 2) how to new an AA? what's the syntax? http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=67463 http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=67466 $ cat mapbug.d void allocAA() { int[int][] maps; maps = new int[int][3]; maps.length = 3; int[int]* mapsp; //mapsp = new int[int]; // this line need size of rightmost array, not type int } int main() { allocAA(); return 0; }
Created attachment 232 [details] infinite loop, allocate an array of AA
As for your second question, I'm not sure that there's a general way. But mapsp = (new int[int][1]).ptr; should work once the underlying bug is fixed. Meanwhile, a workaround is int[int][1] mapsa; mapsp = mapsa.dup.ptr; But since the main bug you're reporting has already been reported and voted on, I'm marking this as a dupe. *** This bug has been marked as a duplicate of 929 ***
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル