:relfileprefix: ../../../
[#boost-urls-segments_ref-replace]

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

  


Replace segments



=== Synopsis
  

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/segments_base/iterator.adoc[iterator]
xref:boost/urls/segments_ref/replace-05.adoc[pass:[replace]](
    xref:boost/urls/segments_base/iterator.adoc[iterator] pos,
    core::string_view s);
----

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/segments_base/iterator.adoc[iterator]
xref:boost/urls/segments_ref/replace-04.adoc[pass:[replace]](
    xref:boost/urls/segments_base/iterator.adoc[iterator] from,
    xref:boost/urls/segments_base/iterator.adoc[iterator] to,
    core::string_view s);
----

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/segments_base/iterator.adoc[iterator]
xref:boost/urls/segments_ref/replace-02.adoc[pass:[replace]](
    xref:boost/urls/segments_base/iterator.adoc[iterator] from,
    xref:boost/urls/segments_base/iterator.adoc[iterator] to,
    std::initializer_list<core::string_view> init);
----

[source,cpp,subs="verbatim,macros,-callouts"]
----
template<class FwdIt>
xref:boost/urls/segments_base/iterator.adoc[iterator]
xref:boost/urls/segments_ref/replace-07.adoc[pass:[replace]](
    xref:boost/urls/segments_base/iterator.adoc[iterator] from,
    xref:boost/urls/segments_base/iterator.adoc[iterator] to,
    FwdIt first,
    FwdIt last);
----
  
=== Description


This function replaces the segment at
the specified position.
Reserved characters in the string are
automatically escaped.



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

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

=== Strong guarantee.

Calls to allocate may throw.



=== Return Value


An iterator to the replaced segment.



=== Parameters

|===
| Name | Description 

| *pos*
| 
An iterator to the segment.

| *s*
| 
The string to assign.

| *from,*
| 
to The range of segments to replace.

| *init*
| 
The list of segments to assign.

| *first,*
| 
last The range of segments to assign.

|===




