仅在使用调试标志编译时"virtual memory exhausted: Cannot allocate memory"



我得到以下代码的错误(error.cpp(:

#include <map>
#include <functional>
#include <vector>
int main()
{
std::map<
int, std::map< std::string,
std::map<std::string, std::map<std::string, std::map<std::string,
std::map<std::string, std::map<std::string, std::map<std::string,
std::map<std::string, std::map<std::string, std::map<std::string,
std::map<std::string, std::map<std::string, std::map<std::string,
std::map<std::string, std::map<std::string, std::map<std::string,
std::map<std::string, std::map<std::string, std::map<std::string,
std::map<std::string, std::string>
> > >
> > >
> > >
> > >
> > >
> > >
> >                                         oups;
}

使用调试标志进行编译时:

g++ error.cpp -g -o error

我的系统是Ubuntu 18.04,g++7.5.0作为虚拟机运行。RAM为5GB,Swap为2.5GB。硬盘空间为1GB。

这正常吗?虫子?限制?

什么是";"更好";上述代码的替代方案?(c++14(

在该定义中有8+7+6个字符串,对吗?所以,我想说,你手头上有一个arity 21的关系。为什么不试试:

constexpr const std::size_t my_arity = 21;
std::unordered_set<std::array<std::string, my_arity>> oups;

相反?

最新更新