2010-08-12 2 views
0
//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>' 

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(); 
} 
+0

[i-hate-C++] : C++은 그렇게 나쁘지 않습니다. 적어도 자바는 아닙니다. – James

+0

제 제안에서 편집 한 것을 보았습니다. 그러나 나는 틀 렸습니다. 미안합니다. 어쨌든 – Thomas

+0

thx, 아프지 않으므로 그대로 두겠습니다. –

답변

2

도움이 될까요?

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

boost::function<T()>boost::bind에 의해 반환되는 형식에서 변환이 있지만,이 매개 변수는 템플릿 인수에 의존하기 때문에, 컴파일러는 여러분을 대신하여 이러한 변환을하지 않습니다.