function argument accepting function or delegate?
Jon D via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jan 16 23:01:14 PST 2016
On Sunday, 17 January 2016 at 06:49:23 UTC, rsw0x wrote:
> On Sunday, 17 January 2016 at 06:27:41 UTC, Jon D wrote:
>> My underlying question is how to compose functions taking
>> functions as arguments, while allowing the caller the
>> flexibility to pass either a function or delegate.
>>
>> [...]
>
> Templates are an easy way.
>
> ---
> auto call(F, Args...)(F fun, auto ref Args args) { return
> fun(args); }
> ---
> Would probably look nicer with some constraints from std.traits.
Thanks much, that works!
More information about the Digitalmars-d-learn
mailing list