title: stoi causes out of range error
body: <p>I have this code which gives me the error <code>terminating with uncaught exception of type std::out_of_range: stoi: out of range</code></p>
  
  <p>which I have identified as being caused by the line <code>long ascii = std::stoi(temp_string);</code></p>
  
  <p>what about the way i'm using <code>stoi</code> is causing that and how can I fix it?</p>
  
  <pre><code>std::string encode(std::string message){
  std::string num_value;
  long cipher;
  if(message.length() &lt; 20){
    for(int i = 0; i &lt; message.length(); ++i){
      int temp = (char) message.at(i); 
      num_value += std::to_string(temp); 
    }
    return num_value;
  }
  else{
      int count = 0;   
      std::string temp_string;
      for(int i = 0; i &lt; message.length(); ++i){
        int temp = (int)  message.at(i);
        temp_string += std::to_string(temp);           
        count++;   
         if(count == 20){
           count = 0;
           //add cipher encrypt
           long ascii = std::stoi(temp_string);
           //cipher = pow(ascii, 10000);
           //add n to cipther encrypt
           //add cipherencrypt + n to num_value
           //reset temp_string
           temp_string += "n";
  
           temp_string = ""; 
  
        }
   }
  return num_value;
  }
  
  int main(){
    std::string s = "Hello World my t's your name aaaaaaaaaaaaa?";
    std::cout&lt;&lt;"encoded value : "&lt;&lt; encode(s)&lt;&lt;std::endl;
  }
  </code></pre>