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


Insert segments

== Synopsis


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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/segments_encoded_base/iterator.adoc[iterator]
xref:boost/urls/segments_encoded_ref/insert-04e.adoc[insert](
    xref:boost/urls/segments_encoded_base/iterator.adoc[iterator] before,
    xref:boost/urls/pct_string_view.adoc[pct&lowbar;string&lowbar;view] s);
----

[.small]#xref:boost/urls/segments_encoded_ref/insert-04e.adoc[_» more..._]#

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/segments_encoded_base/iterator.adoc[iterator]
xref:boost/urls/segments_encoded_ref/insert-0d.adoc[insert](
    xref:boost/urls/segments_encoded_base/iterator.adoc[iterator] before,
    std::initializer&lowbar;list&lt;xref:boost/urls/pct_string_view.adoc[pct&lowbar;string&lowbar;view]&gt; init);
----

[.small]#xref:boost/urls/segments_encoded_ref/insert-0d.adoc[_» more..._]#

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FwdIt&gt;
xref:boost/urls/segments_encoded_base/iterator.adoc[iterator]
xref:boost/urls/segments_encoded_ref/insert-07.adoc[insert](
    xref:boost/urls/segments_encoded_base/iterator.adoc[iterator] before,
    FwdIt first,
    FwdIt last);
----

[.small]#xref:boost/urls/segments_encoded_ref/insert-07.adoc[_» more..._]#

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FwdIt&gt;
xref:boost/urls/segments_encoded_base/iterator.adoc[iterator]
xref:boost/urls/segments_encoded_ref/insert-07.adoc[insert](
    xref:boost/urls/segments_encoded_base/iterator.adoc[iterator] before,
    FwdIt first,
    FwdIt last,
    std::input&lowbar;iterator&lowbar;tag) = delete;
----

[.small]#xref:boost/urls/segments_encoded_ref/insert-07.adoc[_» more..._]#

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FwdIt&gt;
xref:boost/urls/segments_encoded_base/iterator.adoc[iterator]
xref:boost/urls/segments_encoded_ref/insert-07.adoc[insert](
    xref:boost/urls/segments_encoded_base/iterator.adoc[iterator] before,
    FwdIt first,
    FwdIt last,
    std::forward&lowbar;iterator&lowbar;tag);
----

[.small]#xref:boost/urls/segments_encoded_ref/insert-07.adoc[_» more..._]#

== Description


This function inserts a segment        before the specified position&period;        Reserved characters in the segment are        automatically escaped&period;        Escapes in the segment are preserved&period;

All iterators that are equal to        `before` or come after are invalidated&period;


=== Complexity

Linear in `s&period;size() &plus; this&hyphen;&gt;url()&period;encoded&lowbar;resource()&period;size()`&period;


=== Exception Safety

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



== Exceptions


|===
| Name | Thrown on

| `system&lowbar;error`
| The segment contains an invalid percent&hyphen;encoding&period;


|===

== Return Value


An iterator to the inserted        segment&period;



== Parameters


|===
| Name | Description

| *before*
| An iterator before which        the segment is inserted&period; This may        be equal to `end()`&period;


| *s*
| The segment to insert&period;


| *init*
| The list of segments to insert&period;


| *first*
| The first element in the range to insert&period;


| *last*
| One past the last element in the range to insert&period;


|===



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