//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();
}
views:
33answers:
1
+2
A:
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.
Thomas
2010-08-12 19:55:52