Suppose "foo_double" should return a complex double slice, with double input args.
Similarly "foo_float" should return a float slice, with float input args.
I thought it should be easy to parameterize with a template taking a SINGLE
argument, either a"double" or "float" as follows:
import std.stdio;
import std.complex;
Complex!double[] foo_double(double x, double y){
auto r = [x, x];
auto i = [y, y];
auto z = [ Complex!double(x, y), Complex!double(x,y) ];
return z;
}
Complex!float[] foo_float(float x, float y){
auto r = [x, x];
auto i = [y, y];
auto z = [ Complex!float(x, y), Complex!float(x,y) ];
return z;
}
T[] foo_temp(Complex!T[])(T x, T y){
auto r = [x, x];
auto i = [y, y];
auto z = [ Complex!T(x, y), Complex!T(x,y) ];
return z;
}
void main(){
auto yd = foo_double(1.1, 2.2);
writeln(yd); ...
}
But, no ... I am WRONG! I get the message:
qqq.d(18): Error: identifier expected for template value parameter
Nested templates using Complex! really have me confused. How should I
be thinking about such things in order to understand better?
Best Regards,
James