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::insert (3 of 4 overloads)

Insert a character.

Synopsis
string&
insert(
    size_type pos,
    char ch);
Description

Inserts the character ch before the character at index 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 insert at.

ch

The character to insert.

Exceptions

Type

Thrown On

std::length_error

size() + 1 > max_size()

std::out_of_range

pos > size()


PrevUpHomeNext