Reputation: 13257
I am trying to pass a Class member function pointer
template < typename CLASS, typename TYPE1, typename TYPE2 >
void WriteFunctionHelper(CLASS* pOwner, PropInfoType::iterator& it, WriterPtr pw, WriterPtr (Writer::*func)(TYPE1, TYPE2) ) {
MemberProperty<CLASS,TYPE2> *ptr = (MemberProperty<CLASS, TYPE2> *)it->second;
const char *propertName = ptr->m_propertyName.c_str();
if ( !ptr->m_getterFn ) {
throw;
}
pw->*func(propertName,(pOwner->*(ptr->m_getterFn))());
}
I am getting compiler error error C2064: term does not evaluate to a function taking 2 arguments
what is wrong that I am doing
Upvotes: 1
Views: 180
Reputation: 18338
Your func
pointer can be used to trigger a function expecting 2 parameters - first of TYPE1
and second of TYPE2
. You're trying to send propertName
to it, which is of type const char *
. Second parameter also of different type as it's actually a type returned from (pOwner->*(ptr->m_getterFn))()
and not TYPE2
.
Edit: plus see answer from @DenisErmolin
Upvotes: 1
Reputation: 5546
Add bracers around pw->*func
(pw->*func)(propertName,(pOwner->*(ptr->m_getterFn))());
Upvotes: 3