PragmaTwice commented on code in PR #1032:
URL:
https://github.com/apache/incubator-kvrocks/pull/1032#discussion_r1004110808
##########
src/common/status.h:
##########
@@ -285,3 +282,10 @@ struct StatusOr {
template <typename>
friend struct StatusOr;
};
+
+#define GET_OR_RET(...) \
+ ({ \
+ auto&& status = (__VA_ARGS__); \
+ if (!status) return std::forward<decltype(status)>(status); \
+ std::forward<decltype(status)>(status); \
+ }).GetValue()
Review Comment:
> The latter is possible to cause cref a dangling reference.
It is actually not a problem of this macro.
It is a problem for all C++ program, you need to care about lifetime.
You can meet this situation in everywhere of C++, e.g.
```
const auto& a = create_string(...).ref_element(0); // aha, dangling reference
```
And if you want it to work rather than dangling reference, I can fix it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]