Merge pull request #42 from Yuri12358/master

Fixed some &&-qualified methods for optional<MoveOnly> case
This commit is contained in:
Sy Brand
2023-02-24 09:16:04 +00:00
committed by GitHub

View File

@ -742,8 +742,7 @@ public:
static_assert(detail::is_optional<result>::value,
"F must return an optional");
return has_value() ? detail::invoke(std::forward<F>(f), **this)
: result(nullopt);
return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
}
template <class F>
@ -1323,7 +1322,7 @@ public:
static_assert(std::is_move_constructible<T>::value &&
std::is_convertible<U &&, T>::value,
"T must be move constructible and convertible from U");
return has_value() ? **this : static_cast<T>(std::forward<U>(u));
return has_value() ? std::move(**this) : static_cast<T>(std::forward<U>(u));
}
/// Destroys the stored value if one exists, making the optional empty
@ -1646,7 +1645,7 @@ public:
static_assert(detail::is_optional<result>::value,
"F must return an optional");
return has_value() ? detail::invoke(std::forward<F>(f), **this)
return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this))
: result(nullopt);
}
#endif