On Thursday, November 17, 2016 01:27:45 Meta via Digitalmars-d wrote:
> auto bug(alias f)()
> {
>      return cast(typeof(f))&f;
> }
>
> void fun() {}
>
> void main()
> {
>   bug!fun(); //Error: functions cannot return a function
> }

Well, you _can't_ return a function. You could return a function pointer or
a delegate, but not a function. What would it even mean to return a
function?

Why don't you just return &f? I don't understand why you're doing the cast.
&f should give you a pointer to f, so you have a function pointer that you
can then call later (though you'd need to assign the result of bug!fun() to
a variable, since it does nothing otherwise).

-  Jonathan M Davis

Reply via email to