When I use clear()
on a std::vector
, it is supposed to destroy all the elements in the vector
, but instead it doesn\'t.
Sample
You have no right to get a segmentation fault. For that matter, a segmentation fault isn't even part of C++. Your program is removing all elements from the vector, and you're illegally accessing the container out of bounds. This is undefined behaviour, which means anything can happen. And indeed, something happened.