Actually, I dont know, or fully understand, the details either.Can someone explain with more details, please?
I've been digging up the C++ standard, and so far have found:
From basic_istream (188.8.131.52):
Effects: Behaves as an unformatted input function (as described in 184.108.40.206, paragraph 1), except that it
does not count the number of characters extracted and does not affect the value returned by subsequent
calls to gcount(). After constructing a sentry object, if rdbuf() is a null pointer, returns -1 . Otherwise,
calls rdbuf()->pubsync() and, if that function returns -1 calls setstate(badbit)
(which may throw ios_base::failure (220.127.116.11), and returns -1. Otherwise, returns zero.
From basic_streambuf (18.104.22.168.2):
From basic_streambuf (22.214.171.124.2):
Effects: Synchronizes the controlled sequences with the arrays. That is, if pbase() is non-null the characters
between pbase() and pptr() are written to the controlled sequence. The pointers may then
be reset as appropriate.
Returns: -1 on failure. What constitutes failure is determined by each derived class (126.96.36.199).
Default behavior: Returns zero.
From basic_streambuf (188.8.131.52.2):
char_type* pbase() const;
Returns: The beginning pointer for the output sequence.
char_type* pptr() const;
Returns: The next pointer for the output sequence.
Somehow cin.sync() effectively seems to flush the input buffer, from what I see.