On Friday, 15 February 2019 at 14:30:45 UTC, Alex wrote:

There is
https://dlang.org/library/std/functional/to_delegate.html

Ah, there it is :-) Thanks.

A templated function also works.

```
int genfun(F)(F dg) {return dg();}
​
int top_level() {return -1;}
​
void main()
{
    int nested() {return -2;}
    assert(genfun(&top_level) == -1);
    assert(genfun(&nested) == -2);
}
​```

Reply via email to