Аннулирование итератора в boost :: unordered_map

я используюboost::unordered_map следующее

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;

Сейчас я делаю некоторые изменения в списке типовPtrList в петле

for(auto it = instrMap.begin(); it != instrMap.end(); ++it)
{
     auto key = it->first();
     auto list& = it->second();    
     //Make some change to an element in list 

      if(list.empty())
      {
            instMap.erase(key); 
      }



}

Does making changes to the list invalidate the iterator to instrMap?

Erasing the element will invalidate the iterator pointing to the erased element. How do I modify my code so that the this does not cause any problem? Does using it++ instead of ++it help?

Спасибо

Ответы на вопрос(1)

Ваш ответ на вопрос