lundi 13 janvier 2020

capacity of vector is 0 when i am inserting it into an un-ordered map

I have reserved a vector with size 40 but when i am inserted it into an unordered map as a pair then vector capacity becomes 0.Why is it so?

#include<vector> 
#include <iostream>
#include <unordered_map>
using namespace std;

int main() {
   std::vector<int> a;
   a.reserve(40);
   std::cout<<a.capacity()<<std::endl;

   std::unordered_map<int,vector<int>> _map;
   _map.insert(std::make_pair(1,a));
   std::cout<<_map[1].capacity()<<std::endl;



    return 0;
}

Aucun commentaire:

Enregistrer un commentaire