diff --git a/src/optional.hh b/src/optional.hh index dfa84694..aef1a751 100644 --- a/src/optional.hh +++ b/src/optional.hh @@ -84,6 +84,9 @@ public: template T value_or(U&& fallback) const { return m_valid ? m_value : T{std::forward(fallback)}; } + template + T value_or_compute(U&& compute_func) const { return m_valid ? m_value : compute_func(); } + void reset() { destruct_ifn(); m_valid = false; } private: