C ++ Boost io streams, error handling

Is it possible to configure a custom thread, like stanadrd, regarding errors? By default, the good / fail / bad / eof bits are used, and not the exceptions?

The boost docs mention only a std :: failure reset for stream errors and the possibility of another error being propagated (for example, badalloc from attempts to allocate a buffer), however, the raise code does not seem to catch them, instead relying on the user code to process them, but the whole my existing code is based on the good (), bad () and clear () methods when it needs to try again after an error.

+3
source share
1 answer

http://www.trip.net/~bobwb/cppnotes/lec08.htm

, :

void clear (iostate = 0);

, , ios_base:: goodbit.

();

,

(0);

(ios_base:: goodbit);

, ios_base:: goodbit - . clear() → () . :

if (bad_char) is.clear(ios_base:: badbit);// istream badbit

+1

Source: https://habr.com/ru/post/1713039/


All Articles