title: c++ Check if string is valid Integer or decimal (both negative and positive cases)
body: <p>How can I check if a string is a valid number?</p>
  
  <pre><code>string n1 = "0.23"; //Valid
  string n2 = "123"; //Valid
  string n3 = "-77"; //Valid
  string n4 = "-0.73"; //Valid
  string n5 = "345.567"; //Valid
  string e6 = "+67"; //Invalid
  string e7 = "a34"; //Invalid
  string e8 = ".56"; //Invalid
  string e9 = "15."; //Invalid
  string e10 = "15-16"; //Invalid
  string e11 = ".7-53"; //Invalid
  </code></pre>
  
  <p>I've tried this function:</p>
  
  <pre><code>bool is_digits(const std::string &amp;str){
      return str.find_first_not_of("0123456789.-") == std::string::npos;
  }
  </code></pre>
  
  <p>But obviously it will return <code>true</code> even if i pass as parameter the two last examples which are invalid.</p>
  
  <pre><code>string e8 = ".56"; //Invalid
  string e9 = "15." //Invalid
  </code></pre>