I am trying to store a function pointer to be callbacked later like so:
Task->Sync->SetPeriodicTask( &TaskAssigner::ReadAndRelay );
TaskAssigner class declares void ReadAndRelay() and it holds a SyncManager* Sync object.
(It may be odd, but the child object Sync needs to call back to its parent class' function at certain intervals).
I attempt it like this:
void SyncManager::SetPeriodicTask(std::function<void()> func) {
CB_func_periodic = func;
//CB_func_periodic = std::bind(&func, this, std::placeholders::_1);
}
Member variable declaration (SyncManager.h):
private:
using func = std::function<void()>;
func CB_func_periodic;
I am not sure what is the correct syntax here, as I get so many errors. Tried searching the errors, but I couldn't find an answer that suits my case, and I don't want the parameter of SetPeriodicTask(..) to be too complicated for other users to write. How should I approach this?