title: out_of_range exception in std:::erase
body: <p>My following program is giving me an <code>out_of_range</code> exception.</p>
  
  <pre><code>bool myProg(char* value, int length, long&amp; num)
  {
      string s;
      char tmp;
      bool retVal = true;
      s.assign((const char*)value, length);
      s.erase(remove(s.begin(),s.end(),' '),s.end());
  
      ...
      // modify s characters 
  
      std::size_t found = s.rfind('F');
      if (found!=std::string::npos)
              s.erase(found,1);
  
      ...
      // work on num variable 
  
      return true;
  }
  </code></pre>
  
  <p>I checked on google all the functions and found that the exception can be thrown only by <code>erase</code> and that too only when position passed in <code>erase</code> function is invalid.</p>
  
  <p>I cannot find  what input string can cause the exception as I ran it on few of my strings and the program works fine in all of my test cases.</p>
  
  <p>Note that the program cannot be modified now &amp; redeployed , to include try catch to capture input variables and check them . So i am stuck with looking at code only . </p>