0

I a class with a member variable, which is

multiset < pair<TrainType, map<string, set<tm>>>> m_oTrainGraphic;

TrainType is enum. I am inserting some elements in the m_oTrainGraphic container.I have a method, which takes a parameter of type tm, and the thing i wan't to do is to delete those elements which have element of type tm which is equal to the parameter of the method.Here is the method.

bool DeleteTrain(const tm& time)const
    {
        for (auto it = m_oTrainGraphic.begin(); it != m_oTrainGraphic.end(); ++it)
        {

            for (auto iter = it->second.begin(); iter != it->second.end(); ++iter)
            {
                for (auto i = iter->second.begin(); i != iter->second.end(); ++i)
                {
                    if (i->tm_hour == time.tm_hour
                        && i->tm_min == time.tm_min)
                    {
                        m_oTrainGraphic.erase(it);
                    }
                }

            }
        }
    }

The problem is that i get error when trying to erase it.Thanks in advice !

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
K.Krunk
  • 85
  • 1
  • 9
  • So when you've erased `it` ... and you do `iter != it->second.end()` or even `i != iter->second.end()` (less obvious; but still applicable) what do you think will happen, and on what object? – UKMonkey May 02 '18 at 16:11
  • @UKMonkey ok so what are you`r suggestions? How could i delete element if it has equal tm var with the one the method provides ? – K.Krunk May 02 '18 at 16:19

0 Answers0