Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
string::replace (3 of 5 overloads)

Replace a range with a range.

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

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

Precondition

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

Exception Safety

Strong guarantee.

Remarks

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

Template Parameters

Type

Description

InputIt

The type of the iterators.

Constraints

InputItsatisfies InputIterator.

Return Value

*this

Parameters

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.

Exceptions

Type

Thrown On

std::length_error

size() + (inserted - std::distance(first, last)) > max_size()


PrevUpHomeNext