C++ boost::函数错误

C++ boost::函数错误,c++,function,boost,C++,Function,Boost,我有以下几点:(我想把call_back传递到另一个函数,从那里调用它) 我的编译器给了我这个错误: error C2665: 'boost::bind' : none of the 3 overloads can convert parameter 2 from type 'ResolverCommunicator' c:\Program Files\boost\boost_1_44\boost\bind\bind.hpp(1480): could be 'boost::_bi

我有以下几点:(我想把
call_back
传递到另一个函数,从那里调用它)

我的编译器给了我这个错误:

error C2665: 'boost::bind' : none of the 3 overloads can convert parameter 2 from type 'ResolverCommunicator'
        c:\Program Files\boost\boost_1_44\boost\bind\bind.hpp(1480): could be 'boost::_bi::bind_t<R,F,L> boost::bind<std::string(__thiscall ResolverCommunicator::* )(ResolverReply &),ResolverCommunicator,boost::arg<I>>(F,A1,A2)'
        with
        [
            R=boost::_bi::unspecified,
            F=std::string (__thiscall ResolverCommunicator::* )(ResolverReply &),
            L=boost::_bi::list2<boost::_bi::list_av_2<ResolverCommunicator,boost::arg<1>>::B1,boost::_bi::list_av_2<ResolverCommunicator,boost::arg<1>>::B2>,
            I=1,
            A1=ResolverCommunicator,
            A2=boost::arg<1>
        ]
        c:\Program Files\boost\boost_1_44\boost\bind\bind_mf_cc.hpp(43): or       'boost::_bi::bind_t<R,F,L> boost::bind<std::string,ResolverCommunicator,ResolverReply&,ResolverCommunicator,boost::arg<I>>(R (__thiscall ResolverCommunicator::* )(B1),A1,A2)'
        with
        [
            R=std::string,
            F=boost::_mfi::mf1<std::string,ResolverCommunicator,ResolverReply &>,
            L=boost::_bi::list2<boost::_bi::list_av_2<ResolverCommunicator,boost::arg<1>>::B1,boost::_bi::list_av_2<ResolverCommunicator,boost::arg<1>>::B2>,
            I=1,
            B1=ResolverReply &,
            A1=ResolverCommunicator,
            A2=boost::arg<1>
        ]
        c:\Program Files\boost\boost_1_44\boost\bind\bind_mf_cc.hpp(54): or       'boost::_bi::bind_t<R,F,L> boost::bind<std::string,ResolverCommunicator,ResolverReply&,ResolverCommunicator,boost::arg<I>>(R (__thiscall ResolverCommunicator::* )(B1) const,A1,A2)'
        with
        [
            R=std::string,
            F=boost::_mfi::cmf1<std::string,ResolverCommunicator,ResolverReply &>,
            L=boost::_bi::list2<boost::_bi::list_av_2<ResolverCommunicator,boost::arg<1>>::B1,boost::_bi::list_av_2<ResolverCommunicator,boost::arg<1>>::B2>,
            I=1,
            B1=ResolverReply &,
            A1=ResolverCommunicator,
            A2=boost::arg<1>
        ]
        while trying to match the argument list '(std::string (__thiscall
 ResolverCommunicator::* )(ResolverReply &), ResolverCommunicator, boost::arg<I>)'
        with
        [
            I=1
        ]
错误C2665:'boost::bind':3个重载都不能将参数2从类型'ResolverCommunicator'转换
c:\ProgramFiles\boost\boost\u 1\u 44\boost\bind\bind.hpp(1480):可以是“boost::\u bi::bind\u t boost::bind(F,A1,A2)”
具有
[
R=增压::bi::未指定,
F=std::string(uu thiscall ResolverCommunicator::*)(ResolverReply&),
L=boost::_bi::列表2,
I=1,
A1=解析通讯器,
A2=升压::arg
]
c:\ProgramFiles\boost\boost\u 1\u 44\boost\bind\bind\u mf\u cc.hpp(43):或'boost::\u bi::bind\u t boost::bind(R(uu thiscall ResolverCommunicator::*)(B1),A1,A2)'
具有
[
R=std::string,
F=增压:mfi::mf1,
L=boost::_bi::列表2,
I=1,
B1=ResolverReply&,
A1=解析通讯器,
A2=升压::arg
]
c:\ProgramFiles\boost\boost\u 1\u 44\boost\bind\bind\u mf\u cc.hpp(54):或'boost::\u bi::bind\u t boost::bind(R(uu thiscall ResolverCommunicator::*)(B1)const,A1,A2)'
具有
[
R=std::string,
F=增压:mfi::cmf1,
L=boost::_bi::列表2,
I=1,
B1=ResolverReply&,
A1=解析通讯器,
A2=升压::arg
]
在尝试匹配参数列表(std::string(_uthiscall)时
ResolverCommunicator::*)(ResolverReply&),ResolverCommunicator,boost::arg)'
具有
[
I=1
]

有人知道我做错了什么吗?

是否可以构造
ResolverCommunicator
copy(它是否具有可公开访问的复制构造函数)?如果要将
*此
传递到
绑定
,则需要:

boost::function<std::string (ResolverReply& reply)>
    call_back = boost::bind(
        &ResolverCommunicator::reply_call_back, 
        *this, // copy construtibility required here for *this
        boost::_1);
boost::函数
回调=boost::bind(
&ResolverCommunicator::回复\u回拨,
*this,//此处需要*this的副本可构造性
助推:(u 1);
如果没有可用的复制构造,请在
*this
上使用
boost::ref
,或者只使用
this
。请在生命周期内处理实例


编辑:嗯,全局名称空间中的boost占位符是吗?

解析通讯器是否可构造副本(它是否具有可公开访问的副本构造函数)?如果要将
*此
传递到
绑定
,则需要:

boost::function<std::string (ResolverReply& reply)>
    call_back = boost::bind(
        &ResolverCommunicator::reply_call_back, 
        *this, // copy construtibility required here for *this
        boost::_1);
boost::函数
回调=boost::bind(
&ResolverCommunicator::回复\u回拨,
*this,//此处需要*this的副本可构造性
助推:(u 1);
如果没有可用的复制构造,请在
*this
上使用
boost::ref
,或者只使用
this
。请在生命周期内处理实例


编辑:嗯,boost占位符是否在全局命名空间中?

在绑定成员函数时,您不应该传递
this
而不是
*this
吗?我使用g++进行了尝试,它编译时没有出现任何错误。在绑定成员函数时,您不应该传递
this
而不是
*this
吗?我使用g++进行了尝试,结果是正确的编译时没有任何错误。
boost::function<std::string (ResolverReply& reply)>
    call_back = boost::bind(
        &ResolverCommunicator::reply_call_back, 
        *this, // copy construtibility required here for *this
        boost::_1);