:relfileprefix: ../../../
[#boost-urls-segments_ref-insert-05]

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


Insert segments


=== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/segments_ref.hpp#L377[boost/url/segments_ref.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/segments_base/iterator.adoc[iterator]
insert(
    xref:boost/urls/segments_base/iterator.adoc[iterator] before,
    core::string_view s);
----

=== Description


This function inserts a segment
before the specified position.
Reserved characters in the segment are
automatically escaped.



All iterators that are equal to
`before` or come after are invalidated.

=== Linear in `s.size() + this-&gt;url().encoded_resource().size()`.

=== Strong guarantee.

Calls to allocate may throw.




=== Return Value


An iterator to the inserted
segment.



=== Parameters

|===
| Name | Description 

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

| *s*
| 
The segment to insert.

|===




