i cant even pass the compile this time...got this verbos error message
c:\program files\microsoft visual studio 8\vc\include\list(1163) : error C2664: 'std::allocator<_Ty>::construct' : cannot convert parameter 1 from 'BSTR *' to 'ATL::CComBSTR *' 1> with 1> [ 1> _Ty=ATL::CComBSTR 1> ] 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1> c:\program files\microsoft visual studio 8\vc\include\list(1154) : while compiling class template member function 'std::_List_nod<_Ty,_Alloc>::_Node *std::list<_Ty>::_Buynode(std::_List_nod<_Ty,_Alloc>::_Node *,std::_List_nod<_Ty,_Alloc>::_Node *,const _Ty &)' 1> with 1> [ 1> _Ty=ATL::CComBSTR, 1> _Alloc=std::allocator<ATL::CComBSTR> 1> ] 1> c:\documents and settings\david\my documents\visual studio 2005\projects\simstest\simstest\mysqlcmd.h(66) : see reference to class template instantiation 'std::list<_Ty>' being compiled 1> with 1> [ 1> _Ty=ATL::CComBSTR 1> ]
how could i relate list and CAdapt before i learned CAdapt
list is an STL collection, whereas CAdapt is a ATL class. They don't really relate to each other. If you are using ATL, it may be a good idea to use the ATL collections whenever there's one available that does what you want.
I thought those containers were merged in VC2005 Anyhow, CMap and the MFC containers are rubbish. The container you want to use is std::map, which, unlike CMap, is part of the C++ language.
To add to what CG said, if you want a strictly ATL class, there's one called CSimpleMap - I don't know how fully functional it is compared to CMap though.
This means you're trying to pass a BSTR* in to the container somewhere when you need to construct a CCOMBSTR from it first, and pass that in. It won't implicitly convert for you.
[ATL] does ATL has any collection tool lik CMap in MFC?
Eric Vandenberg
i cant even pass the compile this time...got this verbos error message
c:\program files\microsoft visual studio 8\vc\include\list(1163) : error C2664: 'std::allocator<_Ty>::construct' : cannot convert parameter 1 from 'BSTR *' to 'ATL::CComBSTR *'
1> with
1> [
1> _Ty=ATL::CComBSTR
1> ]
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1> c:\program files\microsoft visual studio 8\vc\include\list(1154) : while compiling class template member function 'std::_List_nod<_Ty,_Alloc>::_Node *std::list<_Ty>::_Buynode(std::_List_nod<_Ty,_Alloc>::_Node *,std::_List_nod<_Ty,_Alloc>::_Node *,const _Ty &)'
1> with
1> [
1> _Ty=ATL::CComBSTR,
1> _Alloc=std::allocator<ATL::CComBSTR>
1> ]
1> c:\documents and settings\david\my documents\visual studio 2005\projects\simstest\simstest\mysqlcmd.h(66) : see reference to class template instantiation 'std::list<_Ty>' being compiled
1> with
1> [
1> _Ty=ATL::CComBSTR
1> ]
dont understand what it talking about
mannix
oh, really thx!
this is really complicate!
how could i relate list and CAdapt before i learned CAdapt
MrC150909
list is an STL collection, whereas CAdapt is a ATL class. They don't really relate to each other. If you are using ATL, it may be a good idea to use the ATL collections whenever there's one available that does what you want.
prosimma
here is my test code, tested in win32 console+atl support
#include "stdafx.h"
#include <list>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
CComBSTR myBSTR(L"abc");
list<CComBSTR> mylist;
mylist.push_back( myBSTR );
return 0;
}
STILL GOT THAT ERROR MESSAGE!
please help me!
HakanA
yes, what i really want to use is std:list.
i tried list<PTSTR> and list<CComBSTR>, but it does not work... i dont know why!
having a hard time
bojanplatisa
I thought those containers were merged in VC2005 Anyhow, CMap and the MFC containers are rubbish. The container you want to use is std::map, which, unlike CMap, is part of the C++ language.
http://www.sgi.com/tech/stl/Map.html
Brent VanderMeide - Architect
Jorge Serrano P&#233;rez
oh, strange...
i will try again later, thx!
Dakiar
list<CComBSTR> strings;
CComBSTR bstr(L"test");
strings.push_back(bstr);
Works for me.
David Scrutton
quinlivan
You cannot use CComBSTR with STL collections, because CComBSTR overloads the & operator. You need to use the CAdapt class as follows :
CComBSTR myBSTR(L"abc");
list<CAdapt <CComBSTR> > mylist;
mylist.push_back(myBSTR);
Gu1234
Jonas Samuelsson
This means you're trying to pass a BSTR* in to the container somewhere when you need to construct a CCOMBSTR from it first, and pass that in. It won't implicitly convert for you.
deys
A list and a map are very different containers. What do you mean by 'it doesn't work'