No idea how I could rephrase the title better.
I want to move low level code outside of a simple function and move the code inside the class so the class takes care of the more complicated stuff.
I want to go from this:
void a(void) {
[low level operation];
//User typed simple operations
[low level operation];
}
static void AClass::b() {
register(a); //register(void (__cdecl *func)())
}
int main(void) {
AClass::b();
return 0;
}
To:
void a(void) {
//[no low level operation]
//User typed simple operations
//[no low level operation]
}
static void AClass::b(void (*func)()) {
auto funcA = [] (void (*func)()) -> void (*)() {
[that first low level operation];
func(); //Which is: void a(void);
[the second low level operation];
};
register(funcA(func));
}
int main(void) {
AClass::b(&a);
return 0;
}
At the moment I get the error "< lambda >::operator ()' : function must return a value" - because of the pointer. How could I solve this problem? Returning just void doesn't work. Passing the arguments(the function "func") by reference to the lambda also doesn't work(Cause in this case the lambda is not just a function any more but a Class) - the register(void (__cdecl *func)()) can't convert the now not a function lambda.
Any ideas how to solve my problem?