basic_ios::clear

Clears all error flags.

void clear(iostate state = goodbit, bool reraise = false);

void clear(io_state state);

Parameters

  • state (optional)
    The flags you want to set after clearing all flags. Defaults to goodbit.

  • reraise (optional)
    Specifies whether the exception should be re-raised. Defaults to false (will not re-raise the exception).

Remarks

The flags are goodbit, failbit, eofbit, and badbit. Test for these flags with good, bad, eof, and fail

The member function replaces the stored stream state information with:

state | (rdbuf != 0 ? goodbit : badbit)

If state**&**exceptions is nonzero, it then throws an object of class failure.

Example

See rdstate and getline for examples using clear.

Requirements

Header: <ios>

Namespace: std

See Also

Reference

basic_ios Class

iostream Programming

iostreams Conventions