title: What's wrong with passing C++ iterator by reference?
body: <p>I've written a few functions with a prototype like this:</p>
  
  <pre><code>template &lt;typename input_iterator&gt;
  int parse_integer(input_iterator &amp;begin, input_iterator end);
  </code></pre>
  
  <p>The idea is that the caller would provide a range of characters, and the function would interpret the characters as an integer value and return it, leaving <code>begin</code> at one past the last-used character.  For example:</p>
  
  <pre><code>std::string sample_text("123 foo bar");
  std::string::const_iterator p(sample_text.begin());
  std::string::const_iterator end(sample_text.end());
  int i = parse_integer(p, end);
  </code></pre>
  
  <p>This would leave <code>i</code> set to 123 and <code>p</code> "pointing" at the space before <code>foo</code>.</p>
  
  <p>I've since been told (without explanation) that it's bad form to pass an iterator by reference.  Is it bad form?  If so, why?</p>