I tried to combine the two solutions (Basile with the wrapper, Marco with the struct initializer support) but it didn't work. The struct initializer is not a array literal (seems obvious now). I might go with the 2nd but it's pretty heavy just to get the size.

Thanks.


struct S {
    int a, b;
}

auto toStaticArray(alias array)()
{
    struct S { int a, b; }

    immutable tab = {
        static enum S[] s = array;
        return cast(typeof(s[0])[s.length])s;
    }();
    return tab;
}

enum a = toStaticArray!([{1,2},{3,4}]);  // error

Reply via email to