bsl::basic_string

STL-compliant string conforming to the bslma::Allocator model.

Synopsis

Declared in <bslstl_string.h>

template<
    class CHAR_TYPE,
    class CHAR_TRAITS = char_traits<CHAR_TYPE>,
    class ALLOCATOR = allocator<CHAR_TYPE>>
class basic_string;

Type Aliases

NameDescription
allocator_type Alias for the (template parameter) ALLOCATOR type.
const_iterator Alias for a constant iterator over the characters of this string.
const_pointer Alias for a constant pointer to the character type.
const_reference Alias for a non-modifiable reference to the character type.
const_reverse_iterator These types satisfy the ReversibleSequence requirements.
difference_type This typedef is an alias to AllocatorTraits::difference_type.
iterator Alias for an iterator over the characters of this string.
pointer Alias for a pointer to the character type.
reference Alias for a modifiable reference to the character type.
reverse_iterator Alias for a reverse iterator over the characters of this string.
size_type Alias for the size type of this string.
traits_type Alias for the (template parameter) CHAR_TRAITS type.
value_type Alias for the character type stored in this string.

Member Functions

NameDescription
basic_string [constructor]Constructors
~basic_string [destructor]Destroy this string object.
operator= Assignment operators
append append overloads
append_range Append characters from a range to this string.
assign assign overloads
assign_range Assign characters from a range to this string.
at at overloads
back Return a reference to the last character of this string.
begin begin overloads
c_str Return a pointer to the null-terminated character buffer.
capacity Return the capacity of this string, i.e., the maximum length for which resizing is guaranteed not to trigger a reallocation.
cbegin Return an iterator providing non-modifiable access to the first character of this string (or the past-the-end iterator if this string is empty).
cend Return the past-the-end iterator for this string.
clear Reset this string to an empty value.
compare Lexicographically compare this string with another sequence.
contains contains overloads
copy Copy characters from this string into a character buffer.
crbegin Return a reverse iterator providing non-modifiable access to the last character of this string (or the past-the-end reverse iterator if this string is empty).
crend Return the past-the-end reverse iterator for this string.
data Return a pointer to the character buffer of this string.
empty Return true if this string has length 0, and false otherwise.
end end overloads
ends_with Return whether this string ends with the specified sequence.
erase erase overloads
find find overloads
find_first_not_of find_first_not_of overloads
find_first_of find_first_of overloads
find_last_not_of find_last_not_of overloads
find_last_of find_last_of overloads
front front overloads
get_allocator Return the allocator used by this string to supply memory.
insert insert overloads
insert_range Insert characters from a range into this string.
length Return the length of this string.
max_size Return the maximum possible length of this string.
operator+= Addition assignment operators
operator[] Return a reference to the character at the specified position.
pop_back Erase the last character from this string. The behavior is undefined if this string is empty.
push_back Append the specified character to this string.
rbegin rbegin overloads
rend rend overloads
replace replace overloads
replace_with_range Replace a substring with characters from a range.
reserve Request that the capacity be at least the specified value.
resize Change the length of this string.
resize_and_overwrite Resize this string and overwrite its contents.
rfind rfind overloads
shrink_to_fit Request removal of unused capacity.
size Return the length of this string.
starts_with starts_with overloads
substr substr overloads
swap Exchange the contents of two strings.
operator BloombergLP::bslmf::NestedTraitDeclaration<basic_string, IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable<ALLOCATOR>::value> Declare that basic_string is bitwise-movable when ALLOCATOR is.
operator basic_string_view<CHAR_TYPE, CHAR_TRAITS> Convert this string to a matching basic_string_view.
operator std::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC2> Convert this string to a platform basic_string.

Static Data Members

NameDescription
npos Value used to denote "not-a-position", guaranteed to be outside the range [0 .. max_size()].

Deduction Guides

NameDescription
basic_string<CHAR_TYPE> Deduce template arguments for basic_string from constructor arguments.
basic_string<CHAR_TYPE> Deduce template arguments for basic_string from constructor arguments.
basic_string<CHAR_TYPE> Deduce template arguments for basic_string from constructor arguments.
basic_string<CHAR_TYPE> Deduce template arguments for basic_string from constructor arguments.
basic_string<CHAR_TYPE> Deduce template arguments for basic_string from constructor arguments.
basic_string<CHAR_TYPE, CHAR_TRAITS> Deduce template arguments for basic_string from constructor arguments.
basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR> Deduce template arguments for basic_string from constructor arguments.
basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR> Deduce template arguments for basic_string from constructor arguments.
basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR> Deduce template arguments for basic_string from constructor arguments.
basic_string<CHAR_TYPE, char_traits<CHAR_TYPE>, ALLOCATOR> Deduce template arguments for basic_string from constructor arguments.

Friends

NameDescription
bsl::String_ClearProctorProctor that clears a string and restores it unless released.
bsl::to_stringConvert a numeric value to a string.
bsl::to_stringConvert a numeric value to a string.
bsl::to_stringConvert a numeric value to a string.
bsl::to_stringConvert a numeric value to a string.
bsl::to_stringConvert a numeric value to a string.
bsl::to_stringConvert a numeric value to a string.

Non-Member Functions

NameDescription
eraseErase all occurrences of a character from a string.
erase_ifErase all characters matching a predicate from a string.
hashBasicStringReturn a hash value for the specified string.
operator+Same as the primary operator+ with a C-string lhs.
operator+Same as the primary operator+ with a C-string rhs.
operator+Same as the primary operator+ with a single CHAR_TYPE rhs and rvalue lhs.
operator+Same as the primary operator+ with an rvalue lhs C-string.
operator+Same as the primary operator+ overload with an rvalue lhs.
operator+Same as the primary operator+ with a string-view-like lhs and string rhs.
operator+Same as the primary operator+ with a C-string rhs and rvalue lhs.
operator+Return the concatenation of the specified operands.
operator+Return the concatenation of lhs and rhs.
operator+Same as the primary operator+ with an rvalue lhs and C-string rhs.
operator+Same as the primary operator+ for mixed std/bsl strings with an rvalue rhs.
operator+Same as the primary operator+ overload with an rvalue lhs and lvalue rhs.
operator+Same as the primary operator+ for mixed bsl/std strings.
operator+Same as the primary operator+ with a single CHAR_TYPE lhs and rvalue rhs.
operator+Same as the primary operator+ with C-string operands.
operator+Same as the primary operator+ overload with an rvalue lhs.
operator+Same as the primary operator+ with a C-string lhs and rvalue rhs.
operator+Same as the primary operator+ for mixed bsl/std strings.
operator+Same as the primary operator+ with a C-string rhs and rvalue lhs.
operator+Same as the primary operator+ for mixed std/bsl strings.
operator<=>Perform a lexicographic three-way comparison of two strings.
operator<=>Perform a lexicographic three-way comparison of two strings.
operator<=>Perform a lexicographic three-way comparison of two strings.
operator==Return whether two strings have the same value.
operator==Same as the two-argument operator== for basic_string.
operator==Same as the two-argument operator== for mixed bsl/std strings.
quotedReturn a streamable object that quotes the specified value.
quotedReturn a streamable object that quotes the specified value.
swapExchange the contents of two strings.
::BloombergLP::bslstl::operator+Return the concatenation of the specified lhs string ref and the specified rhs std::basic_string value.
::BloombergLP::bslstl::operator+Return a bsl::string having the value of the concatenation of the strings referred to by the specified lhs and rhs values.
::BloombergLP::bslstl::operator+Return the concatenation of the specified C string and string ref.
::BloombergLP::bslstl::operator+Return the concatenation of the specified lhs string ref and the specified rhs bsl::basic_string value.
::BloombergLP::bslstl::operator+Return the concatenation of the specified lhs string ref and the specified rhs bsl::basic_string value.
::BloombergLP::bslstl::operator+Return the concatenation of the specified string ref and C string.
::BloombergLP::bslstl::operator+Return the concatenation of the specified lhs std::basic_string and the specified rhs string ref.