我有会员职能:
void ClassA::Method(ClassB& inputarg);我想要增强::功能:
boost::function< void (ClassB&) >
FunctionPointer(
boost::bind((&ClassA::Method, _1, _2)(ClassC->ClassA_User, boost::ref(SomeStructure.ClassB_User)));但它没有编译,我做错了什么?
error C2064: term不计算带有两个参数的函数C2780:'boost::_bi::bind_t<_bi::dm_result::type,boost::_mfi::dm,_bi::list_av_1::type> boost::bind(M T::*,“:期望两个参数--1提供了c:\git\3rdparty\common\include\boost\bind\bind.hpp(1728):参见”boost::bind“错误C2780:'boost::_bi::bind_t,_bi::list_av_9::type> boost::bind(boost::type,R (__thiscall T::* )(B1,B2,B3,B4,B5,B6,B7,B8) const,A1,A2,A3,A2,,,c:\git\3rdparty\common\include\boost\bind\bind_mf2_cc.hpp(223):A7,A8,A9):期望11个参数-1提供7> 7>:参见'boost::bind‘的声明
还有更多类似于最后一行输出。
发布于 2015-02-03 10:57:26
如果您想要创建boost::function<void(B&)>,那么使用
FunctionPointer(boost::bind(&ClassA::Method, ClassC->ClassA_User, _1));像FunctionPointer(SomeStructure.ClassB_User);一样叫它
如果您想传递已知的B实例,那么FunctionPointer的类型应该是
boost::function<void()>绑定应该是这样的
boost::bind(&ClassA::Method, ClassC->ClassA_User,
boost::ref(SomeStructure.ClassB_User)));然后像FunctionPointer()一样叫它;
https://stackoverflow.com/questions/28297137
复制相似问题