Well, the first bug is at<p><pre><code>    for ( auto i = results.begin( ); i &lt; results.end( ); ++i )
</code></pre>
which should be<p><pre><code>    for ( auto i = results.begin( ); i != results.end( ); ++i )
</code></pre>
This will work on all the standard collection types. If &quot;results&quot; is some non-ordered type, such as a list, the first form won&#x27;t work.<p>The reason for &quot;auto&quot; is that writing the type expression for an iterator is bulky, and quite messy in some situations involving generics. There were some situations where you needed &quot;decltype&quot;. That was just too obscure.<p>Newer languages offer auto-type implicit type declaration by default.  Both Go and Rust do this. It makes programs easier to write, but harder to read.<p>When this idea was first being kicked around on the C++ standards newsgroup, I proposed that the keyword &quot;let&quot; should be used.  But adding a new keyword might break existing code, so &quot;auto&quot;, which wasn&#x27;t used much, was repurposed.