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

Replace a substring with a string.

Synopsis
string&
replace(
    std::size_t pos,
    std::size_t count,
    string_view sv);
Description

Replaces rcount characters starting at index pos with those of sv, 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.

sv

The string_view to replace with.

Exceptions

Type

Thrown On

std::length_error

size() + (sv.size() - rcount) > max_size()

std::out_of_range

pos > size()


PrevUpHomeNext