Oops it's already solved.  But worth to mention, there is also possibility to: 
either read individual chars from the stream and pushback() if they are digits before using operator >>
 
or peek() the next chars in the stream without reading it to decisde whether to ignore it or to use operator >> 
 
Just be carefull about the '-' which is not a digit but could be the sign of an interger. 
Here a small example :  
int c, n, sign=1; 
ifstream ifs("test.txt", std::ifstream::in);
while (ifs.good() && (c=ifs.peek())!=EOF ) {
    if (isdigit(c)) {
        ifs >> n;
        n *= sign; 
        sign = 1; 
        cout << n << endl; 
    }
    else {
        c=ifs.get();
        if (c == '-')
            sign = -1;
        else sign = 1;
    }
}
ifs.close(); 
It's not the most performant approach, however it has the advantage of only reading from stream, without intermediary strings and memory management.