1#ifndef LIVE_CELLS_MAYBE_HPP
2#define LIVE_CELLS_MAYBE_HPP
9#include "exceptions.hpp"
28 error_ = std::current_exception();
64 return maybe(std::current_exception());
86 return maybe(std::current_exception());
98 return value_.value();
101 std::rethrow_exception(error_);
129 std::optional<T> value_;
134 std::exception_ptr error_;
151 return maybe<
decltype(
f())>::wrap(
f);
154 template <
typename A,
typename B>
155 bool operator==(
const maybe<A> &a,
const maybe<B> &b) {
156 return a.value() == b.value() && a.error() == b.error();
164 return live_cells::internal::hash_combine(0, m.value(), m.error());
A computed cell which determines its argument cells at runtime.
Definition dynamic_compute_cell.hpp:153
Container holding a cell value or an exception that occurred while computing a value.
Definition maybe.hpp:17
maybe()
Create a container holding an uninitialized_cell_error exception.
Definition maybe.hpp:23
std::exception_ptr error() const
Get the exception held in this maybe.
Definition maybe.hpp:121
static maybe< T > wrap(const std::invocable auto &f)
Create a maybe holding the result of calling f.
Definition maybe.hpp:81
maybe(const T &val)
Create a container holding a value.
Definition maybe.hpp:37
maybe(std::exception_ptr error)
Create a container holding an exception that was thrown.
Definition maybe.hpp:45
std::optional< T > value() const
Get the value held in this.
Definition maybe.hpp:112
T unwrap() const
Get the value or throw the exception stored in this container.
Definition maybe.hpp:96
static maybe< T > error(const auto &error)
Create a container holding an exception that was thrown.
Definition maybe.hpp:59
Definition boolean.hpp:26
auto maybe_wrap(const std::invocable auto &f)
Create a maybe holding the result of calling f.
Definition maybe.hpp:150
auto operator==(const T &a, const U &b)
Create a Cell that compares two cells for equality by ==.
Definition equality.hpp:57
Exception indicating that the value of a cell was referenced before its initial value was computed.
Definition exceptions.hpp:43