libMesh
Public Member Functions | Public Attributes | List of all members
libMesh::FPEDisabler Struct Reference

The FPEDisabler class puts Floating-Point Exception (FPE) trapping on hold during its lifetime, restoring the FE environment upon destruction. More...

#include <fpe_disabler.h>

Public Member Functions

 FPEDisabler ()
 
 ~FPEDisabler ()
 

Public Attributes

std::fenv_t old_env
 

Detailed Description

The FPEDisabler class puts Floating-Point Exception (FPE) trapping on hold during its lifetime, restoring the FE environment upon destruction.

This allows code to ignore known/expected FPE sources, e.g. to work around a bug in HDF5 1.14.3 or to test for errors in a more sophisticated way and throw a C++ exception instead.

FE environment changes should not be made during the lifetime of this object, as they will not be preserved when the destructor restores the original environment.

Author
Roy Stogner
Date
2024 Temporarily disables Floating-Point Exception (FPE) trapping

Definition at line 49 of file fpe_disabler.h.

Constructor & Destructor Documentation

◆ FPEDisabler()

libMesh::FPEDisabler::FPEDisabler ( )
inline

Definition at line 51 of file fpe_disabler.h.

References old_env.

52  {
53  std::feholdexcept(&old_env);
54  }
std::fenv_t old_env
Definition: fpe_disabler.h:61

◆ ~FPEDisabler()

libMesh::FPEDisabler::~FPEDisabler ( )
inline

Definition at line 56 of file fpe_disabler.h.

References old_env.

57  {
58  std::fesetenv(&old_env);
59  }
std::fenv_t old_env
Definition: fpe_disabler.h:61

Member Data Documentation

◆ old_env

std::fenv_t libMesh::FPEDisabler::old_env

Definition at line 61 of file fpe_disabler.h.

Referenced by FPEDisabler(), and ~FPEDisabler().


The documentation for this struct was generated from the following file: