How do I pass multidimensional static arrays to functions expecting dynamic arrays?

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Aug 29 18:52:44 PDT 2011


Hey btw, do you think we could use this in Phobos?

template BaseElementType(R)
{
    static if (isArray!(ElementType!R))
        alias BaseElementType!(ElementType!R) BaseElementType;
    else static if (is(typeof({return R.init.front();}()) T))
        alias T BaseElementType;
    else
        alias void BaseElementType;
}

assert(is(BaseElementType!(int[][]) == int));

Maybe a better name is RootElementType. Not too sure.


More information about the Digitalmars-d-learn mailing list