Deallocate all memory in a container of pointers
This assumes that the container holds raw pointer and it owns the pointers. it is a better idea to then let the container hold smart pointers.

These will automatically clear the object they hold when they get destroyed (using delete by default).

typedef std::unique_ptr&lt;Type&gt; Type_ptr;
std::vector&lt;Type_ptr&gt; container;


and use emplace to fill it;

container.emplace_back(std::make_unique&lt;Type&gt;());