[#boost-urls-url_base-segments-0e]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_base.adoc[url&lowbar;base]::segments
:relfileprefix: ../../../
:mrdocs:

Return the path as a container of segments

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/segments_ref.adoc[urls::segments&lowbar;ref]
segments() noexcept;
----

== Description

This function returns a bidirectional view of segments over the path&period; The returned view references the same underlying character buffer&semi; ownership is not transferred&period; Any percent&hyphen;escapes in strings returned when iterating the view are decoded first&period; The container is modifiable&semi; changes to the container are reflected in the underlying URL&period;

== Example

[,cpp]
----
url u( "http://example.com/path/to/file.txt" );

segments sv = u.segments();
----
== Complexity

Constant&period;

== Exception Safety

Throws nothing&period;

== BNF

[,cpp]
----
path          = path-abempty    ; begins with "/" or is empty
              / path-absolute   ; begins with "/" but not "//"
              / path-noscheme   ; begins with a non-colon segment
              / path-rootless   ; begins with a segment
              / path-empty      ; zero characters

path-abempty  = *( "/" segment )
path-absolute = "/" [ segment-nz *( "/" segment ) ]
path-noscheme = segment-nz-nc *( "/" segment )
path-rootless = segment-nz *( "/" segment )
path-empty    = 0<pchar>
----
== Specification

* https://datatracker.ietf.org/doc/html/rfc3986#section-3.3[3&period;3&period;  Path (rfc3986)]

== Return Value

`&ast;this`

== See Also

xref:boost/urls/url_base/encoded_segments-0a.adoc[`encoded&lowbar;segments`], xref:boost/urls/url_base/set_encoded_path.adoc[`set&lowbar;encoded&lowbar;path`], xref:boost/urls/url_base/set_path.adoc[`set&lowbar;path`], xref:boost/urls/url_base/set_path_absolute.adoc[`set&lowbar;path&lowbar;absolute`]&period;


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