Re: STL Map Scoping Issue
On Aug 12, 9:38 am, Frank Birbacher <bloodymir.c...@gmx.net> wrote:
So far I have no idea what is causing the AV.
sfnc...@gmail.com schrieb:
delete shipTypeMap[0];
At least you have undefined behaviour here: deleted pointers are
invalid. invalid pointers may not be read or copied, but only be
assigned to or destructed (when going out of scope). But elements of a
map must be copyable. So you should first remove the pointer from the
map (store it in a local variable) and then delete the object it points t=
o.
That's in theory. In practice, of course, there's no problem on
any real architecture; no implementation of std::map will read
or copy the pointer unless you actually try to access it.
To avoid this hassle try using boost::shared_ptr.
Sounds like added complexity for no gain.
--
James Kanze (GABI Software) email:james.ka...@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34