mirror of
https://github.com/TartanLlama/optional.git
synced 2025-06-25 00:51:37 +02:00
Merge pull request #42 from Yuri12358/master
Fixed some &&-qualified methods for optional<MoveOnly> case
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user