ENH: Add an exception safe state restore class for streams

Programs that modify an input or output stream's format state should
restore that state upon return or before throwing an
exception. Otherwise the state remains in effect in subsequent uses of
the stream. For example, if a program modifies the precision of
std::cout using std::cout.precision(20), then the precision should be
restored to the default state upon return.

This class follows the RAII (Resource Acquisiton Is Initialization)
idiom to restore the state of a stream upon destruction of the class.

A few tests have been modified to use this class. Hopefully this class
and these changes will statisfy the Coverity defect: Not restoring
ostream format.

Change-Id: I5ddbc2207268d45fe2a7550a5e50f4646365ddad
Merge topic 'IosStateSave'

5b5e4b2e ENH: Add an exception safe state restore class for streams