From f3ac764684c64fbdd2094853a80b23e570cd5d9c Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Tue, 15 Oct 2024 20:56:26 -0500 Subject: Conver to using static constructors for string, sqlite, files. --- include/fud_result.hpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'include/fud_result.hpp') diff --git a/include/fud_result.hpp b/include/fud_result.hpp index dae084a..3acf776 100644 --- a/include/fud_result.hpp +++ b/include/fud_result.hpp @@ -47,6 +47,26 @@ class [[nodiscard]] Result { return ResultType{std::move(error)}; } + template + static ResultType okay(const Result& okayRes) { + return ResultType{okayRes.getOkay()}; + } + + template + static ResultType okay(Result&& okayRes) { + return ResultType{okayRes.takeOkay()}; + } + + template + static ResultType error(const Result& errorRes) { + return ResultType{errorRes.getError()}; + } + + template + static ResultType error(Result&& errorRes) { + return ResultType{errorRes.takeError()}; + } + [[nodiscard]] constexpr bool isOkay() const { return (m_value.index() == 0); @@ -67,12 +87,12 @@ class [[nodiscard]] Result { return std::get(m_value); } - [[nodiscard]] const T&& getOkay() const&& + [[nodiscard]] T&& takeOkay() { return std::move(std::get(m_value)); } - [[nodiscard]] const E&& getError() const&& + [[nodiscard]] E&& takeError() { return std::move(std::get(m_value)); } -- cgit v1.2.3