读书人

关于boost bind的有关问题

发布时间: 2013-04-20 19:43:01 作者: rapoo

关于boost bind的问题

typedef bool EvtCallBack(evt::ZEventPtr);

class CNode {
template<class T>
static void createNode(evt::EventType evtType, T* obj, EvtCallBack (T::* call) );
}

template<class T> inline
void CNode::createNode( evt::EventType evtType, T* obj, EvtCallBack (T::* call) )
{
createNode(evtType, boost::bind(&call, obj, _1)); //这句话编译出错
}

出错如下:
1>E:\3rdParty\include\boost/bind/bind.hpp(69): error C2825: 'F': must be a class or namespace when followed by '::'
1> E:\3rdParty\include\boost/bind/bind_template.hpp(15) : see reference to class template instantiation 'boost::_bi::result_traits<R,F>' being compiled
1> with
1> [
1> R=boost::_bi::unspecified,
1> F=bool (__thiscall CSession::* *)(evt::ZEventPtr)
1> ]
1> e:\project\dev\cmn\CombineNode.h(34) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
1> with
1> [
1> R=boost::_bi::unspecified,
1> F=bool (__thiscall CSession::* *)(evt::ZEventPtr),
1> L=boost::_bi::list2<boost::_bi::value<CSession*>,boost::arg<1>>
1> ]
1> CSession.cpp(13) : see reference to function template instantiation 'void CombineNode::createNode<CSession>(evt::EventType,T *,bool (__thiscall CSession::* )(evt::ZEventPtr))' being compiled
1> with
1> [
1> T=CSession
1> ]
1>E:\3rdParty\include\boost/bind/bind.hpp(69): error C2039: 'result_type' : is not a member of '`global namespace''
1>E:\3rdParty\include\boost/bind/bind.hpp(69): error C2146: syntax error : missing ';' before identifier 'type'
1>E:\3rdParty\include\boost/bind/bind.hpp(69): error C2208: 'boost::_bi::type' : no members defined using this type
1>E:\3rdParty\include\boost/bind/bind.hpp(69): fatal error C1903: unable to recover from previous error(s); stopping compilation



不知道为何出错,请高手指点
[解决办法]


boost::bind(&call, obj, _1) 这里的&call去掉 &

boost::bind(call, obj, _1)

读书人网 >C++

热点推荐