title: Removing an element from a Vector while preserving order - need a better approach
body: <p>I am trying to remove an element from a Vector in C++. In the code below, I am removing an element that is greater than 10 from a list of numbers in Vector. I am using a nested loop to do the deletion. Is there a better or simpler method to do the same.</p>
  
  <pre><code>// removing an element from vector preserving order
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  int main() {
      vector&lt;int&gt; v {3,2,9,82,2,5,4,3,4,6};
      for (int i=0; i &lt; v.size(); i++) {
          if (v[i] &gt; 10) { // remove element &gt; 10
              while (i &lt; v.size()) {
                  v[i] = v[i+1];
                  i ++;
              }
          }
      }
      v.pop_back();
      for (int i=0; i &lt; v.size(); i++) {
          cout &lt;&lt; v[i] &lt;&lt; "|";
      }
      return 0;
  }
  </code></pre>