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


Insert segments

== Synopsis


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

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

== Description


This function inserts the segments in        a range before the specified position&period;        Reserved characters in the list are        automatically escaped&period;

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

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


=== Mandates

[,cpp]
----
std::is_convertible< std::iterator_traits< FwdIt >::reference_type, core::string_view >::value == true
----

=== Complexity

Linear in `std&colon;&colon;distance( first, last ) &plus; this&hyphen;&gt;url()&period;encoded&lowbar;resource()&period;size()`&period;


=== Exception Safety

Strong guarantee&period;        Calls to allocate may throw&period;



== Return Value


An iterator to the first        segment inserted, or `before` if        `init&period;empty()`&period;



== Parameters


|===
| Name | Description

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


| *first*
| The beginning of the range of segments to insert&period;


| *last*
| The end of the range of segments to insert&period;


|===



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