title: Cin read number and check for integer
body: <p>Hy,</p>
  
  <p>I want to read a number in c++ with the cin function. I know there are a lot of threads but I didn't found a perfekt solution.</p>
  
  <p>First I tried it with <strong>cin.fail()</strong> function. But if I input a number like this <strong>12asdf</strong> it reads the <strong>12</strong> correct and didn't throw an error.</p>
  
  <p>Then I tried to read a string and convert it with the <strong>atoi()</strong> function but if I read a string like this <strong>12asdf</strong> I have the same problem. It reads the 12 correct and throws no error.</p>
  
  <p>The I tried it with the function but the all_of function isn't available in visual 2013.</p>
  
  <pre><code>if ( std::all_of(input.begin(), input.end(), std::isdigit) )
  {
       //input is integer
  }
  </code></pre>
  
  <p>How can I check an input like this <strong>12asdf</strong> and throw an error?</p>
  
  <p>Best regards</p>