title: Idiomatic STL: Iterating over a list and inserting elements
body: <p>I'm writing an algorithm that iterates over a list of points, calculates the distance between them and inserts additional points if the distance is too great. However I seem to be lacking the proper familiarity with STL to come up with an elegant solution. I'm hoping that I can learn something, so I'll just show you my code. You might have some hints for me.</p>
  
  <pre><code>for (std::list&lt;PathPoint&gt;::iterator it = ++points_.begin();
       it != points_.end(); it++)
  {
      Vector curPos = it-&gt;getPosition();
      Vector prevPos = (--it)-&gt;getPosition();
      Vector vecFromPrev = curPos - prevPos;
      float distance = vecFromPrev.abs();
      it++;
      if (distance &gt; MAX_DISTANCE_BETWEEN_POINTS)
      {               
          int pointsToInsert = (int)(distance / MAX_DISTANCE_BETWEEN_POINTS);             
          Vector curPos = prevPos;                
          for (int i = 0; i &lt; pointsToInsert; i++)
          {
              curPos += vecFromPrev / pointsToInsert;
              it = points_.insert(it, PathPoint(curPos, false));
              it++;
          }
      }
  }
  </code></pre>