There is no real difference.
case 1:
std::vector<int> vec(5);
allocates 5 int-elements.
case2:
std::vector<int> vec;
vec.resize(5);
here, we begin with an empty vector of ints.
When you then call resize, the function checks if the size you passed over is smaller than the actual size (wich is 0, in that case). If yes, allocate _Newsize - size() new elements. If no, pop_back (delete) size() - _Newsize elements.
So in the end, resize is slower, because there are more machine cycles (if statements, subtracting sizes...) to do.
if you want to now more, here's the resize function from vector:
void resize(size_type _Newsize)
{ // determine new length, padding as needed
if (_Newsize < size())
_Pop_back_n(size() - _Newsize);
else if (size() < _Newsize)
{ // pad as needed
_Alty _Alval(this->_Getal());
_Reserve(_Newsize - size());
_TRY_BEGIN
_Uninitialized_default_fill_n(this->_Mylast, _Newsize - size(),
_Alval);
_CATCH_ALL
_Tidy();
_RERAISE;
_CATCH_END
this->_Mylast += _Newsize - size();
}
}
as you can see, it does quite a lot.
But in the end, it's just a question about (in most cases not important) micro-seconds...
So no real difference.