From 8f87c599a9e3c9c205588bb1c5eca82514158b6a 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 (synced from e6d271295f1607726c40356698f3351ff6fa709b) --- src/ox/std/error.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ox/std/error.hpp b/src/ox/std/error.hpp index 3e0aed616..4af771afe 100644 --- a/src/ox/std/error.hpp +++ b/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__))