See this simple example:

int staticFind(T, S...)() {
    foreach(id, R; S) {
        if (is(T == R))
            return id;
        }
    }
    return -1;
}

staticFind!(int, int, double) will generate a 'statement is unreachable' warning, and staticFind!(int, double) won't.

This behaviour is understandable, but annoying. If template writer cares about this unreachable warning, they basically can't use any early return at all.

So previous example has to be re-written into:

int staticFind(T, S...)() {
    int ret = -1;
    foreach(id, R; S) {
        if (is(T == R) && ret == -1)
            ret = id;
        }
    }
    return ret;
}

However, this might not always be so simple in more complex functions. And this could potentially increase compilation time (maybe?).

Reply via email to