-1

I'm trying compile with gcc

#include <string>
#include <vector>

std::vector < std::string, std::vector < std::vector < int > > > plain;

int main(){
return 0;
}

But getting a error: error: ‘class std::vector"<"std::__cxx11::basic_string, std::allocator"<"std::vector"<"int> > >’ has no member named ‘deallocate’

aLLex
  • 55
  • 6
  • 2
    Perhaps you wanted to use either `std::map` or `std::unordered_map`??. Please see How to [`mcve`](http://stackoverflow.com/help/mcve) and some highly recommend [C++ texts](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). Additionally, the [**`C++ tag`** wiki](http://stackoverflow.com/tags/c%2b%2b/info) also has some good pointers to get you running. – WhiZTiM Sep 30 '16 at 22:18
  • It's really not that clear how what you 're trying to do in this snippet. As others pointed out already, the second argument to std::vector must be an allocator, not another std::vector class/instance – bergercookie Mar 09 '18 at 19:48

1 Answers1

6

Your plain is std::vector<std::string, NotReallyAnAllocator> where NotReallyAnAllocator is std::vector < std::vector < int > >.

A std::vector (of anything) is not an allocator and the compiler clearly complains about the fact that it doesn't implement the necessary allocator interface.

I'm not sure what you wanted to achieve, but look into std::unordered_map and std::map if you need key-value containers.

krzaq
  • 16,240
  • 4
  • 46
  • 61