Returns whether this StatusOr<T> holds a value.
Declared in <absl/status/statusor.h>
[[nodiscard]]
bool
ok() const;
Returns whether or not this absl::StatusOr<T> holds a T value. This member function is analogous to absl::Status::ok() and should be used similarly to check the status of return values.
Example:
StatusOr<Foo> result = DoBigCalculationThatCouldFail(); if (result.ok()) { // Handle result else { // Handle error }
true if a value is held, false if an error is held.
The return value should not be discarded.