Comment #0 by verylonglogin.reg — 2011-07-15T07:25:46Z
Maybe it duplicates some other issue, but I didn't find it.
Or maybe it is issue 2296.
void f(T: T[n], size_t n)(T[n] t) { }
void main()
{
int[2] a;
f!(typeof(a))(a); //this compiles
f(a); //this doesn't
}
main.d(7): Error: template main.f(T : T[n],uint n) does not match any function template declaration
main.d(7): Error: template main.f(T : T[n],uint n) cannot deduce template function from argument types !()(int[2u])
Comment #1 by yebblies — 2011-07-15T07:32:16Z
void f(T: U[n], U, size_t n)(T t) { } works as a substitute.
Comment #2 by verylonglogin.reg — 2011-07-15T07:47:46Z
Another workaround is D2 constraints (more powerful and less buggly):
import std.traits;
void f(Tn)(Tn t) if(isStaticArray!Tn) { }
Comment #3 by k.hara.pg — 2013-04-08T21:11:37Z
(In reply to comment #0)
> void f(T: T[n], size_t n)(T[n] t) { }
>
> void main()
> {
> int[2] a;
> f!(typeof(a))(a); //this compiles
> f(a); //this doesn't
> }
The template function never called with IFTI, because:
1. T is deduced to int from the argument 'a'.
2. T is tested with specialized signature `: T[n]`. But T is int, so never match.
Although it looks weird behavior, it is not a bug.