Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which constructor of std::vector is used in this case

Tags:

This looks simple but I am confused: The way I create a vector of hundred, say, ints is

std::vector<int>  *pVect = new std::vector<int>(100);

However, looking at std::vector's documentation I see that its constructor is of the form

explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );

So, how does the previous one work? Does new call the constructor with an initialization value obtained from the default constructor? If that is the case, would

std::vector<int, my_allocator> *pVect = new std::vector<int>(100, my_allocator);

where I pass my own allocator, also work?