Currently, given:
template A() {
template A() {
enum A = 1;
}
}
This:
A!()!()
does not compile (multiple ! arguments are not allowed).
Neither does this (C style cast illegal):
(A!())!()
The only way to invoke the nested template seems to be:
alias B = A!();
B!()
This is less than ideal.
Comment #1 by simen.kjaras — 2018-08-05T09:26:22Z
import std.meta : Instantiate;
template A() {
template A() {
enum A = 1;
}
}
unittest {
enum i = Instantiate!(A!());
}
Now, that shows it's possible in the language to work around this issue. The real issue however, is that multiple ! arguments are not allowed.
From what I can gather on the forum, the reason is a perceived ambiguity, in that F!T!int could mean F!(T!int) or (F!T)!int. The language already provides tools to disambiguate between them - the first example is how you'd invoke it that way, and the other example is simply impossible in the language right now.
Comment #2 by robert.schadek — 2024-12-13T19:00:06Z