:relfileprefix: ../../../
[#DAC1302C79C8F51446CB28AA9DBED58F1F6AAE13]

= Function segments_encoded_ref::insert

pass:v,q[Insert segments]


== Synopsis

Declared in header `</boost/url/segments_encoded_ref.hpp#L453[boost/url/segments_encoded_ref.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/segments_encoded_base.adoc[segments_encoded_base]::xref:boost/urls/segments_encoded_base/iterator.adoc[iterator]
insert(
    xref:boost/urls/segments_encoded_base.adoc[segments_encoded_base]::xref:boost/urls/segments_encoded_base/iterator.adoc[iterator] before,
    initializer_list<xref:boost/urls/pct_string_view.adoc[pct_string_view]> init);
----

== Description

pass:v,q[This function inserts the segments] pass:v,q[in an initializer list before the]
pass:v,q[specified position.]
pass:v,q[Reserved characters in the list are]
pass:v,q[automatically escaped.]
pass:v,q[Escapes in the list are preserved.]
pass:v,q[All iterators that are equal to]
pass:v,q[`before` or come after are invalidated.]
[NOTE]
pass:v,q[None of the character buffers referenced]
pass:v,q[by the list may overlap the character]
pass:v,q[buffer of the underlying url, or else]
pass:v,q[the behavior is undefined.]

=== Example
[,cpp]
----
url u( "/file.txt" );

u.encoded_segments().insert( u.encoded_segments().begin(), { "path", "to" } );
----

=== Complexity
pass:v,q[Linear in `init.size() + this->url().encoded_resource().size()`.]

=== Exception Safety
pass:v,q[Strong guarantee.]
pass:v,q[Calls to allocate may throw.]
pass:v,q[Exceptions thrown on invalid input.]



== Return Value

* `iterator` 


== Parameters

|===
| Name | Type 

| *before*
| `iterator`

| *init*
| `initializer_list`

|===



