From 57ad13fc4a0c6613a18585861aa9fc3e8681d80a Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 21 Feb 2021 00:32:07 -0600 Subject: [PATCH] [ox/std] Add an unlikely label to ox{Return,Throw}Error for C++20 builds --- deps/ox/src/ox/std/error.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 3f4dec30..f7f814c7 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -104,6 +104,11 @@ constexpr Error toError(const Result &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