| Home | Libraries | People | FAQ | More

###### string::replace (3 of 5 overloads)

Replace a range with a range.

<h7> Synopsis </h7>

    template<
        class InputIt>
    string&
    replace(
        const_iterator first,
        const_iterator last,
        InputIt first2,
        InputIt last2);

<h7> Description </h7>

Replaces the characters in the range `{first, last)` with those of `{first2, last2)`.

<h7> Precondition </h7>

`{first, last)`is a valid range. `{first2, last2)` is a valid range.

<h7> Exception Safety </h7>

Strong guarantee.

<h7> Remarks </h7>

All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.

<h7> Template Parameters </h7>

Type | Description
--- | ---
`InputIt` | The type of the iterators.

<h7> Constraints </h7>

`InputIt`satisfies InputIterator.

<h7> Return Value </h7>

`*this`

<h7> Parameters </h7>

Name | Description
--- | ---
`first` | An iterator referring to the first character to replace.
`last` | An iterator one past the end of the last character to replace.
`first2` | An iterator referring to the first character to replace with.
`last2` | An iterator one past the end of the last character to replace with.

<h7> Exceptions </h7>

Type | Thrown On
--- | ---
`std::length_error` | `size() + (inserted - std::distance(first, last)) > max_size()`