For a library, I\'d like a function to accept another function and its arguments, then store them all for calling later. The arguments must allow for any mixture of types, b
If you want/are able to make use of the C++11 future library you can use std::async
#include
auto caller = std::async(myFunc1, 123, 45.6); // Creates a future object.
caller.get(); // Waits for the function to get executed and returns result.
To force lazy evaluation use:
auto caller = std::async(std::launch::deferred, myFunc1, 123, 45.6);
Also this has the advantage that the function call might be executed on a different thread which makes use of multicore hardware. However this may not be suitable in every case.