C++ 向量分配器错误

aLL*_*Lex -1 c++ g++ c++11

我正在尝试使用 gcc 进行编译

\n\n
#include <string>\n#include <vector>\n\nstd::vector < std::string, std::vector < std::vector < int > > > plain;\n\nint main(){\nreturn 0;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

但出现错误:\n 错误: \xe2\x80\x98class std::vector"<"std::__cxx11::basic_string, std::allocator"<"std::vector"<"int>> > >\xe2 \x80\x99 没有名为 \xe2\x80\x98deallocate\xe2\x80\x99 的成员

\n

krz*_*zaq 6

你的plain就是在std::vector<std::string, NotReallyAnAllocator>哪里。NotReallyAnAllocatorstd::vector < std::vector < int > >

A std::vector(任何东西)都不是分配器,编译器明确抱怨它没有实现必要的分配器接口。

我不确定您想要实现什么,但请研究一下std::unordered_mapstd::map是否需要键值容器。