Depends on the types and how you call it. std::vector<int> v(1000000);
has to zero a million ints, whereas new int[1000000];
doesn't, so I would expect a difference in speed. This is one place in std::vector
where you might pay through the nose for something you don't use, if for some reason you don't care about the initial values of the elements.
If you compare std::vector<int> v(1000000);
with new int[1000000]();
then I doubt you'll see much difference. The significant question is whether one of them somehow has a more optimized loop setting the zeros, than the other one does. If so, then the implementation of the other one has missed a trick (or more specifically the optimizer has).