std::ios::clear()only clears error flags if possible. If not, for example, there is no stream buffer (i.e. stream.rdbuf()yield nullptr), then the parameter std::ios_base::badbitremains set. This is the only affect. In particular, it std::ios_base::clear()does not remove characters from the input buffer.
, . ,
stream.ignore();, ( , , std::ios_base::eofbit).stream.ignore(std::numeric_limits<std::streamsize>::max(), '\n');, '\n'.ignore() , stream.peek() , (, isdigit(stream.peek()) false)