nested templates using Complex! with slices, ... confused, I am!
Paul Backus
snarwin at gmail.com
Mon Aug 9 18:44:34 UTC 2021
On Monday, 9 August 2021 at 18:35:56 UTC, james.p.leblanc wrote:
>>```d
>>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
I think what you want is:
```d
Complex!T[] foo_temp(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;
}
```
This is what I get when I take one of the non-template versions
and replace `float` or `double` with `T`.
More information about the Digitalmars-d-learn
mailing list