S
Stuart Carnie
Due to the tightening of the VC++ compiler in 2005, I have run into a
compiler error (from code that previously worked in 2003) using a
CComPtr<ITypeLib> as an element of a std::list, as follows
std::list<CComPtr<ITypeLib> >. I understand the problem, so am looking
for the correct solution to my problem.
On the line that attempts to call push_back, I receive "error C2664:
'std::allocator<_Ty>::construct' : cannot convert parameter 1 from
'ITypeLib **' to 'ATL::CComPtr<T> *' c:\program files\microsoft visual
studio 8\vc\include\list 1163"
e.g.
std::list<CComPtr<ITypeLib> > typeLibs;
CComPtr<ITypeLib> spTypeLib;
... some code the creates an instance of spTypeLib
list.push_back(spTypeLib); // fails here with the C2664 error.
The problem is the push_back function takes a by reference parameter of
type CComPtr<ITypeLib>, however the CComPtr class overrides operator&,
returning a value of type ITypeLib**.
I want to use the CComPtr, for the benefits of the RAII pattern, and it
simplifies my production code significantly in this set of routines.
My question is "What is the correct way to handle this situation, and
avoid the overloaded operator& issue?"
Cheers,
Stuart
compiler error (from code that previously worked in 2003) using a
CComPtr<ITypeLib> as an element of a std::list, as follows
std::list<CComPtr<ITypeLib> >. I understand the problem, so am looking
for the correct solution to my problem.
On the line that attempts to call push_back, I receive "error C2664:
'std::allocator<_Ty>::construct' : cannot convert parameter 1 from
'ITypeLib **' to 'ATL::CComPtr<T> *' c:\program files\microsoft visual
studio 8\vc\include\list 1163"
e.g.
std::list<CComPtr<ITypeLib> > typeLibs;
CComPtr<ITypeLib> spTypeLib;
... some code the creates an instance of spTypeLib
list.push_back(spTypeLib); // fails here with the C2664 error.
The problem is the push_back function takes a by reference parameter of
type CComPtr<ITypeLib>, however the CComPtr class overrides operator&,
returning a value of type ITypeLib**.
I want to use the CComPtr, for the benefits of the RAII pattern, and it
simplifies my production code significantly in this set of routines.
My question is "What is the correct way to handle this situation, and
avoid the overloaded operator& issue?"
Cheers,
Stuart