equivalent of std.functional.partial for templates?
Steven Schveighoffer
schveiguy at gmail.com
Wed Aug 11 14:15:32 UTC 2021
On Wednesday, 11 August 2021 at 14:08:59 UTC, Paul Backus wrote:
> On Wednesday, 11 August 2021 at 14:03:50 UTC, Paul Backus wrote:
>> On Wednesday, 11 August 2021 at 14:00:33 UTC, Steven
>> Schveighoffer wrote:
>>> 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.
>>
>> https://phobos.dpldocs.info/std.meta.ApplyLeft.html
>
> Should have read further--this does not work with template
> functions due to [issue 1807.][1] My mistake.
>
> [1]: https://issues.dlang.org/show_bug.cgi?id=1807
So first, I though ApplyLeft would work, but I convinced myself
it was focused on applying the template to arguments
individually, but that's just the example used. ApplyLeft is
exactly what I'm looking for, but as you said (and as my example
shows), it doesn't work in this case. It would be nice to have
something that would work (or make ApplyLeft work via a compiler
change).
Thanks for the nudge!
-Steve
More information about the Digitalmars-d-learn
mailing list