Jack Applegame:

Finally http://dpaste.1azy.net/fc503331

I suggest to use indents composed by 4 spaces.
Generally in D we use template constraints, instead of static ifs with a nice error message...
In such complex situations I also suggest to add braces.

Something like this:


auto castElementType(T = byte, F)(ref F from)
if (isArray!F) {
    alias E = typeof(from[0]);

    static if(is(E == const)) {
        return cast(const(Unqual!T)[])from;
    } else static if(is(E == immutable)) {
        return cast(immutable(Unqual!T)[])from;
    } else static if(is(E == shared)) {
        return cast(shared(Unqual!T)[])from;
    } else {
        return cast(Unqual!T[])from;
    }
}


Bye,
bearophile

Reply via email to