Following what @MadScienceDreams suggested, this worked out fine for me ...
First, I defined the argument variables of the versions of std :: function objects in the structure, and then used the fact that this is C ++ not C to add some methods:
typedef struct { std::function<void (void)> f1; std::function<void (int)> f2; std::function<int (float *)> f3; // ... and so on std::function<int (const char * format, va_list args)> vprintToStdOut; std::function<int (const char * format, va_list args)> vprintToStdErr; int printToStdOut(const char * format, ...) { va_list ap; va_start(ap, format); int count = vprintToStdOut(format, ap); va_end(ap); return count; } int printToStdErr(const char * format, ...) { va_list ap; va_start(ap, format); int count = vprintToStdErr(format, ap); va_end(ap); return count; } } CallbackTable;
The standard implementations of the function of the argument variables for output to the console were then (after the declaration "using namespace std :: placeholders;", without which the syntax is uncontrollable):
myCallbackTable.vprintToStdOut = std::bind(vfprintf, stdout, _1, _2); myCallbackTable.vprintToStdErr = std::bind(vfprintf, stderr, _1, _2);
... and from this point of view, I can use exactly the syntax that I was hoping to use:
myCallbackTable.printToStdOut("I like to eat at least %d bananas a day\r\n", nBananas);
source share