diff --git a/ostd/maybe.hh b/ostd/maybe.hh index ad8f464..a7b7ff3 100644 --- a/ostd/maybe.hh +++ b/ostd/maybe.hh @@ -221,28 +221,44 @@ public: return address_of(this->p_value); } - Value *operator->() { + constexpr Value *operator->() { return address_of(this->p_value); } - constexpr Value const &operator*() const { + constexpr Value const &operator*() const & { return this->p_value; } - Value &operator*() { + constexpr Value &operator*() & { return this->p_value; } + constexpr Value const &&operator*() const && { + return ostd::move(this->p_value); + } + + constexpr Value &&operator*() && { + return ostd::move(this->p_value); + } + constexpr explicit operator bool() const { return this->p_engaged; } - constexpr Value const &value() const { + constexpr Value const &value() const & { return this->p_value; } - Value &value() { + constexpr Value &value() & { return this->p_value; } + constexpr Value const &&value() const && { + return ostd::move(this->p_value); + } + + constexpr Value &&value() && { + return ostd::move(this->p_value); + } + template constexpr Value value_or(U &&v) const & { static_assert( @@ -257,7 +273,7 @@ public: } template - Value value_or(U &&v) && { + constexpr Value value_or(U &&v) && { static_assert( IsMoveConstructible, "Maybe::value_or: T must be copy constructible"