Is there any equivalent function of memset for vectors in C++ ?
memset
(Not clear() or erase() method, I want to retain the size of v
clear()
erase()
Another way, I think I saw it first in Meyers book:
// Swaps with a temporary. vec.swap( std::vector(vec.size(), 0) );
Its only drawback is that it makes a copy.