Base type for arrays
Namespace via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 17 13:33:09 PDT 2015
----
import std.stdio;
template BaseTypeOf(T) {
static if (is(T : U[], U))
alias BaseTypeOf = BaseTypeOf!(U);
else
alias BaseTypeOf = T;
}
void foo(T : U[], U)(T arr) if (is(BaseTypeOf!(U) == real)) {
}
void main() {
//real _x;
real[2] x;
real[2][2] xx;
real[2][2][2] xxx;
//float[2] yy;
//foo(_x);
foo(x);
foo(xx);
foo(xxx);
//foo(yy);
}
----
should work
More information about the Digitalmars-d-learn
mailing list