I use boost::unordered_map as follows
typedef boost::shared_ptr<WriterExeciter> PtrWriter; typedef std::list<PtrWriter> PtrList; boost::unordered_map<std::pair<unsigned int, unsigned long long>, PtrList> Map Map instrMap;
Now I am making some changes to a list of type PtrList in a loop
for(auto it = instrMap.begin(); it != instrMap.end(); ++it) { auto key = it->first(); auto list& = it->second();
Does making changes to the list invalidate the iterator for instrMap?
Erasing an element will invalidate the iterator that points to the erased element. How can I change the code so that it does not cause any problems? Does it++ instead of ++it help?
thanks
source share