Re: ATL and STL, headache #88: maps of structs containing CComPtr
I don't think it would when embedded in a struct with no
copy constructor and assignment operator redefined. These
need to be added since the defaults do shallow copies thus
leading to double destruction.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:ODy789ofGHA.5092@TK2MSFTNGP04.phx.gbl...
Jason S <jmsachs@gmail.com> wrote:
I am using a map<> to lookup interface pointers:
struct dsrc_entry {
CComPtr<Idatasource> pdsrc;
DWORD cookie;
dsrc_entry(Idatasource *pdsrc_in, DWORD cookie_in) : pdsrc(pdsrc_in),
cookie(cookie_in)
};
typedef map<CComBSTR, dsrc_entry> Idatasourcemap;
Idatasourcemap dsrc_map;
I am a bit unsure of the proper way to get this change to work. I'm
basically worried about what happens when the dsrc_entry structure
gets copied (when stuff gets inserted into the map, possibly also on
lookup but I think the copying only happens on insertion). Will the
CComPtr<> do the right thing?
Yes, CComPtr will do the right thing.
--
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