If a parameter is given to clear(), the state of the stream is adjusted to be the state given by the
parameter; that is, the flags set in the parameter are set for the stream, and the other flags are cleared.
The only exception is that the badbit is always set if there is no stream buffer, which is the case if
rdbuf() == 0 (see Section 15.12.2, page 820, for details).
The following example checks whether failbit is set and clears it if necessary: