diff --git a/source/mijin/container/optional.hpp b/source/mijin/container/optional.hpp index 6d49780..da39933 100644 --- a/source/mijin/container/optional.hpp +++ b/source/mijin/container/optional.hpp @@ -157,17 +157,16 @@ public: [[nodiscard]] constexpr bool empty() const noexcept { return storage_.empty(); } inline void reset() noexcept; - - template - auto then(TCallable&& onSuccess, TErrorCallable&& onError = 0) + template + auto then(this TSelf&& self, TCallable&& onSuccess, TErrorCallable&& onError = 0) { using result_t = std::invoke_result_t>; if constexpr (std::is_same_v) { - if (!empty()) + if (!self.empty()) { - std::invoke(std::forward(onSuccess), get()); + std::invoke(std::forward(onSuccess), self.get()); } else if constexpr (!std::is_same_v) { @@ -176,9 +175,9 @@ public: } else if constexpr (requires(result_t obj) { {obj == NULL_OPTIONAL} -> std::convertible_to; }) { - if (!empty()) + if (!self.empty()) { - return std::invoke(std::forward(onSuccess), get()); + return std::invoke(std::forward(onSuccess), self.get()); } else {