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

The native type of string values.

Synopsis

Defined in header <boost/json/string.hpp>

class string
Types

Name

Description

allocator_type

The type of Allocator returned by get_allocator.

const_iterator

A random access const iterator to an element.

const_pointer

A const pointer to an element.

const_reference

A const reference to an element.

const_reverse_iterator

A reverse random access const iterator to an element.

difference_type

The type used to represent signed integers.

iterator

A random access iterator to an element.

pointer

A pointer to an element.

reference

A reference to an element.

reverse_iterator

A reverse random access iterator to an element.

size_type

The type used to represent unsigned integers.

value_type

The type of a character.

Member Functions

Name

Description

append

Append characters to the string.

Append a string to the string.

Append a range of characters.

assign

Assign characters to a string.

at

Return a character with bounds checking.

back

Return the last character.

begin

Return an iterator to the beginning.

c_str

Return the underlying character array directly.

capacity

Return the number of characters that can be held without a reallocation.

cbegin

Return an iterator to the beginning.

cend

Return an iterator to the end.

clear

Clear the contents.

compare

Compare a string with the string.

copy

Copy a substring to another string.

crbegin

Return a reverse iterator to the first character of the reversed container.

crend

Return a reverse iterator to the character following the last character of the reversed container.

data

Return the underlying character array directly.

empty

Check if the string has no characters.

end

Return an iterator to the end.

ends_with

Return whether the string end with a string.

Return whether the string ends with a character.

erase

Erase characters from the string.

Erase a character from the string.

Erase a range from the string.

find

Find the first occurrence of a string within the string.

Find the first occurrence of a character within the string.

find_first_not_of

Find the first occurrence of any of the characters not within the string.

Find the first occurrence of a character not equal to ch.

find_first_of

Find the first occurrence of any of the characters within the string.

find_last_not_of

Find the last occurrence of a character not within the string.

Find the last occurrence of a character not equal to ch.

find_last_of

Find the last occurrence of any of the characters within the string.

front

Return the first character.

get_allocator

Return the associated memory_resource.

grow

Increase size without changing capacity.

insert

Insert a string.

Insert a character.

Insert a range of characters.

operator string_view

Convert to a string_view referring to the string.

operator+=

Append characters from a string.

Append a character.

operator=

Copy assignment.

Move assignment.

Assign a value to the string.

operator[]

Return a character without bounds checking.

pop_back

Remove the last character.

push_back

Append a character.

rbegin

Return a reverse iterator to the first character of the reversed container.

rend

Return a reverse iterator to the character following the last character of the reversed container.

replace

Replace a substring with a string.

Replace a range with a string.

Replace a range with a range.

Replace a substring with copies of a character.

Replace a range with copies of a character.

reserve

Increase the capacity to at least a certain amount.

resize

Change the size of the string.

rfind

Find the last occurrence of a string within the string.

Find the last occurrence of a character within the string.

shrink_to_fit

Request the removal of unused capacity.

size

Return the number of characters in the string.

starts_with

Return whether the string begins with a string.

Return whether the string begins with a character.

storage

Return the associated memory_resource.

string

Default constructor.

Pilfer constructor.

Constructor.

Copy constructor.

Move constructor.

subview

Return a substring.

swap

Swap the contents.

~string

Destructor.

Static Members

Name

Description

max_size

Return the maximum number of characters any string can hold.

Static Members

Name

Description

npos

A special index.

Friends

Name

Description

swap

Exchange the given values.

Description

Instances of string store and manipulate sequences of char using the UTF-8 encoding. The elements of a string are stored contiguously. A pointer to any character in a string may be passed to functions that expect a pointer to the first element of a null-terminated char array. String iterators are regular char pointers.

Remarks

string member functions do not validate any UTF-8 byte sequences passed to them.

Thread Safety

Non-const member functions may not be called concurrently with any other member functions.

Satisfies

ContiguousContainer, ReversibleContainer, and SequenceContainer.

Convenience header <boost/json.hpp>


PrevUpHomeNext