title: How to delete smart pointer to dynamically allocated object?
body: <p>I made an iterator which when dereferenced returns a copy of <code>std::shared_ptr</code> that points to a dynamically allocated <code>std::pair</code> (created with <code>new</code> in the internals of the iterator). The iterator functions as is, but want to free the <code>pair</code> at the end of the loop to prevent memory leaks.</p>
  
  <pre><code>for (auto it = parser.begin(); it != parser.end(); ++it) {
      shared_ptr&lt;pair&lt;string, string&gt;&gt; record = *it;
      // Analysis of pair
      // delete pair with delete, or reset
  }
  </code></pre>
  
  <p>However, I am having trouble freeing the <code>pair</code>. I have tried <code>delete record</code>, <code>delete *record</code>, and <code>record.reset()</code>, but none of these will compile.</p>