[#absl-StatusOr-operator_assign-01]
= xref:absl.adoc[absl]::xref:absl/StatusOr.adoc[StatusOr]::operator&equals;
:relfileprefix: ../../
:mrdocs:

Perfect&hyphen;forwarding value assignment operator&period;

== Synopsis

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

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

== Description

If `&ast;this` contains a `T` value before the call, the contained value is assigned from `std&colon;&colon;forward&lt;U&gt;(v)`&semi; Otherwise, it is directly&hyphen;initialized from `std&colon;&colon;forward&lt;U&gt;(v)`&period; This function does not participate in overload unless&colon; 1&period; `std&colon;&colon;is&lowbar;constructible&lowbar;v&lt;T, U&gt;` is true, 2&period; `std&colon;&colon;is&lowbar;assignable&lowbar;v&lt;T&amp;, U&gt;` is true&period; 3&period; `std&colon;&colon;is&lowbar;same&lowbar;v&lt;StatusOr&lt;T&gt;, std&colon;&colon;remove&lowbar;cvref&lowbar;t&lt;U&gt;&gt;` is false&period; 4&period; Assigning `U` to `T` is not ambiguous&colon; If `U` is `StatusOr&lt;V&gt;` and `T` is constructible and assignable from both `StatusOr&lt;V&gt;` and `V`, the assignment is considered bug&hyphen;prone and ambiguous thus will fail to compile&period; For example&colon; StatusOr&lt;bool&gt; s1 &equals; true&semi; &sol;&sol; s1&period;ok() &amp;&amp; &ast;s1 &equals;&equals; true StatusOr&lt;bool&gt; s2 &equals; false&semi; &sol;&sol; s2&period;ok() &amp;&amp; &ast;s2 &equals;&equals; false s1 &equals; s2&semi; &sol;&sol; ambiguous, `s1 &equals; &ast;s2` or `s1 &equals; bool(s2)`?

== Return Value

A reference to `&ast;this`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *v*
| The value to assign into the held object&period;
|===


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