I don't get it. Do I have to write a separate template for arrays specifically or something?

NonConst foo(Constant: const NonConst, NonConst)(Constant bar) {
        pragma(msg,"NonConst is ",NonConst);
        pragma(msg,"Constant is ",Constant);
        NonConst foo = bar;
        return foo;
}

void main() {
        const int bar = 42;
        auto baz = foo(bar);
        pragma(msg,typeof(baz));
        baz = 23;
        const(int[]) barr = [1,2,3];
        auto bazz = foo(barr);
        pragma(msg,typeof(bazz));
        bazz[0] = 4;

}

/*

NonConst is int
Constant is const(int)
int
NonConst is const(int)[]
Constant is const(int)[]
const(int)[]
derp.d(16): Error: cannot modify const expression bazz[0]
Failed: ["dmd", "-v", "-o-", "derp.d", "-I."]

*/

Reply via email to