]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
enhance: Improve TRY macro
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 3 Aug 2025 11:43:32 +0000 (13:43 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 3 Aug 2025 11:45:20 +0000 (13:45 +0200)
src/ccache/util/expected.hpp

index a99cd2a3b30bdb6bdfc47bce74f279d5cb923052..e8a553725db704ddcabca769c57bda3f11a675ca 100644 (file)
@@ -50,11 +50,11 @@ template<typename E, typename T> void throw_on_error(const T& value);
 template<typename E, typename T>
 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)