문제

I have the following code declaration of multimap:

typedef std::multimap<std::string,std::string> rd;

std::multimap<std::string, rd> Rdout;
std::multimap<std::string, rd> Rdin;

I use the following to find two map iterators:

std::multimap<std::string,rd>:: iterator ot =
Rdout.find(B.getName().str()+B.getParent()->getName().str());

std::multimap<std::string,rd>:: iterator it = 
Rdin.find(B.getName().str()+B.getParent()->getName().str());

When I try to insert inner map of Rdin into Rdout which are of same type I get segfault

if(!it->second.empty())
{
    ot->second.insert(it->second.begin(), it->second.end());
}

Appreciate your help thanks!!

도움이 되었습니까?

해결책

if(!it->second.empty())
{
    ot->second.insert(it->second.begin(), it->second.end());
}

should be

if(it != Rdin.end())
{
    ot->second.insert(it->second.begin(), it->second.end());
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top