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

PrevUpHomeNext
basic_static_string::replace (5 of 14 overloads)

Replace a part of the string.

Synopsis
constexpr basic_static_string&
replace(
    size_type pos,
    size_type n1,
    const_pointer s,
    size_type n2);
Description

Replaces rcount characters starting at index pos with those of {s, s + n2), where rcount is std::min(n1, 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.

n1

The number of characters to replace.

s

The string to replace with.

n2

The length of the string to replace with.

Exceptions

Type

Thrown On

std::length_error

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

std::out_of_range

pos > size()


PrevUpHomeNext