-
Notifications
You must be signed in to change notification settings - Fork 0
debug.h ~ debug ~ reset
Baptiste Thémine edited this page Jul 5, 2020
·
5 revisions
std::ios& reset(std::ios &ios) noexcept;
Resets current iostream properties to their previously saved value.
You must call the function debug::save before calling debug::reset
.
The state of ios
is unchanged, all other properties are replaced.
Typical usage of this function is to apply some iostream properties temporarily.
-
ios
--> reference to an iostream object.
Returns a reference to ios
passed in argument.
Never throws exception. If debug::save has never been called, behaviour is undefined.
In the following example, we overload operator<<
and apply specific formatting without affecting the rest of our program.
#include <iostream>
#include <JLC/debug.h>
struct Object {
int data;
friend std::ostream& operator<<(std::ostream &out, const Object &obj){
return out << debug::save << std::hex << std::showbase << std::uppercase << obj.data << debug::reset;
}
};