Please consider the following program:

struct V(T) {
    int opApply(scope int delegate(ref T value) dg) {
        return 0;
    }
    int opApply(scope int delegate(ref const T value) dg) const {
        return 0;
    }
}

struct V1(T) {
    int opApply(scope int delegate(ref inout T value) dg) inout {
        return 0;
    }
}

void main() {
    const V!int mytype1;
    V!int mytype2;
    V1!int mytype3;

    foreach( v; mytype1 ) {
    }
    foreach( v; mytype2 ) {
    }
foreach( v; mytype3 ) { // <- This line doesn't compile: cannot uniquely infer foreach argument types
    }
}

So the only way to get inout to work is... not to use it?

Shachar

Reply via email to