Input of "3 \n" gets you a nice "Not an integer" message which is rather counter-intuitive for formatted input. cin.peek() seems like it would be more flexible than the ignore.
stringstream conversions cover these by return a boolean on conversion. However, they're relatively slow apparently. You could look into lexical_cast (which might be a bit faster) or coerce_cast (which is based on Boost.Spirit) or the C API functions like strtol for alternatives.
AFAIK the lexical_cast uses stream conversions to do its job.
This is one of the number one questions people ask. If you want to ensure that the user inputs ONLY an <int>, ignoring leading and trailing whitespace, the proper way to do it is demonstrated here:
Duoas, I'm aware of how lexical_cast works but I've been told multiple times it's been "optimized" whatever that means. That's why I put a footnote that it "might" be faster. coerce_cast uses the exact same convention as lexical_cast and I've seen some pretty awesome benchmarks.