[英]C++ vector allocator error
我正在嘗試用 gcc 編譯
#include <string>
#include <vector>
std::vector < std::string, std::vector < std::vector < int > > > plain;
int main(){
return 0;
}
但是得到一個錯誤:錯誤:'class std::vector"<"std::__cxx11::basic_string, std::allocator"<"std::vector"<"int> > >' 沒有名為 'deallocate' 的成員
你的plain
是std::vector<std::string, NotReallyAnAllocator>
其中NotReallyAnAllocator
是std::vector < std::vector < int > >
。
std::vector
(of any) 不是分配器,編譯器清楚地抱怨它沒有實現必要的分配器接口。
我不確定您想要實現什么,但是如果您需要鍵值容器,請查看std::unordered_map
和std::map
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.