Parameters declared as the alias of a template won't accept the arguments of the same type.

JG someone at somewhere.com
Sun May 1 11:34:49 UTC 2022


On Sunday, 1 May 2022 at 07:59:57 UTC, Elfstone wrote:
> On Sunday, 1 May 2022 at 06:42:26 UTC, Tejas wrote:
>> On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote:
>>>     module test;
>>>
>>>     struct MatrixImpl(S, size_t M, size_t N)
>>>     {
>>>     }
>>>
>>> [...]
>>
>> AFAICT, I'm afraid you'll have to stick to `dot2` 🙁
>>
>>
>> This DIP I believe does what you want but... It wasn't looked 
>> upon favorably...
>>
>> https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1023.md
>
> Thanks a lot! So this really is a D "feature".
> The current behaviour is so broken. It makes no sense, for a 
> language user at least.
> I don't understand why it's not yet solved, if it's a known 
> issue.

I guess the current best is something like:

```d
enum isVector(V) = is(V==MatrixImpl!(S,1,N),S,size_t N);

@nogc
auto dot1(V)(in V lhs, in V rhs)
if(isVector!V) {
     return dot2(lhs,rhs);
}
```

or

```d
enum isVector(V) = is(V==MatrixImpl!(S,1,N),S,size_t N);

@nogc
auto dot1(V)(in V lhs, in V rhs)
if(isVector!V) {
     static if(is(V==MatrixImpl!(S,1,N),S,N)) { S ret=0; return 
ret; }
     static assert("This should never been shown");
}
```





More information about the Digitalmars-d-learn mailing list