A static array contained inside a struct is not accessible during CTFE. Because of this, it seems impossible (since some versions) to define compile-time constants of such structures (for example tuple vectors or matrices). --- struct S { int arr[1]; this(int x){ arr[0] = x; // (this.arr[0u]) = x cannot be evaluated at compile time } } immutable S s_constant = S(1); // Error: cannot evaluate __ctmp1.this(1) at compile time ---
a.b[i]=c; isn't implemented in CTFE yet, but a.b=c; is, so I'm downgrading from blocker. (It's still high priority, though). Workaround: struct S { int arr[1]; this(int x){ int[1] z = x; arr = z; } }
Unfortunately, the workaround also errors out with (although I did not check a current svn build): test.d(6): Error: this.arr[] = cast(const(int[]))x cannot be evaluated at compile time But this gave me finally another idea, which seems to work: struct test { int[1] f; this(int x){ int[] dst = f; dst[0] = x; } } [Now off to some code porting and finally trying out the recent features... ;-)]
Unfortunately, the workaround also does not work (compiles but generates incorrect code): http://d.puremagic.com/issues/show_bug.cgi?id=3984.
Yeah, there doesn't seem to be any workaround. Changing it back to blocker.
Fixed. D1: https://github.com/D-Programming-Language/dmd/commit/ef2a0f1da10331c4de102ca3e029ea1c1c1a46bf D2: https://github.com/D-Programming-Language/dmd/commit/0219a5f0dcc88076759a4c472582954d0fb804b0
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル