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 (4 of 5 overloads)

Replace a substring with copies of a character.

Synopsis
string&
replace(
    std::size_t pos,
    std::size_t count,
    std::size_t count2,
    char ch);
Description

Replaces rcount characters starting at index poswith count2 copies of ch, where rcount is std::min(count, size() - pos).

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

pos

The index to replace at.

count

The number of characters to replace.

count2

The number of characters to replace with.

ch

The character to replace with.

Exceptions

Type

Thrown On

std::length_error

size() + (count2 - rcount) > max_size()

std::out_of_range

pos > size()


PrevUpHomeNext