:relfileprefix: ../../../
[#boost-urls-segments_ref-assign]

== xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/segments_ref.adoc[pass:[segments_ref]]::assign

  


Assign segments



=== Synopsis
  

[source,cpp,subs="verbatim,macros,-callouts"]
----
void
xref:boost/urls/segments_ref/assign-08.adoc[pass:[assign]](std::initializer_list<core::string_view> init);
----

[source,cpp,subs="verbatim,macros,-callouts"]
----
template<class FwdIt>
void
xref:boost/urls/segments_ref/assign-0d.adoc[pass:[assign]](
    FwdIt first,
    FwdIt last);
----
  
=== Description


The existing contents are replaced
by a copy of the contents of the
initializer list.
Reserved characters in the list are
automatically escaped.



All iterators are invalidated.
[NOTE]

None of the character buffers referenced
by `init` may overlap the character buffer
of the underlying url, or else the behavior
is undefined.
[,cpp]
----
url u;

u.segments().assign( { "path", "to", "file.txt" } );
----

=== Linear in `init.size() + this-&gt;url().encoded_query().size() + this-&gt;url().encoded_fragment().size()`.

=== Strong guarantee.

Calls to allocate may throw.




=== Parameters

|===
| Name | Description 

| *init*
| 
The list of segments to assign.

| *first,*
| 
last The range of segments
to assign.

|===




