Skip to content

debug.h ~ debug ~ reset

Baptiste Thémine edited this page Jul 5, 2020 · 5 revisions
std::ios& reset(std::ios &ios) noexcept;

Description

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.

Parameters

  • ios --> reference to an iostream object.

Return value

Returns a reference to ios passed in argument.

Exceptions

Never throws exception. If debug::save has never been called, behaviour is undefined.

Examples

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;
    }
};

See also

Clone this wiki locally