Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
string::replace (5 of 5 overloads)

Replace a range with copies of a character.

Synopsis
string&
replace(
    const_iterator first,
    const_iterator last,
    std::size_t count,
    char ch);
Description

Replaces the characters in the range {first, last) with count copies of ch.

Precondition

{first, last)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.

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.

count

The number of characters to replace with.

ch

The character to replace with.

Exceptions

Type

Thrown On

std::length_error

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


PrevUpHomeNext