std::vector::clear() in constructor and destructor
I encounter many times with code where std::vector::clear() of class member of type std::vector is called in constructor and destructor.
I don't see why it's required:
- constructor - the class member of type std::vector is empty by default, so no need to call
clear(). - destructor - the class member of type
std::vectorwill be destroyed as part of standard destruction of object containing it. As part of vector destruction all value objects contained in it will be destroyed (if it heap allocated pointers to memory, they should be deleted "manually"), so again no need to callclear().
Do I miss something?