[#boost-urls-segments_encoded_view-2constructor-02]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/segments_encoded_view.adoc[segments&lowbar;encoded&lowbar;view]::segments&lowbar;encoded&lowbar;view
:relfileprefix: ../../../
:mrdocs:


Constructor

== Synopsis


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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
segments&lowbar;encoded&lowbar;view(core::string&lowbar;view s);
----

== Description


This function constructs segments from        a valid path string, which can contain        percent escapes&period;        Upon construction, the view references        the character buffer pointed to by `s`&period;        caller is responsible for ensuring        that the lifetime of the buffer        extends until the view is destroyed&period;


=== Example

[,cpp]
----
segments_encoded_view ps( "/path/to/file.txt" );
----

=== Effects

[,cpp]
----
return parse_path( s ).value();
----

=== Postconditions

[,cpp]
----
this->buffer().data() == s.data()
----

=== Complexity

Linear in `s`&period;


=== Exception Safety

Exceptions thrown on invalid input&period;


=== BNF

[,cpp]
----
path = [ "/" ] [ segment *( "/" segment ) ]

segment = *pchar
----

=== Specification

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

Constructor

This function constructs segments from        a valid path string, which can contain        percent escapes&period;        Upon construction, the view references        the character buffer pointed to by `s`&period;        caller is responsible for ensuring        that the lifetime of the buffer        extends until the view is destroyed&period;


=== Example

[,cpp]
----
segments_encoded_view ps( "/path/to/file.txt" );
----

=== Effects

[,cpp]
----
return parse_path( s ).value();
----

=== Postconditions

[,cpp]
----
this->buffer().data() == s.data()
----

=== Complexity

Linear in `s`&period;


=== Exception Safety

Exceptions thrown on invalid input&period;


=== BNF

[,cpp]
----
path = [ "/" ] [ segment *( "/" segment ) ]

segment = *pchar
----

=== Specification

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



== Exceptions


|===
| Name | Thrown on

| `system&lowbar;error`
| `s` contains an invalid path&period;


| `system&lowbar;error`
| `s` contains an invalid path&period;


|===

== Parameters


|===
| Name | Description

| *s*
| The string to parse&period;


| *s*
| The string to parse&period;


|===



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