Boost C++ Libraries Home Libraries People FAQ More

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