Defined in header <cparse/Cursor.hh>

stream_type::char_type peek();

Returns the next character from the stream without consuming it. Neither the line nor the column counter is updated — peeks do not advance position.

Parameters

None.

Return value

The next character in the stream. No sentinel on end-of-input — a throw occurs instead.

Exceptions

  • Throws std::runtime_error with the message [Cursor::peek] invalid stream if the internal stream pointer is null.
  • Throws std::ios_base::failure if the stream signals failbit, eofbit or badbit, per the exception mask set by the constructors.

Notes

Use safePeek() inside condition expressions (while, if) so a peek at the end of input does not throw out of the condition.

See also