Template Class Susp
Defined in File susp.hpp
Inheritance Relationships
Base Type
public otyca::SuspBase
(Class SuspBase)
Class Documentation
-
template<class T>
class Susp : public otyca::SuspBase Suspended (lazy) evaluation wrapper with memoization and dependency tracking.
- Template Parameters:
T – The type of value being lazily computed.
Public Functions
-
inline Susp(const std::function<void(T&)> &updater)
Constructs a Susp with a custom updater function.
- Parameters:
updater – Function that computes or updates the value.
-
inline T &as_is() const
Returns the memoized value without checking validity.
- Returns:
Reference to the memoized value.
-
inline T const &force_update_and_get() const
Forces update of the memoized value and returns it.
- Returns:
Const reference to the updated value.
-
inline T const &get() const
Returns the value, computing it if not valid.
- Returns:
Const reference to the current or updated value.
-
inline operator T const&() const
Allows implicit conversion to the value type.
- Returns:
Const reference to the value.
-
inline bool valid() const
Checks if the current value is valid (up-to-date).
- Returns:
True if valid, false if invalidated.
-
inline virtual void reset() const override
Invalidates the current value and recursively resets dependents.
-
inline void reset_dependents_if_changed()
Conditionally resets dependents if the updated value differs from the current one.