[#boost-urls-segments_encoded_ref-insert-04e] = xref:boost/urls/segments_encoded_ref/insert-04e.adoc[boost::urls::segments_encoded_ref::insert] :relfileprefix: ../../../ :mrdocs: Insert segments == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/segments_encoded_ref.hpp#L405[boost/url/segments_encoded_ref.hpp]>` [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_string_view] s); ---- == Description This function inserts a segment before the specified position. Reserved characters in the segment are automatically escaped. Escapes in the segment are preserved. All iterators that are equal to `before` or come after are invalidated. == Complexity Linear in `s.size() + this‐>url().encoded_resource().size()`. == Exception Safety Strong guarantee. Calls to allocate may throw. Exceptions thrown on invalid input. == Exceptions [cols=2] |=== | Name | Thrown on | `system_error` | The segment contains an invalid percent‐encoding. |=== == Return Value An iterator to the inserted segment. == Parameters [cols=2] |=== | Name | Description | *before* | An iterator before which the segment is inserted. This may be equal to `end()`. | *s* | The segment to insert. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#