I'm trying to register a function that returns an int to be called at the end of a program using the atexit() function. (Specifically, the endwin() function from ncurses.)
But since atexit() needs a pointer to a void function, I ran into a problem. I tried the following:
static_cast<void (*)()>(endwin)
but static_casting from an int function to a void function doesn't seem to be allowed.
Is what I'm trying to accomplish possible at all, and if yes, how?
Note: I'm willing to just ignore the return value of the function.
Edit: I also tried creating a lambda function, which seems to do what I want:
atexit([]{ endwin(); });
Is this a good solution compared to a wrapper/forwarding function? (Other than that it needs C++11 and avoids defining a new function whose sole purpose is just forwarding another function.)