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

Return the first segment

== Synopsis

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

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

== Description

This function returns a string with the first segment of the path without any leading or trailing &apos;&sol;&apos; separators&period; Any percent&hyphen;escapes in the string are decoded first&period;

== Preconditions
[,cpp]
----
this->empty() == false
----
== Effects
[,cpp]
----
return *begin();
----
== Example
[,cpp]
----
assert( url_view( "/path/to/file.txt" ).segments().front() == "path" );
----
== Complexity
Linear in `this&hyphen;&gt;front()&period;size()`&period;

== Exception Safety
Calls to allocate may throw&period;

== Return Value

The first segment&period;


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