[ox/std] Add an unlikely label to ox{Return,Throw}Error for C++20 builds

This commit is contained in:
Gary Talent 2021-02-21 00:32:07 -06:00
parent c82b72d8aa
commit 57ad13fc4a

View File

@ -104,6 +104,11 @@ constexpr Error toError(const Result<T> &ve) noexcept {
}
inline void oxIgnoreError(ox::Error) 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_error
#else
#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