I am passing a pointer to a member function into a template function. Something like this,
Foo bar; /* bar.baz(...) is a function */
auto pnt = bar.baz;
passMmbFunc<...,decltype(pnt)>(...,pnt);
The relevant parts of passMmbFunc
look like this,
template <..., typename D>
void map(..., D func) {
...
auto ret = func(someVal);
...
}
I assumed that the syntax for calling a pointer to a member function is the same as a regular pointer to function but it is not. I get the following error,
error: must use '.*' or '->*' to call pointer-to-member function in 'func (...)', e.g. '(... ->* func) (...)'
From within passMmbFunc
, how would I call pnt? I know that a pointer to a member function can be called if you have a object of the respective class handy. But since I am passing it as a parameter, that is not the case. So, is there anyway to call a pointer to member function if you only have a pointer and no object?