std::feholdexcept(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

std::feholdexcept - std::feholdexcept. Yes bestie, the NAME section is literally the function name twice, and honestly? The confidence is iconic. This page is from the C++ Standard Libary manual (that spelling is in the page header and we are keeping it, no notes πŸ’…).


🌸 Synopsis 🌸

Defined in header <cfenv>.

int feholdexcept( std::fenv_t* envp )  (since C++11)

Marked (since C++11), so this is very much a C++11-and-later baddie.

Here’s the whole glow-up sequence, step by step:

  1. First it saves the current floating-point environment into the object pointed to by envp β€” similar to std::fegetenv.
  2. Then it clears all floating-point status flags.
  3. Then it installs the non-stop mode: future floating-point exceptions will not interrupt execution (will not trap), until the floating-point environment is restored by std::feupdateenv or std::fesetenv.

Think of it as a little subroutine cloak: this function may be used at the beginning of a subroutine that must hide the floating-point exceptions it may raise from the caller. So the caller doesn’t get jump-scared by floating-point drama πŸ™ˆ.

And if only some exceptions must be suppressed while others must be reported, the non-stop mode is usually ended with a call to std::feupdateenv after clearing the unwanted exceptions. Periodt.


πŸŽ€ Parameters πŸŽ€

  • envp β€” pointer to the object of type std::fenv_t where the floating-point environment will be stored. That’s the little storage spot, bestie 🫢.

✨ Return value ✨

0 on success, non-zero otherwise. That’s it. That’s the vibe check.


πŸ¦‹ See also πŸ¦‹

  • feupdateenv β€” restores the floating-point environment and raises the previously raised exceptions (function) (since C++11).
  • fegetenv β€” saves or restores the current floating-point environment (function).
  • fesetenv β€” function, with the (since C++11) tag hanging out with it.
  • FE_DFL_ENV β€” default floating-point environment (macro constant) (since C++11).
  • C documentation for feholdexcept.

Source/version/date check, bestie: this page is from http://cppreference.com, dated 2024.06.10, and it’s std::feholdexcept(3) β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from