bkietz commented on code in PR #44477:
URL: https://github.com/apache/arrow/pull/44477#discussion_r1815888035
##########
cpp/src/arrow/result.h:
##########
@@ -294,7 +294,13 @@ class [[nodiscard]] Result : public
util::EqualityComparable<Result<T>> {
///
/// \return The stored non-OK status object, or an OK status if this object
/// has a value.
- constexpr const Status& status() const { return status_; }
+ constexpr const Status& status() const& { return status_; }
+
+ /// Gets the stored status object, or an OK status if a `T` value is stored.
+ ///
+ /// \return The stored non-OK status object, or an OK status if this object
+ /// has a value.
+ Status status() && { return status_; }
Review Comment:
> The issue with this is that std::move(status_) will leave status_ in an OK
state
Please mark the result as an error with a placeholder status and move the
error status out. This won't be any more expensive than what you've already
written, and we can replace the placeholder with a static status after #44493
```suggestion
Status status() && {
if (ok()) return Status::OK();
auto out = std::move(status_);
status_ = Status::UnknownError("Uninitialized Result<T>");
return out;
}
```
> There is a
[proposal](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3125r1.html)
for this, which will likely make it into C++26
Whenever this is ready, it'll make constructs like static error statuses
much nicer.
--
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]