Does "v1.reserve(100)" above actually allocates memory for 100 integers and calls constructor on them? I don't think it is doing, but then I might be wrong.
The reason why I don't think is: When I do v1.size(), it returns 0 and not 100. And if it doesn't, then how does a vector know that it does not have to reallocate itself until 100 elements? Does it store that 100 internally somewhere?
Vectors have a capacity, which is the size of the length array, and a size, which is how many elements are actually being used. This is so that the vector doesn't need to be reallocated every time a new elements is pushed to the back.
reserve() ensures that the new capacity will be at least as large as the parameter. If the current capacity is <= to the new one, the call does nothing, obviously.
Constructors are not called.