[#boost-urls-segments_base-back]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/segments_base.adoc[segments&lowbar;base]::back
:relfileprefix: ../../../
:mrdocs:

Return the last segment

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/segments_base.hpp#Lundefined[boost&sol;url&sol;segments&lowbar;base&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
std::string
back() const;
----

== Preconditions

[,cpp]
----
this->empty() == false
----
== Example

[,cpp]
----
assert( url_view( "/path/to/file.txt" ).segments().back() == "file.txt" );
----
== Preconditions

[,cpp]
----
this->empty() == false
----
== Effects

[,cpp]
----
return *--end();
----
== Complexity

Linear in `this&hyphen;&gt;back()&period;size()`&period;

== Exception Safety

Calls to allocate may throw&period;

== Return Value

The last segment&period;


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