[ox/std] Add oxRequire

This commit is contained in:
Gary Talent 2021-03-16 21:15:05 -05:00
parent d6ff337cc0
commit e6d271295f

View File

@ -56,6 +56,9 @@ struct [[nodiscard]] Error {
template<typename T>
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__))