I am looking to have one function(called F) return a pointer to one of two other functions(F1 and F2). I do not know how the function prototype for F. I have seen something in c, but it used typedefs. Thanks in advance
void one(int) { /* ... */ }
void two(int) { /* ... */ }
decltype(&one) foo( int v ) { return v < 10 ? one : two ; }
typedefvoid function_type( int ) ;
function_type* bar( int v ) { return v < 10 ? one : two ; }
#include <functional>
std::function< void(int) > baz( int v ) { return v < 10 ? one : two ; }
@Script Coder
It looks a bit weird when having function pointer as return type. It means that F is a function returning a pointer to a function with return type void taking one int argument.