The internals of stl containers, except std::array
, are stored in heap, separately from the container object itself.
clear
calls the destructor of whatever is stored in the container. If you store plain pointers or references to objects then no, the objects won't be destroyed, because pointers and references themselves don't have destructors. If you store unboxed objects or smart pointers, they will be destroyed.