From ea97d3af48312e203d774ef4d8d64bbad02902ae Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Sat, 3 Aug 2024 20:49:31 +0200 Subject: [PATCH] Removed deducing this-version again as the world (clang) isn't ready for it yet. --- source/mijin/container/optional.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/mijin/container/optional.hpp b/source/mijin/container/optional.hpp index da39933..c3bd31d 100644 --- a/source/mijin/container/optional.hpp +++ b/source/mijin/container/optional.hpp @@ -157,8 +157,21 @@ public: [[nodiscard]] constexpr bool empty() const noexcept { return storage_.empty(); } inline void reset() noexcept; + + template + auto then(TCallable&& onSuccess, TErrorCallable&& onError = 0) + { + return thenImpl(*this, std::forward(onSuccess), std::forward(onError)); + } + + template + auto then(TCallable&& onSuccess, TErrorCallable&& onError = 0) const + { + return thenImpl(*this, std::forward(onSuccess), std::forward(onError)); + } +private: template - auto then(this TSelf&& self, TCallable&& onSuccess, TErrorCallable&& onError = 0) + static auto thenImpl(TSelf&& self, TCallable&& onSuccess, TErrorCallable&& onError = 0) { using result_t = std::invoke_result_t>;