:relfileprefix: ../../../
[#boost-urls-segments_view-2constructor-0e]

== xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/segments_view.adoc[pass:[segments_view]]::segments_view


Constructor


=== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/segments_view.hpp#L163[boost/url/segments_view.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
segments_view(core::string_view s);
----

=== Description


This function constructs segments from
a valid path string, which can contain
percent escapes.
Upon construction, the view references
the character buffer pointed to by `s`.
caller is responsible for ensuring
that the lifetime of the buffer
extends until the view is destroyed.
[,cpp]
----
segments_view ps( "/path/to/file.txt" );
----
[,cpp]
----
return parse_path( s ).value();
----
[,cpp]
----
this->buffer().data() == s.data()
----

=== Linear in `s`.

=== Exceptions thrown on invalid input.
[,cpp]
----
path = [ "/" ] [ segment *( "/" segment ) ]

segment = *pchar
----

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.3[3.3.  Path]



=== Exceptions

|===
| Name | Thrown on

| ``s``
| 
contains an invalid path.

|===



=== Parameters

|===
| Name | Description 

| *s*
| 
The string to parse.

|===




