[#absl-StatusOr-ok] = xref:absl.adoc[absl]::xref:absl/StatusOr.adoc[StatusOr]::ok :relfileprefix: ../../ :mrdocs: Returns whether this `StatusOr<T>` holds a value. == Synopsis Declared in `<absl/status/statusor.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- [[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 https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^]. ==== [.small]#Created with https://www.mrdocs.com[MrDocs]#