Original Post
im having some problems with boost bind and function... the problem is in the Bind function: this is what id like... template<class T> void Bind(UINT msg, FunctionType r,T* t) { associations_.insert(AssocMap::value_type(msg, boost::bind(r, t, _1, _2, _3, _4))); } Error 1 error C2064: term does not evaluate to a function taking 4 arguments c:\program\boost\boost_1_34_1\boost\function\function_template.hpp 155 Drone this is what works... template<class T> void Bind(UINT msg, void (T::*r)(UINT, WPARAM, LPARAM, Window*),T* t) { associations_.insert(AssocMap::value_type(msg, boost::bind(r, t, _1, _2, _3, _4))); } why cant i use boost::function in this case?
template <class FunctionType>
class Handler
{
//typedef boost::function<void (UINT , WPARAM , LPARAM , Window*)> FunctionType;
public:
Handler() {}
virtual ~Handler() {}
template<class T>
void Bind(UINT msg, FunctionType r,T* t)
{
associations_.insert(AssocMap::value_type(msg, boost::bind(r, t, _1, _2, _3, _4)));
}
bool Unbind(UINT msg)
{
associations_.erase(msg);
}
void HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, Window* pWindow)
{
BOOST_FOREACH(AssocMap::value_type p, associations_)
{
if((p.first) == uMsg || uMsg == 0)
(p.second)(uMsg, wParam, lParam, pWindow);
}
}
private:
typedef std::map<UINT, FunctionType> AssocMap;
AssocMap associations_;
};