我正试图创建一个带有COM智能指针的CList(为其生成的包装类之一)
_com_ptr_t
)作为模板参数:
CList<IDispatchPtr, IDispatchPtr> list;
但是,我遇到了几个类似于以下内容的编译错误:
error C2664: 'void __stdcall SerializeElements(class CArchive &,class _com_ptr_t<class _com_IIID<struct IDispatch,&struct __s_GUID _GUID_00020400_0000_0000_c000_00000000004
6> > *,int)' : cannot convert parameter 2 from 'struct IDispatch ** ' to 'class _com_ptr_t<class _com_IIID<struct IDispatch,&struct __s_GUID _GUID_00020400_0000_0000_c000_000000000046> > *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
它在使用常规指针时进行编译:
CList<IDispatch*, IDispatch*> list;
查看调用SerializedElements的MFC代码,问题似乎在于它采用了一个类型*,并且两者之间没有转换
IDispatch** and IDispatchPtr*
. 这有什么办法吗?