diff options
author | Dino Radakovic <dinor@google.com> | 2023-05-04 12:37:11 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-05-04 12:38:14 -0700 |
commit | b2abe7ad28fd79cbb889dbf9814292be495f04ed (patch) | |
tree | 1193cbd2a4883a4f45711e12b801f9ff097df5a5 /absl/status/statusor.h | |
parent | 3d604bc673b8c6d72a45afdfdc24e9d442b6f372 (diff) |
Make `absl::StatusOr::AssignStatus` public. Recommend against using it outside of generic programming
PiperOrigin-RevId: 529484669
Change-Id: I9889a9f7a7fa7dc6ef8c731f1b583a74e6afd2cf
Diffstat (limited to 'absl/status/statusor.h')
-rw-r--r-- | absl/status/statusor.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/absl/status/statusor.h b/absl/status/statusor.h index beedd795..f1932238 100644 --- a/absl/status/statusor.h +++ b/absl/status/statusor.h @@ -612,6 +612,21 @@ class StatusOr : private internal_statusor::StatusOrData<T>, return this->data_; } + // StatusOr<T>::AssignStatus() + // + // Sets the status of `absl::StatusOr<T>` to the given non-ok status value. + // + // NOTE: We recommend using the constructor and `operator=` where possible. + // This method is intended for use in generic programming, to enable setting + // the status of a `StatusOr<T>` when `T` may be `Status`. In that case, the + // constructor and `operator=` would assign into the inner value of type + // `Status`, rather than status of the `StatusOr` (b/280392796). + // + // REQUIRES: !Status(std::forward<U>(v)).ok(). This requirement is DCHECKed. + // In optimized builds, passing absl::OkStatus() here will have the effect + // of passing absl::StatusCode::kInternal as a fallback. + using internal_statusor::StatusOrData<T>::AssignStatus; + private: using internal_statusor::StatusOrData<T>::Assign; template <typename U> |