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