From 2744875a688ed148b296063910634b9083e51b0d Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sun, 3 Aug 2025 13:43:32 +0200 Subject: [PATCH] enhance: Improve TRY macro --- src/ccache/util/expected.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) -- 2.47.2