From e6d271295f1607726c40356698f3351ff6fa709b Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 16 Mar 2021 21:15:05 -0500 Subject: [PATCH] [ox/std] Add oxRequire --- deps/ox/src/ox/std/error.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 3e0aed61..4af771af 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -56,6 +56,9 @@ struct [[nodiscard]] Error { template struct [[nodiscard]] Result { + + using type = T; + T value; Error error; @@ -111,4 +114,7 @@ inline void oxIgnoreError(ox::Error) noexcept {} #define oxReturnError(x) if (const auto _ox_error = ox::detail::toError(x)) return _ox_error #define oxThrowError(x) if (const auto _ox_error = ox::detail::toError(x)) throw _ox_error #endif +#define oxConcatImpl(a, b) a##b +#define oxConcat(a, b) oxConcatImpl(a, b) +#define oxRequire(out, x) auto [out, oxConcat(oxRequire_err_, __LINE__)] = x; oxReturnError(oxConcat(oxRequire_err_, __LINE__))