diff --git a/include/tl/optional.hpp b/include/tl/optional.hpp index 37b774a..5308231 100644 --- a/include/tl/optional.hpp +++ b/include/tl/optional.hpp @@ -742,8 +742,7 @@ public: static_assert(detail::is_optional::value, "F must return an optional"); - return has_value() ? detail::invoke(std::forward(f), **this) - : result(nullopt); + return has_value() ? detail::invoke(std::forward(f), **this) : result(nullopt); } template @@ -1323,7 +1322,7 @@ public: static_assert(std::is_move_constructible::value && std::is_convertible::value, "T must be move constructible and convertible from U"); - return has_value() ? **this : static_cast(std::forward(u)); + return has_value() ? std::move(**this) : static_cast(std::forward(u)); } /// Destroys the stored value if one exists, making the optional empty @@ -1646,7 +1645,7 @@ public: static_assert(detail::is_optional::value, "F must return an optional"); - return has_value() ? detail::invoke(std::forward(f), **this) + return has_value() ? detail::invoke(std::forward(f), std::move(**this)) : result(nullopt); } #endif