I made a template function that takes a member function as a parameter.
However, since the class must be declared before it can be used as part of a member function parameter, I must make it a separate parameter:
template<typename C, void (C::*Method)(void)>
function<void(C*)> methodWrap()
{
}
This means that when I explicitly create an instance of the template (I want these wrappers to be generated at compile time, and not in the member pointer as an argument), I have to enter it twice when I use it:
function<void(C*)> someFunc = wrapMethod<SomeClass, &SomeClass::someMethod>();
Why can't I just write something like tis:
template<void (C::*Method)(void)>
function<void(C*)> methodWrap()
{
}
and let it capture type C and its pointer to a member function, without requiring you to enter SomeClass twice?
, C " ", ,
template<typename C>
template<void (C::*Method)(void)>
function<void(C*)> methodWrap()
{
}