From d1251ac30f564877303e5b22c570b2178d68d30e Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:48:31 +0300 Subject: [PATCH] move isresult out --- include/Geode/Result.hpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/include/Geode/Result.hpp b/include/Geode/Result.hpp index 994426a..5bc3b8a 100644 --- a/include/Geode/Result.hpp +++ b/include/Geode/Result.hpp @@ -233,9 +233,6 @@ namespace geode { using ErrType = ErrType2; }; - template - concept IsResult = IsResultImpl::value; - template using ResultOkType = typename IsResultImpl::OkType; @@ -250,6 +247,9 @@ namespace geode { concept IsStringStreamable = requires(std::stringstream ss, Type t) { ss << t; }; } + template + concept IsResult = impl::IsResultImpl::value; + /// @brief Constructs a new Ok value /// @param ok the value to wrap in an Ok /// @return a new Ok value @@ -1591,7 +1591,7 @@ namespace geode { /// @param operation the operation to perform if this Result is Ok /// @return the result of the operation if this Result is Ok, otherwise this Result template - requires(std::invocable && impl::IsResult> && std::convertible_to>>) + requires(std::invocable && IsResult> && std::convertible_to>>) constexpr std::invoke_result_t andThen(Operation&& operation ) && noexcept(noexcept(operation(std::declval()))) { if (this->isOk()) { @@ -1606,7 +1606,7 @@ namespace geode { /// @param operation the operation to perform if this Result is Ok /// @return the result of the operation if this Result is Ok, otherwise this Result template - requires(std::invocable && impl::IsResult> && std::convertible_to>>) + requires(std::invocable && IsResult> && std::convertible_to>>) constexpr std::invoke_result_t andThen(Operation&& operation ) const& noexcept(noexcept(operation(std::declval()))) { if (this->isOk()) { @@ -1621,7 +1621,7 @@ namespace geode { /// @param operation the operation to perform if this Result is Ok /// @return the result of the operation if this Result is Ok, otherwise this Result template - requires(std::invocable && impl::IsResult> && std::convertible_to>>) + requires(std::invocable && IsResult> && std::convertible_to>>) constexpr std::invoke_result_t andThen(Operation&& operation ) && noexcept(noexcept(operation())) { if (this->isOk()) { @@ -1636,7 +1636,7 @@ namespace geode { /// @param operation the operation to perform if this Result is Ok /// @return the result of the operation if this Result is Ok, otherwise this Result template - requires(std::invocable && impl::IsResult> && std::convertible_to>>) + requires(std::invocable && IsResult> && std::convertible_to>>) constexpr std::invoke_result_t andThen(Operation&& operation ) const& noexcept(noexcept(operation())) { if (this->isOk()) { @@ -1677,7 +1677,7 @@ namespace geode { /// @param operation the operation to perform if this Result is Err /// @return the result of the operation if this Result is Err, otherwise this Result template - requires(std::invocable && impl::IsResult> && std::convertible_to>>) + requires(std::invocable && IsResult> && std::convertible_to>>) constexpr std::invoke_result_t orElse(Operation&& operation ) && noexcept(noexcept(operation(std::declval()))) { if (this->isOk()) { @@ -1692,7 +1692,7 @@ namespace geode { /// @param operation the operation to perform if this Result is Err /// @return the result of the operation if this Result is Err, otherwise this Result template - requires(std::invocable && impl::IsResult> && std::convertible_to>>) + requires(std::invocable && IsResult> && std::convertible_to>>) constexpr std::invoke_result_t orElse(Operation&& operation ) const& noexcept(noexcept(operation(std::declval()))) { if (this->isOk()) { @@ -1707,7 +1707,7 @@ namespace geode { /// @param operation the operation to perform if this Result is Err /// @return the result of the operation if this Result is Err, otherwise this Result template - requires(std::invocable && impl::IsResult> && std::convertible_to>>) + requires(std::invocable && IsResult> && std::convertible_to>>) constexpr std::invoke_result_t orElse(Operation&& operation ) && noexcept(noexcept(operation())) { if (this->isOk()) { @@ -1722,7 +1722,7 @@ namespace geode { /// @param operation the operation to perform if this Result is Err /// @return the result of the operation if this Result is Err, otherwise this Result template - requires(std::invocable && impl::IsResult> && std::convertible_to>>) + requires(std::invocable && IsResult> && std::convertible_to>>) constexpr std::invoke_result_t orElse(Operation&& operation ) const& noexcept(noexcept(operation())) { if (this->isOk()) { @@ -1779,7 +1779,7 @@ namespace geode { /// @return the inner Result if the Result is Ok, otherwise the outer Result constexpr Result, ErrType> flatten( ) && noexcept(std::is_nothrow_move_constructible_v && std::is_nothrow_move_constructible_v) - requires(impl::IsResult && std::same_as>) + requires(IsResult && std::same_as>) { if (this->isOk()) { return std::move(*this).unwrap(); @@ -1793,7 +1793,7 @@ namespace geode { /// @return the inner Result if the Result is Ok, otherwise the outer Result constexpr Result, ErrType> flatten( ) const& noexcept(std::is_nothrow_move_constructible_v && std::is_nothrow_move_constructible_v) - requires(impl::IsResult && std::same_as>) + requires(IsResult && std::same_as>) { if (this->isOk()) { return this->unwrap();