[#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 `*this`. == Synopsis Declared in `<absl/status/statusor.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- [[nodiscard]] xref:absl/StatusOr.adoc[StatusOr<T>]&& WithSourceLocation(xref:absl/SourceLocation.adoc[absl::SourceLocation] loc = absl::SourceLocation::current()) &&; ---- == Description Appends the `loc` to the current location chain inside the status iff the status‐or is non‐ok and contains a non‐empty message, and returns an rvalue reference to `*this`. Example: StatusOr<int> Finalize(...); StatusOr<int> DoSomething(...) { ... return Finalize().WithSourceLocation(); } == Return Value An rvalue reference to `*this`. [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. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#