I have a template function like this:

```d
auto foo(T, Args...)(Args args) {...}
```

If I try to bind the T only, and produce a partial template function which can accept any number of parameters, but has T already specified, I get an error, because instantiating `foo!T` means Args is length 0.

I was surprised not to see something in std.meta that could create this for me. In `std.functional` there is `partial` (which bizarrely only allows one parameter to be specified), but I don't see an equivalent for template parameters.

For functions, it seems IFTI can't see through to infer the template parameters of the alias, but you can have a function wrapper:

```d
template bindFirst(alias F, Args...)
{
   // this doesn't work
   // alias bindFirst(Args2...) = F!(Args, Args2);
   // but this does
auto bindFirst(Args2...)(Args2 args2) { return F!(Args)(args2); }
}

alias bf = bindFirst!(foo, int);
bf("hello", 5); // ok
```

It would be nice if the alias worked, but I don't know what's involved to make IFTI work there. I know I can alter foo to be a template within a template. Perhaps that's the right answer. However, this doesn't help for functions already written that I can't alter.

Any ideas on how to solve this? I know my function solution is not very flexible...

-Steve

Reply via email to