Returns whether this StatusOr<T> holds a value.

Synopsis

Declared in <absl/status/statusor.h>

[[nodiscard]]
bool
ok() const;

Description

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 }

Return Value

true if a value is held, false if an error is held.

Note

The return value should not be discarded.

Created with MrDocs