1
votes

How do I apply just the template arguments to a function that expects template arguments, without implicitly also calling the function with zero arguments? I want a function or delegate pointer instead of a value.

void foo(T)(double x) {}

auto bar() {
    return foo!(int);
}
hack.d(36): Error: function hack.foo!int.foo(double x) is not callable using argument types ()
hack.d(36):        missing argument for parameter #1: double x
1

1 Answers

3
votes

If you had an ordinary function

void foo() {}

and you wanted a function pointer to it, how would you do that?

&foo

Now, suppose you have a template:

void foo(T)() {}

and want a pointer to a specific instance... you can probably guess at this point :)

&foo!arg