I'm trying to figure out a way to hold multiple callback functions with different signatures.
Concretely, say I have structs accel_t
and gyro_t
which will be the arguments to two different callback functions void cb1(const accel_t &msg)
and void cb2(const gyro_t &msg)
, I will then want to pass cb1 and cb2 to a subscribe()
function for it to be added to some form of a container (say std::list or std::vector).
I'm imagining I have a callback function defined in my body like this:
void cb1(const accel_t &msg)
{
/**do stuff*/
}
My subscribe function will look like this:
myclass.subscribe<accel_t>(cb1);
What would be the best way to implement this ?
Aucun commentaire:
Enregistrer un commentaire