[#absl-StatusOr-value_or-03]
= xref:absl.adoc[absl]::xref:absl/StatusOr.adoc[StatusOr]::value&lowbar;or
:relfileprefix: ../../
:mrdocs:

Returns the held value, or a default when no value is present&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename U&gt;
requires internal&lowbar;statusor&colon;&colon;IsValueOrValid&lt;T, U&amp;&amp;, false&gt;&colon;&colon;value
T
value&lowbar;or(U&& default&lowbar;value) const &amp;;
----

== Description

Returns the current value if `this&hyphen;&gt;ok() &equals;&equals; true`&period; Otherwise constructs a value using the provided `default&lowbar;value`&period;

Unlike `value`, this function returns by value, copying the current value if necessary&period; If the value type supports an efficient move, it can be used as follows&colon;

T value &equals; std&colon;&colon;move(statusor)&period;value&lowbar;or(def)&semi;

Unlike with `value`, calling `std&colon;&colon;move()` on the result of `value&lowbar;or` will still trigger a copy&period;

== Return Value

The held value if present, otherwise `default&lowbar;value`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *default&lowbar;value*
| The value returned when no held value is present&period;
|===


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