static if and templates
Oliver
oliver.ruebenkoenig at web.de
Thu Sep 27 00:50:13 PDT 2007
Hi,
in the function isMatrix I would like to access the function isArray. Unfortunately, this does not work, even though if I use the definition of isArray directly it does work.
How could I write the code using isArray? Thanks for any hints.
Oliver
------------------
import std.stdio;
bool isArray(T)(T expr){
return (expr.mangleof)[0] == 'A';
}
bool isMatrix(T)(T expr){
static if ( (expr.mangleof)[0] == 'A' ) // works
//static if ( isArray(expr) ) // does NOT work
return (expr.mangleof)[1] == 'A';
else
return false;
}
void main () {
double s = 1.;
double[] v = [1.,2.];
double[][] m = [[1.,2.]];
writefln("s: ", isArray(s), " ", isMatrix(s) );
writefln("v: ", isArray(v), " ", isMatrix(v) );
writefln("m: ", isArray(m), " ", isMatrix(m) );
}
More information about the Digitalmars-d-learn
mailing list