[ox/std] Add ValErr support to oxReturnError

This commit is contained in:
Gary Talent 2019-06-16 19:00:47 -05:00
parent 98d045827e
commit 5834201fbb

View File

@ -17,7 +17,7 @@
#define OxError(x) static_cast<ox::Error>(x)
#endif
#define oxReturnError(x) if (const auto _err = x) return _err
#define oxReturnError(x) if (const auto _err = ox::error::toError(x)) return _err
namespace ox {
@ -77,5 +77,18 @@ struct ValErr {
};
namespace error {
[[nodiscard]] constexpr ox::Error toError(ox::Error e) noexcept {
return e;
}
template<typename T>
[[nodiscard]] constexpr ox::Error toError(ox::ValErr<T> ve) noexcept {
return ve.error;
}
}
}