Return a reference on a string using an iterator <p>I have a vector containing strings, an iterator (<code>_it</code>) on this vector, and I would like to return a reference on one of the string using this iterator.</p> <p>For now, the return is made by copy:</p> <pre><code>std::string myClass::next_token() { std::vector&lt;std::string&gt;::const_iterator old_it = _it++; return *old_it; } </code></pre> <p>I would like to do this (note the <code>&amp;</code> on return-type)</p> <pre><code>std::string&amp; myClass::next_token() { //... } </code></pre> <p>But I get the following error :</p> <blockquote> <p>invalid initialization of reference of type <code>‘std::string&amp; {aka std::basic_string&lt;char&gt;&amp;}’</code> from expression of type <code>‘const std::basic_string&lt;char&gt;’ std::string&amp; token = *old_it</code>;</p> </blockquote>