From 2c50ce48ed22dfa98d79fc938d7afe0d5b079f7f Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 17 May 2026 15:02:07 -0500 Subject: [PATCH] [ox/std] Add Result::reoriginate functions --- deps/oxlib/src/std/include/ox/std/error.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/deps/oxlib/src/std/include/ox/std/error.hpp b/deps/oxlib/src/std/include/ox/std/error.hpp index 98a4fd05..4e03a5dc 100644 --- a/deps/oxlib/src/std/include/ox/std/error.hpp +++ b/deps/oxlib/src/std/include/ox/std/error.hpp @@ -345,6 +345,21 @@ struct [[nodiscard]] Result { return *this; } + constexpr Result reoriginate( + ErrorCode const pErrCode, + CString const pMsg = nullptr, + std::source_location const &pSrc = std::source_location::current()) const && noexcept { + if (error) { + return {std::move(value), Error{pErrCode, pMsg, pSrc}}; + } + return Error{}; + } + + constexpr Result reoriginate( + std::source_location const &pSrc = std::source_location::current()) const && noexcept { + return {std::move(value), Error{error.errCode, error.msg, pSrc}}; + } + }; namespace detail {