Range Based For Loop
<p>My question is: When I use a range based for loop like in this example, is it releasing the memory on the heap in each 'Object' stored in 'vec'?  I had a thought that this was just copying a pointer, and then trying to release the copied pointer.</p>

<p>I believe 'auto *&amp; obj : vec' is declaring 'obj' a reference to a pointer, and then assigning the address of each object stored in 'vec' to it, which its memory will be released, and set to nullptr. Is this right?</p>

<pre><code>std::vector &lt;Object*&gt; vec;
vec.push_back(new Object{});
vec.push_back(new Object{});
//....

//clean up
for(auto *&amp; obj : vec)
    delete obj, obj = nullptr;
</code></pre>