#include <fpenvironment.h>
Guard type that safely disables floating point traps for the scope in which it is placed.
Example:
You can also keep some traps enabled. E.g. FE_DIVBYZERO is a candidate you might want to keep enabled, whereas FE_UNDERFLOW and FE_OVERFLOW are the ones that you really need to get rid of:
Definition at line 79 of file fpenvironment.h.
Public Member Functions | |
DisableFloatTraps (int mask=0) | |
Constructs the guard object. More... | |
~DisableFloatTraps () | |
When the guard goes out of scope the floating point environment is restored. More... | |
Private Member Functions | |
void | reenable_traps (int mask) |
Reenables the given traps. More... | |
Private Attributes | |
std::fenv_t | environment_ |
The stored environment that the destructor will restore. More... | |
|
inlineexplicit |
Constructs the guard object.
mask | A bitwise of the traps you want to keep enabled. |
Definition at line 87 of file fpenvironment.h.
|
inline |
When the guard goes out of scope the floating point environment is restored.
Definition at line 98 of file fpenvironment.h.
|
private |
Reenables the given traps.
mask | A bitwise of the traps you want to keep enabled. |
Definition at line 63 of file fpenvironment.cc.
|
private |
The stored environment that the destructor will restore.
Definition at line 108 of file fpenvironment.h.