[#boost-urls-segments_encoded_ref-operator_assign-08]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/segments_encoded_ref.adoc[segments&lowbar;encoded&lowbar;ref]::operator&equals;
:relfileprefix: ../../../
:mrdocs:

Assignment

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/segments_encoded_ref.adoc[segments&lowbar;encoded&lowbar;ref]&
operator&equals;(std::initializer&lowbar;list&lt;pct&lowbar;string&lowbar;view&gt; init);
----

== Description

The existing contents are replaced by a copy of the contents of the initializer list&period; Reserved characters in the list are automatically escaped&period; Escapes in the list are preserved&period;

All iterators are invalidated&period;

== Example

[,cpp]
----
url u;

u.encoded_segments() = {"path", "to", "file.txt"};
----
== Preconditions

None of the character buffers referenced by the list may overlap the character buffer of the underlying url, or else the behavior is undefined&period;

== Effects

[,cpp]
----
this->assign( init.begin(), init.end() );
----
== Complexity

Linear in `init&period;size() &plus; this&hyphen;&gt;url()&period;encoded&lowbar;query()&period;size() &plus; this&hyphen;&gt;url()&period;encoded&lowbar;fragment()&period;size()`&period;

== Exception Safety

Strong guarantee&period; Calls to allocate may throw&period; Exceptions thrown on invalid input&period;

== Exceptions

[cols="1,4"]
|===
| Name| Thrown on
| `system&lowbar;error`
| The list contains an invalid percent&hyphen;encoding&period;
|===

== Return Value

A reference to this&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *init*
| The list of segments to assign&period;
|===


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