status_or support value_or

This commit is contained in:
tqcq 2024-03-13 17:22:41 +08:00
parent 9ed6245cfb
commit a7a0cb052c

View File

@ -113,6 +113,26 @@ public:
return **this; 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 const &status() const & { return status_; }
Status &&status() && { return std::move(status_); } Status &&status() && { return std::move(status_); }