If I understand correctly, do you want to return a function link to the next function in the state chain and that all functions of the state step have the same signature?
I see that the problem is that the return type is the function itself, so declaring the type of the function calls a recursive type definition.
So you want to write RetType fn_(float) form functions, but RetType type (basically) RetType fn_(float) . So now we have (RetType (*)(float)) fn_(float) or something like that, but no matter how hard we try, we can't get rid of RetType.
You cannot disable this recursion without forwardly declaring something. We can forward declaration classes and use them, so let's write a simple class wrapper for your function pointer, which may have hinted at @Jarod. Now std :: function is a class sort for your function, but this requires an explicit type declaration, which we do not have.
class Widget; class StateFn; class StateFn { Widget * THIS; StateFn (Widget::*Fn)(float); public:
So now the recursive definition is broken, our state functions can return StateFn objects, and we can call them.
source share