Help! Error C2664 (cannot convert)
I'm trying to develop a very simple COM collection enumerator using ATL
(Visual Studio 2005 SP1). I want an object named ILibrary to return a
collection of IBook's. But I keep getting the same error in atlcom.h (line
211):
error C2664: '_CopyVariantFromInterface<T>::copy' : cannot convert parameter
2 from 'IBook *const *__w64 ' to 'IBook **'
I don't know if I should be casting or converting anything myself. Below is
the relevant code.
Here's the library class:
typedef vector<IBook*> BOOK_VECTOR;
typedef CComEnumOnSTL<CComIEnum<VARIANT>, &IID_IEnumVARIANT, VARIANT,
_CopyVariantFromInterface<IBook>, PERSON_VECTOR > VarEnum;
class ATL_NO_VTABLE CLibrary:
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CLibrary, &CLSID_Employer>, public
ICollectionOnSTLImpl<IDispatchImpl<ILibrary, &IID_ILibrary, &LIBID_TestLib>,
BOOK_VECTOR, VARIANT, _CopyVariantFromInterface<IBook>, VarEnum>
Here's the copy policy class:
template < class T >
class _CopyVariantFromInterface
{
public:
static HRESULT copy(VARIANT* pV, T** pIP)
{
HRESULT hr = (*pIP)->QueryInterface(IID_IDispatch, (void**)&pV->pdispVal);
if(SUCCEEDED(hr) )
pV->vt = VT_DISPATCH;
else
{
(*pIP)->AddRef();
pV->vt = VT_UNKNOWN;
pV->punkVal = (*pIP);
}
return S_OK;
}
static void init(VARIANT* p) { VariantInit(p); }
static void destroy(VARIANT* p) { VariantClear(p); }
};
Please help!
Thanks.