0

Is there a way to do this initialization of my vector of unordered maps in one line?

vector<unordered_map<int,int>> lookup;
for (int i = 0; i < vector_size; i++)
{
    unordered_map<int, int> map;
    lookup.push_back(map);
}

1 Answers1

0
vector<unordered_map<int, int>> lookup(vector_size);

Syntax - vector<container or data_type> vector_name(size, initial_value)

abhiarrathore
  • 74
  • 1
  • 5