[#boost-urls-segments_encoded_ref-insert-04]
= 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#Lundefined[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]
insert(
    xref:boost/urls/segments_encoded_base/iterator.adoc[iterator] before,
    xref:boost/urls/pct_string_view.adoc[pct&lowbar;string&lowbar;view] s);
----

== 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

[cols="1,4"]
|===
| 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

[cols="1,4"]
|===
|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;
|===


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