Reputation: 97
I am trying to create a simple wrapper function for std::bind, which will take a member function.
template<typename T, typename F>
void myBindFunction(T &t)
{
std::bind(T::F, t );
}
MyClass a = MyClass();
myBindFunction <MyClass, &MyClass::m_Function>( a );
I'm not sure if what I am trying to achieve it possible?
Upvotes: 1
Views: 106
Reputation: 172924
You can make the 2nd template parameter a non-type template parameter, i.e. a member function pointer.
template<typename T, void(T::*F)()>
void myBindFunction(T &t)
{
std::bind(F, t); // bind the member function pointer with the object t
}
Upvotes: 1