Re: Can i use CComPtr in CSimplemap?
I use it like this way:
CComPtr<IDispatch> disp;
...
CSimpleMap<CComPtr<IDispatch>,WTL::CString> m;
m.Add(disp,L"...");
CSimpleMap.Add didn't zero the memeory it realloc'd:
BOOL Add(TKey key, TVal val)
{
TKey* pKey;
pKey = (TKey*)realloc(m_aKey, (m_nSize + 1) * sizeof(TKey));
if(pKey == NULL)
return FALSE;
...
and here, CSimpleMap use the newer alloc'd object's address:
void SetAtIndex(int nIndex, TKey& key, TVal& val)
{
ATLASSERT(nIndex >= 0 && nIndex < m_nSize);
new(&m_aKey[nIndex]) Wrapper<TKey>(key);
but CComPtr cannot use it's address if it's member 'p' isn't null
//The assert on operator& usually indicates a bug. If this is really
//what is needed, however, take the address of the p member explicitly.
T** operator&()
{
ATLASSERT(p==NULL);
return &p;
}
So, i have to use plain pointer instead of smart pointer with CSimpleMap.
Could you give me some ideas?
"Igor Tandetnik" <itandetnik@mvps.org> ????????
news:O#OtBPrXJHA.868@TK2MSFTNGP06.phx.gbl...
"wtller" <wtller@yahoo.com> wrote in message
news:09B7ADE7-D4E7-41A4-975B-D178162FADC8@microsoft.com
like this: CSimpleMap<CComPtr<IUnknown>,int>
Yes, this should work. Have you tried it and encountered problems?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925