I have 3 comments (if you're still reading this thread :) )

First, you could let nextGen determine the return type. Since the
template know that nextGen returns an int delegate(int), there is no
need for the user to provide the 'int' parameter.

So user code could become:

void main(string[] argv)
{
    auto exFunc = &exT!(nextGen).exFunc; // <- here
    exFunc();
}

Second, you could have exT return (become) the function itself, saving
you the trouble to call it with exT!(...).exFunc
In that case, exT could be a template function.

Third, you can also use it directly, like this:

    // First call:
    exT!(nextGen)();

If you still want to name it other wise, you can use and alias:


    // Second call:
    alias myFunc1 = exT!(nextGen);
    myFunc1();


Or use a function pointer, as in your initial code:

    // Third call:
    auto myFunc2 = &exT!(nextGen);
    myFunc2();

Which gives us shorter developer and user code. See here.

http://dpaste.dzfl.pl/63a220cf

Reply via email to