title: How can I detect the last iteration in a loop over std::map?
body: <p>I'm trying to figure out the best way to determine whether I'm in the last iteration of a loop over a map in order to do something like the following:</p>
  
  <pre><code>for (iter = someMap.begin(); iter != someMap.end(); ++iter) {
      bool last_iteration;
      // do something for all iterations
      if (!last_iteration) {
          // do something for all but the last iteration
      }
  }
  </code></pre>
  
  <p>There seem to be several ways of doing this: random access iterators, the <code>distance</code> function, etc. What's the canonical method?</p>
  
  <p>Edit: no random access iterators for maps!</p>