std::basic_istream<CharT,Traits>::peek (3) - Linux Manuals
std::basic_istream<CharT,Traits>::peek: std::basic_istream<CharT,Traits>::peek
NAME
std::basic_istream<CharT,Traits>::peek - std::basic_istream<CharT,Traits>::peek
Synopsis
int_type peek();
Behaves as UnformattedInputFunction. After constructing and testing the sentry object, reads the next character from the input stream without extracting it.
Parameters
(none)
Return value
If good() == true, returns the next character as obtained by rdbuf()->sgetc()
Otherwise, returns Traits::eof().
Exceptions
failure if an error occurred (the error state flag is not goodbit) and exceptions() is set to throw for that state.
If an internal operation throws an exception, it is caught and badbit is set. If exceptions() is set for badbit, the exception is rethrown.
Example
// Run this code
Output:
See also
sgetc (public member function of std::basic_streambuf<CharT,Traits>)
get (public member function)
unget (public member function)