Maybe enhancements

master
Daniel Kolesa 2016-09-02 18:15:46 +01:00
parent cd748bd44a
commit 0dc4d5074d
1 changed files with 22 additions and 6 deletions

View File

@ -221,28 +221,44 @@ public:
return address_of(this->p_value); return address_of(this->p_value);
} }
Value *operator->() { constexpr Value *operator->() {
return address_of(this->p_value); return address_of(this->p_value);
} }
constexpr Value const &operator*() const { constexpr Value const &operator*() const & {
return this->p_value; return this->p_value;
} }
Value &operator*() { constexpr Value &operator*() & {
return this->p_value; 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 explicit operator bool() const { return this->p_engaged; }
constexpr Value const &value() const { constexpr Value const &value() const & {
return this->p_value; return this->p_value;
} }
Value &value() { constexpr Value &value() & {
return this->p_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<typename U> template<typename U>
constexpr Value value_or(U &&v) const & { constexpr Value value_or(U &&v) const & {
static_assert( static_assert(
@ -257,7 +273,7 @@ public:
} }
template<typename U> template<typename U>
Value value_or(U &&v) && { constexpr Value value_or(U &&v) && {
static_assert( static_assert(
IsMoveConstructible<Value>, IsMoveConstructible<Value>,
"Maybe<T>::value_or: T must be copy constructible" "Maybe<T>::value_or: T must be copy constructible"