Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
dedekind::morphologies::safe_float< F > Class Template Referenceexport

Finite IEEE-754 subset: the finiteness invariant makes the order total, so (unlike raw F) this carrier reflexively compares. More...

Public Member Functions

constexpr safe_float () noexcept=default
 Zero, the finite default.
constexpr safe_float (F x)
 Checked entry: throws std::domain_error on NaN / +/-inf. Explicit, so a raw F never converts silently. The body is one comparison and the throw lives out of line, so the constructor inlines and a constant argument folds (the IR exhibits depend on it).
constexpr F value () const noexcept
 Read the finite representative.

Static Public Member Functions

static constexpr std::optional< safe_float > lift (F x) noexcept
 Kleisli lift \(F \to \mathrm{Maybe}\langle\mathtt{safe\_float}\rangle\): nullopt on the rejected boundary (NaN / +/-inf), else the finite value.

Friends

constexpr auto operator<=> (const safe_float &, const safe_float &) noexcept=default
constexpr bool operator== (const safe_float &, const safe_float &) noexcept=default
constexpr std::partial_ordering operator<=> (const safe_float &a, F b) noexcept
 Compare against a raw F pivot (a 5.0 in a point-free predicate). Partial: a NaN pivot is unordered.
constexpr bool operator== (const safe_float &a, F b) noexcept

Detailed Description

template<std::floating_point F>
class dedekind::morphologies::safe_float< F >

Finite IEEE-754 subset: the finiteness invariant makes the order total, so (unlike raw F) this carrier reflexively compares.

std::floating_point family

witnesses

The representative is private and every constructor checks it: the default is 0, the explicit constructor throws on NaN / +/-inf (so a non-finite literal is a compile error in a constant expression), and lift / try_safe_float are the non-throwing Kleisli entry. The reflexivity certificate below rests on a guarantee, not a convention. This is the enforced form of the #496 safe_float, and the carrier of the machine-real ambient numbers::ℝ_d.

Note
Signed zeros. -0.0 and +0.0 are distinct bit patterns that compare equal, so <= is antisymmetric only up to ==, which the defaulted operator== absorbs (they collapse to one lattice element). A hostile reader will poke here; the collapse is sound.

The documentation for this class was generated from the following file:
  • src/main/modules/dedekind/morphologies/floating_point.cppm