I need to inherit multiple times the following class, taking variadic arguments as template parameters.
template <class SignalDispatcherClass, class ... ArgTypes>
class ISignalMap
{
//private
public:
void RegisterSlot(SignalAddress pSignalFunc, ISlotInvoker<ArgTypes...>* pSlotInvoker)
{
//implementation
}
};
So far I can expand a parameter pack and get multiple class specializations, but with functions taking only one argument.
template <class SignalDispatcherClass, class ... ArgTypes>
class ISignalStorage : public ISignalMap<SignalDispatcherClass, ArgTypes>...
{
};
///////
ISignalStorage<SignalA, int, double, bool> iss;
For now this allows me to register slot functions with a single argument (int, double or bool - accordingly). What I need is something that would look like:
ISignalStorage<SignalA, <int, double, bool>, <int, int>, <const char*>> iss;
So far I've been looking into other questions and one appears to be somewhat close to the topic, though I failed to implement or understand it. Wish there were a simplier way (Variadic variadic template templates)
added: code example
struct IDummySlot
{
void FuncDbl(double)
{}
void FuncInt(int)
{}
void FuncIntDbl(int, double)
{}
};
template <class ... Args>
struct ISlotInvoker
{};
template <class SignalDispatcherClass, class ... ArgTypes>
class ISignalMap
{
public:
void RegisterSlot(void(IDummySlot::*pSignalFunc)(ArgTypes...), ISlotInvoker<ArgTypes...>* pSlotInvoker)
{
return;
}
};
template <class SignalDispatcherClass, class ... ArgTypes>
class ISignalStorage : public ISignalMap<SignalDispatcherClass, ArgTypes>...
{
};
int main()
{
ISignalStorage<IDummySlot, int, double> iss;
ISlotInvoker<int> slot_int;
ISlotInvoker<double> slot_double;
ISlotInvoker<int, double> slot_intDouble;
//iss.RegisterSlot(&IDummySlot::FuncInt, &slot_int); //ambigous
/*Appears to be that I didn't test it, I just saw that inheritance worked as I expected, but didn't try to invoke*/
return 0;
}