Passing function as values and returning functions

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 11 05:19:06 PDT 2012


On Wed, 11 Apr 2012 08:08:44 -0400, Xan <xancorreu at gmail.com> wrote:

> On Wednesday, 11 April 2012 at 11:59:14 UTC, Jacob Carlborg wrote:

>> Use "delegate" or "function" both for the argument type and return type.
>
>
> How to do that?

int function(int) g(int function(int a) p) { return p; }

Should do the trick.

delegates are not implicitly convertible to/from function pointers.

You can, however, explicitly convert a function to a delegate.  But this  
should be done only when there is a requirement to use delegates.

However, use std.functional.toDelegate if you are interested.

-Steve


More information about the Digitalmars-d-learn mailing list