[#absl-StatusOr-2constructor-00d]
= xref:absl.adoc[absl]::xref:absl/StatusOr.adoc[StatusOr]::StatusOr
:relfileprefix: ../../
:mrdocs:

Constructs a new `StatusOr&lt;T&gt;` from a value convertible to `Status`&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename U = xref:absl/Status.adoc[absl::Status]&gt;
requires internal&lowbar;statusor&colon;&colon;IsConstructionFromStatusValid&lt;
                                 false, T, U&gt;&colon;&colon;value
StatusOr(U&& v);
----

== Description

Constructs a new `absl&colon;&colon;StatusOr&lt;T&gt;` with a non&hyphen;ok status&period; After calling this constructor, `this&hyphen;&gt;ok()` will be `false` and calls to `value()` will crash, or produce an exception if exceptions are enabled&period;

The constructor also takes any type `U` that is convertible to `absl&colon;&colon;Status`&period; This constructor is explicit if an only if `U` is not of type `absl&colon;&colon;Status` and the conversion from `U` to `Status` is explicit&period;

REQUIRES&colon; !Status(std&colon;&colon;forward&lt;U&gt;(v))&period;ok()&period; This requirement is DCHECKed&period; In optimized builds, passing absl&colon;&colon;OkStatus() here will have the effect of passing absl&colon;&colon;StatusCode&colon;&colon;kInternal as a fallback&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *v*
| The status (or value convertible to a status) to store&period;
|===


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