I have a structure that I pass around my application which contains a bunch of callback functions:
typedef struct {
std::function<void (void)> f1;
std::function<void (int)> f2;
std::function<int (float *)> f3;
// ... and so on
} CallbackTable;
I handle state control within the application by binding different functions to the various callbacks, depending upon the current system state; it works fine.
What I'd now like to do is to add a couple of extra callbacks with signatures containing variable numbers of arguments, akin to printf: for example,
std::function<int (const char * format, ...)> printToStdOut;
This doesn't work. In Visual C++, I get an error message stating:
error C2027: use of undefined type 'std::_Get_function_impl<_Fty>'
I'm still feeling my way through this area of C++ syntax and would very much appreciate any advice on how I should proceed from here. My overriding objective is to be able to make a call along the lines of:
myCallbackTable.printToStdOut("I've just eaten %d bananas\r\n", nBananas);
...and to have the output directed to a console, to a file or to a GUI window, according to the system state.