[ox/std] Move most macros to def.hpp in anticipation of C++20 modules
This commit is contained in:
18
deps/ox/src/ox/std/error.hpp
vendored
18
deps/ox/src/ox/std/error.hpp
vendored
@ -24,6 +24,7 @@ class exception {
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "def.hpp"
|
||||
#include "defines.hpp"
|
||||
#include "strongint.hpp"
|
||||
#include "typetraits.hpp"
|
||||
@ -176,20 +177,3 @@ constexpr Error toError(const Result<T> &ve) noexcept {
|
||||
constexpr void oxIgnoreError(const ox::Error&) noexcept {}
|
||||
template<typename T>
|
||||
constexpr void oxIgnoreError(const ox::Result<T>&) noexcept {}
|
||||
#if __cplusplus >= 202002L
|
||||
#define oxReturnError(x) if (const auto _ox_error = ox::detail::toError(x)) [[unlikely]] return _ox_error
|
||||
#define oxThrowError(x) if (const auto _ox_error = ox::detail::toError(x)) [[unlikely]] throw ox::Exception(_ox_error)
|
||||
#else
|
||||
#define oxReturnError(err) if (const auto _ox_error = ox::detail::toError(err)) return _ox_error
|
||||
#define oxThrowError(err) if (const auto _ox_error = ox::detail::toError(err)) throw ox::Exception(_ox_error)
|
||||
#endif
|
||||
#define oxConcatImpl(a, b) a##b
|
||||
#define oxConcat(a, b) oxConcatImpl(a, b)
|
||||
// oxRequire Mutable
|
||||
#define oxRequireM(out, x) auto [out, oxConcat(oxRequire_err_, __LINE__)] = x; oxReturnError(oxConcat(oxRequire_err_, __LINE__))
|
||||
#define oxRequire(out, x) const oxRequireM(out, x)
|
||||
// oxRequire Mutable Throw
|
||||
#define oxRequireMT(out, x) auto [out, oxConcat(oxRequire_err_, __LINE__)] = x; oxThrowError(oxConcat(oxRequire_err_, __LINE__))
|
||||
// oxRequire Throw
|
||||
#define oxRequireT(out, x) const oxRequireMT(out, x)
|
||||
|
||||
|
Reference in New Issue
Block a user