On Sunday, 12 October 2014 at 19:46:41 UTC, ketmar via
Digitalmars-d-learn wrote:
Hello.
please, how to call template constructor of a class? it's
completely
escaped my mind. i.e. i have this class:
class A {
this(alias ent) (string name) {
...
}
}
and i want to do:
void foo () { ... }
auto a = new A!foo("xFn");
yet compiler tells me that
"template instance A!foo A is not a template declaration, it is
a class"
yes, i know that i can rewrite constructor to something like
this:
this(T) (string name, T fn) if (isCallable!T) {
...
}
and then use autodeduction, but i want the first form! ;-)
How about a static factory method? Or do you know there is a
syntax for invoking a templatized constructor and just can't
remember it?