Non-consistent implicit function template specializations

Rekel paultjeadriaanse at gmail.com
Tue Aug 17 18:07:07 UTC 2021


On Tuesday, 17 August 2021 at 16:24:38 UTC, Steven Schveighoffer 
wrote:
>> void foo(T:U[L], uint L)(T a){...}
>
> This is an invalid specification, what is U? Did you mean:

Yes, sorry typo in the forum.

> void foo(T: U[L], U, uint L)(T a) {...}
>
>> void foo(T:U[L][L], uint L)(T a){...} // Never matched
>
> Apart from another missing U, this is only a SQUARE 2d-array 
> (both dimensions the same), your example below only calls with 
> a 1x2 array.

Again, sorry a typo, calling with `[[1,2],[3,4]]`.

>> void foo(T:U[L], U:V[L], V uint L)(T a){...} // Never matched 
>> (alternatively)
>
> I don't think you need this, and I had to comment it out, or 
> the compiler wouldn't build.

That is correct, it's equivalent thus causes 2 matches.

> All these are calling with array literals, which default to 
> dynamic arrays, not static arrays.

I realise that is their default, though in this scenario they 
should (I believe) be used as static arrays. (This works for me 
in any case)


More information about the Digitalmars-d-learn mailing list