the "from" template and parameterized functions

aliak something at something.com
Mon Aug 27 16:03:08 UTC 2018


I can't get the from template [0] to work in the following 
situation, is it possible?

---
module m;

import std.stdio;

package template from(string moduleName) {
     mixin("import from = " ~ moduleName ~ ";");
}

version(works) {
     struct S {}
     void t(from!"m".S param) {}
     auto a = S();
} else {
     struct S(T) {}
     void t(T)(from!"m".S!T param) {} // This errors out
     auto a = S!int();
}

void main()
{
     t(a);
}
---

And the error is:

onlineapp.d(15): Error: undefined identifier T
onlineapp.d(21): Error: template m.t cannot deduce function from 
argument types !()(S!int), candidates are:
onlineapp.d(15):        m.t(T)(from!"m".S!T param)


[0] 
https://forum.dlang.org/thread/hwqqfetprqhlzqpoxkvc@forum.dlang.org


More information about the Digitalmars-d-learn mailing list