Template type deduction question
data pulverizer
data.pulverizer at gmail.com
Thu May 21 07:47:56 UTC 2020
On Thursday, 21 May 2020 at 07:16:11 UTC, Basile B. wrote:
> The problem is that "K" is a template type parameter [1].
> When the compiler deduces the parameter that ends up with a
> symbol, i.e not a type.
> To permit a symbol to be deduced you can use a template alias
> parameter[2] instead:
>
> ---
> struct Matrix(T) {}
> struct Kernel(T) {}
>
> void calculateKernelMatrix(alias K, T)(K!T kernel, Matrix!T
> data) { }
>
> void main()
> {
> Matrix!float m;
> Kernel!float k;
> calculateKernelMatrix(k,m); // OK
> }
> ---
Thanks!
More information about the Digitalmars-d-learn
mailing list