function argument accepting function or delegate?
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jan 22 05:42:52 PST 2016
On 1/17/16 1:27 AM, 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.
>
> Simply declaring an argument as either a function or delegate seems to
> prohibit the other. Overloading works. Are there better ways?
If you are looking for a runtime way to do this (the template alias way
works too), you may look at std.functional.toDelegate which converts a
function pointer to a delegate.
But it is awkward to make this a requirement for your user.
-Steve
More information about the Digitalmars-d-learn
mailing list