I made a template function which takes a member function as a parameter.
However, since the class has to be declared before it can be used as part of the member function parameter, I have to make it a separate parameter:
template<typename C, void (C::*Method)(void)>
function<void(C*)> methodWrap()
{
}
Which means when explicitly instantiate the template (I want these wrappers to be generated at compile time, not passing in a member pointer as an argument) I have to type 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 the type of C and its member function pointer without having to type SomeClass twice?
Or why can't I wrapper it in an outer template that declares C as a "free variable" and then has an inner template argument that performs the deduction
template<typename C>
template<void (C::*Method)(void)>
function<void(C*)> methodWrap()
{
}