I am reading TC++PL3 and in 21.3.8 it describes the class sentry, which
is member of basic_istream and basic_ostream.
Q1: Should we always use the sentry class when we define new functions
and operators for basic_ostream/basic_istream (ostream/istream)?
Q2: It is mentioned that we can place code "such as throwing exceptions
caused by state changes" in the sentry's destructor. However in 14.4.7
it is mentioned:
"Exiting from a destructor by throwing an exception is also a violation
of the standard library requirements (E2)".
I suppose both sentry's constructor and destructor, are to be provided
by the implementer of the standard library basic_istream and
basic_ostream classes?