vector freeing issue compared to array
<p>I am storing dynamically allocated class pointers in a vector like below.</p>

<pre><code>     vector&lt;Test *&gt; v;
    Test *t1 = new Test;
    Test *t2 = new Test;
    v.push_back(t1);
    v.push_back(t2);
</code></pre>

<p>Now, if i have to free Test objects, i have to loop through entire vector and free one by one and then do a clear.</p>

<pre><code>for(int i = 0; i&lt;v.size(); i++)
     {
         delete v[i];
     }
     v.clear();
</code></pre>

<p>Is there any function in vector to free all internal objects. That function should call Test class destructor for each object.
I understand that it is difficult for Vector class whether the pointer is address of a local object or dynamically allocated.
But still, whenever developer is confident that all are dynamically allocated he could have used freeing function if provided.</p>

<p>Although vector is treated as advanced Array, freeing objects in an array is much easier like below.</p>

<pre><code>Test  *a = new Test[2];
delete []a;
</code></pre>

<p>Is there any function in vector to free all internal objects ? or vector developers thought its not useful to provide such function ? or it is missed requirement for Vector?</p>
