[Issue 19139] Need a convenient syntax for invoking nested templates

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 5 09:26:22 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19139

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras at gmail.com
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
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.

--


More information about the Digitalmars-d-bugs mailing list