Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/164.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 编译器不';t整理工艺_C++_Multimap - Fatal编程技术网

C++ 编译器不';t整理工艺

C++ 编译器不';t整理工艺,c++,multimap,C++,Multimap,我有一个多重映射,它的键很短,值是另一个多重映射 std::multimap<short,std::multimap<short,short>> multimap std::multimap multimap 现在我想做` std::multimap<short,short> &a=multimap.find(0)->second; std::pair<short,short> z={1,2}; a.insert(z); std

我有一个多重映射,它的键很短,值是另一个多重映射

std::multimap<short,std::multimap<short,short>> multimap
std::multimap multimap
现在我想做`

std::multimap<short,short> &a=multimap.find(0)->second;
std::pair<short,short> z={1,2};
a.insert(z);
std::multimap&a=multimap.find(0)->秒;
std::对z={1,2};
a、 插入(z);
它编译得很好。但是当我运行它的时候,它只是停止并且没有完成这个过程,它甚至没有抛出任何runtimeerror。你有什么想法吗?谢谢你的建议。

std::multimap<short,std::multimap<short,short>> multimap
...
std::multimap<short,short> &a=multimap.find(0)->second;
std::pair<short,short> z={1,2};
a.insert(z);


除此之外,您的标题“编译器未完成进程”不是很清楚,执行不是您期望的,但是编译器不会运行进程。如果
multimap
没有键为
0
的项,则
multimap.find(0)
返回一个不可取消引用的迭代器。在取消引用迭代器之前,请始终检查此类调用的返回值

auto iter = multimap.find(0);
if ( iter != multimap.end() )
{
   std::multimap<short,short> &a = iter->second;
   std::pair<short,short> z={1,2};
   a.insert(z);
}
else
{
   // Decide what to do
}
auto-iter=multimap.find(0);
if(iter!=multimap.end())
{
std::multimap&a=iter->second;
std::对z={1,2};
a、 插入(z);
}
其他的
{
//决定做什么
}

在调试器下或通过Valgrindw运行。如果您不给我们提供帮助,我们将无法再现您的错误并帮助您。您希望在调试器中获得什么参考?在您的案例中,
find
返回
end
吗?它与您问题的标题相矛盾。请注意,编译器完成代码编译后,其作业将100%完成。您的标题可能应该进行调整,以注意程序的执行意外终止或类似终止。
auto iter = multimap.find(0);
if ( iter != multimap.end() )
{
   std::multimap<short,short> &a = iter->second;
   std::pair<short,short> z={1,2};
   a.insert(z);
}
else
{
   // Decide what to do
}