[#absl-StatusOr-ok]
= xref:absl.adoc[absl]::xref:absl/StatusOr.adoc[StatusOr]::ok
:relfileprefix: ../../
:mrdocs:

Returns whether this `StatusOr&lt;T&gt;` holds a value&period;

== Synopsis

Declared in `&lt;absl&sol;status&sol;statusor&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
bool
ok() const;
----

== Description

Returns whether or not this `absl&colon;&colon;StatusOr&lt;T&gt;` holds a `T` value&period; This member function is analogous to `absl&colon;&colon;Status&colon;&colon;ok()` and should be used similarly to check the status of return values&period;

Example&colon;

StatusOr&lt;Foo&gt; result &equals; DoBigCalculationThatCouldFail()&semi; if (result&period;ok()) &lcub; &sol;&sol; Handle result else &lcub; &sol;&sol; Handle error &rcub;

== Return Value

`true` if a value is held, `false` if an error is held&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====

[.small]#Created with https://www.mrdocs.com[MrDocs]#
