From a7a0cb052cb6cb4a9899c1eb3f7fa3ad455b988b Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Wed, 13 Mar 2024 17:22:41 +0800 Subject: [PATCH] status_or support value_or --- include/sled/status_or.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/sled/status_or.h b/include/sled/status_or.h index 455e06d..2fb8d83 100644 --- a/include/sled/status_or.h +++ b/include/sled/status_or.h @@ -113,6 +113,26 @@ public: return **this; } + T &value_or(T &&val) & + { + if (!ok()) return val; + } + + T const &value_or(T &&val) const & + { + if (!ok()) return val; + } + + T &&value_or(T &&val) && + { + if (!ok()) return val; + } + + T const &&value_or(T &&val) const && + { + if (!ok()) return val; + } + Status const &status() const & { return status_; } Status &&status() && { return std::move(status_); }