Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::NumericValue Class Reference

Small owning numeric snapshot whose public operations preserve its finite range invariant. No scene, widget, callback or mutable alias is retained. Values between user ticks are valid. More...

#include <numeric.hpp>

Public Member Functions

 NumericValue ()=default
 Construct zero in the default 0..100 range with step one.
double value () const noexcept
NumericRange range () const noexcept
std::expected< NumericValue, NumericError > withValue (double candidate) const
bool operator== (const NumericValue &other) const =default

Static Public Member Functions

static std::expected< NumericValue, NumericError > create (double initial, NumericRange range={})

Detailed Description

Small owning numeric snapshot whose public operations preserve its finite range invariant. No scene, widget, callback or mutable alias is retained. Values between user ticks are valid.

Member Function Documentation

◆ create()

std::expected< NumericValue, NumericError > portals::NumericValue::create ( double initial,
NumericRange range = {} )
static
Parameters
initialExplicit finite value in the inclusive range; never clamped or rounded.
rangeFinite ordered bounds and a positive representable user increment.
Returns
Valid owning value or the first allocation-free numeric validation cause.

◆ operator==()

bool portals::NumericValue::operator== ( const NumericValue & other) const
default
Parameters
otherComplete owning snapshot to compare.
Returns
True when value and range are equal.

◆ range()

NumericRange portals::NumericValue::range ( ) const
inlinenoexcept
Returns
An owning copy of the validated bounds and user increment.

◆ value()

double portals::NumericValue::value ( ) const
inlinenoexcept
Returns
The finite numeric value, with no owner or thread dependency.

◆ withValue()

std::expected< NumericValue, NumericError > portals::NumericValue::withValue ( double candidate) const
Parameters
candidateFinite replacement within these bounds; no snapping is performed.
Returns
New owning value or the original numeric cause; this value never changes.

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