lt;&lt; &quot;key:&quot; &lt;&lt; i.key();
  std::cout &lt;&lt; &quot;value:&quot; &lt;&lt; *i;
  i-&gt;foo(); // call T::foo()
}
</pre>
<p>and this now needs to be converted into</p>
<pre class="literal-block">
for( boost::ptr_map&lt;std::string,T&gt;::iterator i = m.begin(), e = m.end();
     i != e; ++i )
{
  std::cout &lt;&lt; &quot;key:&quot; &lt;&lt; i-&gt;first;
  std::cout &lt;&lt; &quot;value:&quot; &lt;&lt; *i-&gt;second;
  i-&gt;second-&gt;foo(); // call T::foo()
}
</pre>
<p>Apart from the above 