list<CComBSTR> error.

I

ishekar

Hi all,

Dont hit me for asking this in this forum but i feel this question is
related to allocators hence i think its the right place.
I was trying to use the list of CComBSTR but was getting this error. can
anyone tell me why, is there a workaround

list<CComBSTR> lstStr;
lstStr.push_back(CComBSTR(L"test"));

e:\program files\microsoft visual studio\vc98\include\list(222) : error
C2664: 'construct' : cannot convert parameter 1 from 'unsigned short ** ' to
'class ATL::CComBSTR *'
Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
e:\program files\microsoft visual studio\vc98\include\list(218) :
while compiling class-template member function 'class std::list<class
ATL::CComBSTR,class std::allocator<class ATL::CComBSTR> >::iterator
__thiscall std::list<class ATL::CComB
::iterator,const class ATL::CComBSTR &)'
Error executing cl.exe.

The above error is found in the line
allocator.construct(&_Acc::_Value(_S), _X);

TFH
ISR
 
J

John Harrison

ishekar said:
Hi all,

Dont hit me for asking this in this forum but i feel this question is
related to allocators hence i think its the right place.
I was trying to use the list of CComBSTR but was getting this error. can
anyone tell me why, is there a workaround

list<CComBSTR> lstStr;
lstStr.push_back(CComBSTR(L"test"));

CComBSTR is not suitable for the STL because it stupidly overloads the &
operator.

In ATL 3 there is a wrapper class that makes CComBSTR STL compatible. I
forget what its called, or whether it is even available to you using VC++ 6.
Check in an ATL/COM group.

john
 
I

ishekar

I got the answer. CComBSTR does not support the & operator hence the ATL
class CAdapt which does this can be used.
typedef list< CAdapt<CComBSTR> > lstString;

Thanks
ISR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top