Why this template code does not compile?

Victor Porton porton at narod.ru
Wed Mar 13 17:38:02 UTC 2019


Why this template code does not compile?

///
module runnable;

import std.meta;
import std.typecons;

template FieldInfo(argT, string argName) {
     template FieldInfo(Nullable!argT argDefault = 
Nullable!argT()) {
     }
}

alias processFields(T, string name) =
     AliasSeq!(FieldInfo!(T, name)());

void main(string[] args)
{
     alias Fields = processFields!(int, "x");
}
///

/tmp/temp_7F58BE2F0150.d(12,34): Error: template 
`runnable.FieldInfo!(int, "x").FieldInfo` cannot deduce function 
from argument types `!()()`, candidates are:
/tmp/temp_7F58BE2F0150.d(7,5):        `runnable.FieldInfo!(int, 
"x").FieldInfo(Nullable!int argDefault = Nullable!argT())`
/tmp/temp_7F58BE2F0150.d(16,20): Error: template instance 
`runnable.processFields!(int, "x")` error instantiating

LDC - the LLVM D compiler (1.11.0):
   based on DMD v2.081.2 and LLVM 6.0.1


More information about the Digitalmars-d-learn mailing list