Error: template instance does not match template declaration

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 29 11:29:27 PDT 2016


On 03/29/2016 11:21 AM, ref2401 wrote:

 > private void impl(S, T, T[string] dict)(S arg) {
 >      writeln("S: ", S.stringof);
 >      writeln("T: ", T.stringof);
 >      writeln("dict: ", dict);

So, dict is a template value parameter of type T[string]. I don't think 
you can use an associative array as a template value parameter. (Can we?)

However, it is possible to use anything as an alias template parameter.

If it's acceptable in your case, the following works:

private void impl(S, T, alias dict)(S arg)
         if (is (typeof(dict) == T[S])) {

(Or T[string]).

Ali



More information about the Digitalmars-d-learn mailing list