https://d.puremagic.com/issues/show_bug.cgi?id=12315
--- Comment #2 from [email protected] 2014-03-09 05:26:20 PDT --- (In reply to comment #1) > Changing this to dmd CTFE bug. I can't think of any way to solve it in Phobos > without more compiler support. This seems to work: import std.traits: ForeachType; ForeachType!R[] myArray(R)(R r) { if (__ctfe) { typeof(return) result; foreach (item; r) result ~= r; return result; } else { // ... assert(0); } } struct Foo1 { int i; } struct Foo2 { immutable int i; } void main() { enum r1 = [Foo1(1)].myArray; // OK enum r2 = [Foo2(1)].myArray; // OK } -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
