开发者

boost bind template error

//error C2784: 'HRESULT get_wrapper(T *,boost::function<R(void)>)' : 
//could not deduce template argument for 'boost::function<R(void)>' 
//from 'boost::_bi::bind_t<R,F,L&g开发者_C百科t;'

STDMETHODIMP CAttributeValue::get_Name(BSTR* pVal)
{
    return get_wrapper(pVal, boost::bind<BSTR>(&CAttributeValue::getNameCOM, this)); //error here
}

template <class T> HRESULT get_wrapper(T* pVal, boost::function<T()> GetVal)
{
    if(!pVal)
        return E_POINTER;
    HRESULT status = E_FAIL;
    try {
        *pVal = GetVal();
        status = S_OK;
    } catch (...) {}
    return status;
}

BSTR CAttributeValue::getNameCOM() const
{
    BOOST_STATIC_ASSERT(sizeof(TCHAR)==sizeof(wchar_t));
    return TStr2CComBSTR(_name).Detach();
}


Does it help to do this?

return get_wrapper<BSTR>(pVal, boost::bind(&CAttributeValue::getNameCOM, this));
//                ^^^^^^

There is a conversion from the type returned by boost::bind to boost::function<T()>, but since this parameter depends on a template argument, the compiler won't do any such conversions on your behalf.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜