From: Joel Rosdahl Date: Sun, 3 Aug 2025 11:43:32 +0000 (+0200) Subject: enhance: Improve TRY macro X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=2744875a688ed148b296063910634b9083e51b0d;p=thirdparty%2Fccache.git enhance: Improve TRY macro --- diff --git a/src/ccache/util/expected.hpp b/src/ccache/util/expected.hpp index a99cd2a3..e8a55372 100644 --- a/src/ccache/util/expected.hpp +++ b/src/ccache/util/expected.hpp @@ -50,11 +50,11 @@ template void throw_on_error(const T& value); template void throw_on_error(const T& value, std::string_view prefix); -#define TRY(x_) \ +#define TRY(expression_) \ do { \ - const auto result_ = x_; \ + auto result_ = (expression_); \ if (!result_) { \ - return tl::unexpected(result_.error()); \ + return tl::unexpected(std::move(result_.error())); \ } \ } while (false)