I'm not sure, but I think I've read that you should only delete a vector if it's not empty. So now I always check before I delete a vector:
if (!vector.empty()) {
vector.clear();
}
However, I no longer find anything about whether this step is unnecessary.
Is it forbidden to use clear on an empty vector?
The check is unneeded,
and decrease readability IMO.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With