What is the easiest way to tell if an extraction from a stringstream parsed all the stream, or only part of it?

E.g. I want to use this for, say, string -> int conversion. If I have an input, "-123", then it should parse the entire string and return -123. If I have the input "-123abc", it also returns "-123" but I want to make this an error condition (as the input string was not a properly formatted int) rather than silently parsing only half of the input string and returning.

The reason I am using stringstream is firstly as I rarely use it and want the practice, secondly because I can easily make this a function template and be able to extract any kind of data that std::stringstream can work with.