I have a class method which takes in a function pointer of an object of any class but with a specific return and parameter list.
The problem is that the compiler returns that what I pass is not the same as the arguments of the method I'm using.
There are other things I'm have trouble with but I will point them out below and as always not every detail is here only whatever is important.
Class.h:
template<typename Value, typename ...Args>
class thing <Value(Args...)>
{
/* moar code */
template<typename C>
void method(C* object, Value(C::*func)(Args...), Args... /*how do I pass all of the parameters from here*/)
{
(object->*fund)(/*then put the parameters in here*/);
/* Also would this work with or with out parameters being passed*/
/* this is then wrapped and stored to be used later */
}
}
In main func:
thing<void(int)> thingObj;
AClass obj(/*initialise if needed*/);
thingObj.method(&obj, &AClass::func, /*Parameters*/);
Reason for not using boost/std::function is this is an experiment so I can lean how this works
Excuse the typos and lack of formatting on phone, will correct things and add detail wherever I feel necessary
You can use indices for it.
Then write overloading of your method like this
And call it in your first method like
Live example
This works for me: