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?
You are doing it all wrong. Just create it as an automatic object if all you need is a vector in the current scope and time
The constructor has default arguments for the second and third parameters. So it is callable with just an int. If you want to pass an own allocator, you have to pass a second argument since you can’t just skip it
A dedicated example might clarify the matter