huh array literals don't work since they call an allocation function, even if all the data in them is all static. That's disappointing.

We can force it though with something like this:

template arrlit(T...) {
        static __gshared immutable int[] literal = [T];
        alias arrlit = literal;
}

        arr2 ~= arrlit!(1,2,3);

then it doesn't allocate (arr2 is a StackArray btw). The arrlit.ptr is the initialized data segment, which is a much more reasonable place for it than doing a runtime allocation.

Reply via email to