You probably don't want to know the size of the vector in bytes, because the vector is a non-trivial object that is separate from the content, which is housed in dynamic memory.
std::vector<int> v { 1, 2, 3 }; // v on the stack, v.data() in the heap
What you probably want to know is the size of the data, the number of bytes required to store the current contents of the vector. To do this, you could use
template<typename T>
size_t vectorsizeof(const typename std::vector<T>& vec)
{
return sizeof(T) * vec.size();
}
or you could just do
size_t bytes = sizeof(vec[0]) * vec.size();