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

Appends a source location and returns an rvalue reference to `&ast;this`&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;
xref:absl/StatusOr.adoc[StatusOr&lt;T&gt;]&&
WithSourceLocation(xref:absl/SourceLocation.adoc[absl::SourceLocation] loc = absl&colon;&colon;SourceLocation&colon;&colon;current()) &amp;&amp;;
----

== Description

Appends the `loc` to the current location chain inside the status iff the status&hyphen;or is non&hyphen;ok and contains a non&hyphen;empty message, and returns an rvalue reference to `&ast;this`&period;

Example&colon;

StatusOr&lt;int&gt; Finalize(&period;&period;&period;)&semi;

StatusOr&lt;int&gt; DoSomething(&period;&period;&period;) &lcub; &period;&period;&period; return Finalize()&period;WithSourceLocation()&semi; &rcub;

== Return Value

An rvalue reference to `&ast;this`&period;

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

[cols="1,4"]
|===
| Name| Description
| *loc*
| The source location to append&period;
|===


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