[ox/std] Add oxRequire
This commit is contained in:
parent
d6ff337cc0
commit
e6d271295f
6
deps/ox/src/ox/std/error.hpp
vendored
6
deps/ox/src/ox/std/error.hpp
vendored
@ -56,6 +56,9 @@ struct [[nodiscard]] Error {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct [[nodiscard]] Result {
|
struct [[nodiscard]] Result {
|
||||||
|
|
||||||
|
using type = T;
|
||||||
|
|
||||||
T value;
|
T value;
|
||||||
Error error;
|
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 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
|
#define oxThrowError(x) if (const auto _ox_error = ox::detail::toError(x)) throw _ox_error
|
||||||
#endif
|
#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__))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user