This class template provides an STL‐compliant string that conforms to the bslma::Allocator model. For the requirements of a string class, consult the second revision of the ISO/IEC 14882 Programming Language C++ (2003). Note that the (template parameter) CHAR_TYPE must be equal to ALLOCATOR::value_type. In addition, this implementation offers strong exception guarantees (see below), with the general rules that:
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;
Description
1. any method that would result in a string of length larger than the size returned by max_size throws std::length_error, and 2. any method that attempts to access a position outside the valid range of a string throws std::out_of_range.
Circumstances where a method throws bsl::length_error (1) are clear and not repeated in the individual function‐level documentations below.
More generally, this class supports an almost complete set of in‐core value semantic operations, including copy construction, assignment, equality comparison (but excluding ostream printing since this component is below STL). A precise operational definition of when two objects have the same value can be found in the description of operator== for the class. This class is exception neutral with full guarantee of rollback: if an exception is thrown during the invocation of a method on a pre‐existing object, the object is left unchanged. In no event is memory leaked.
Note that aliasing (e.g., using all or part of an object as both source and destination) is supported in all cases in the public interface of basic_string. However, the private interface (...Raw methods) should be assumed to be not alias‐safe unless specifically noted otherwise.
Type Aliases
Name |
Description |
Alias for the (template parameter) |
|
Alias for a constant iterator over the characters of this string. |
|
Alias for a constant pointer to the character type. |
|
Alias for a non‐modifiable reference to the character type. |
|
These types satisfy the |
|
This |
|
Alias for an iterator over the characters of this string. |
|
Alias for a pointer to the character type. |
|
Alias for a modifiable reference to the character type. |
|
Alias for a reverse iterator over the characters of this string. |
|
Alias for the size type of this string. |
|
Alias for the (template parameter) |
|
Alias for the character type stored in this string. |
Member Functions
Name |
Description |
|
Constructors |
|
Destroy this string object. |
Assignment operators |
|
|
|
Append to this string the characters from the specified |
|
|
|
Assign to this string the characters from the specified |
|
|
|
|
|
|
|
Return an address providing non‐modifiable access to the null‐terminated buffer of |
|
Return the capacity of this string, i.e., the maximum length for which resizing is guaranteed not to trigger a reallocation. |
|
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). |
|
Return the past‐the‐end iterator for this string. |
|
Reset this string to an empty value. Note that the capacity may change (or not if |
|
|
|
|
|
Copy from this string, starting from the optionally specified |
|
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). |
|
Return the past‐the‐end reverse iterator for this string. |
|
|
|
Return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return the allocator used by this string to supply memory. |
|
|
|
Insert at the specified |
|
Return the length of this string. Note that this number may differ from |
|
Return the maximal possible length of this string. Note that requests to create a string longer than this number of characters are guaranteed to raise a |
|
Addition assignment operators |
|
Subscript operators |
|
Erase the last character from this string. The behavior is undefined if this string is empty. |
|
Append the specified |
|
|
|
|
|
|
|
Replace the substring in the range starting at the specified |
|
Change the capacity of this string to the specified |
|
|
|
Change the length of this string to the specified |
|
|
|
Request the removal of unused capacity by causing reallocation. Note that this method has no effect if the capacity is equal to the size. Also note that if (and only if) reallocation occurs, all iterators, including the past the end iterator, and all references to the elements are invalidated. |
|
Return the length of this string. Note that this number may differ from |
|
|
|
|
|
Exchange the value of this object with that of the specified |
|
|
|
|
Convert this object to a |
|
Convert this object to a string type native to the compiler's library, instantiated with the same character type and traits type, but not necessarily the same allocator type. The return string will contain the same sequence of characters as |
Static Data Members
Name |
Description |
Value used to denote "not‐a‐position", guaranteed to be outside the range |
Specializations
Deduction Guides
Name |
Description |
Deduce the template parameter |
|
Deduce the template parameter |
|
Deduce the template parameter |
|
Deduce the template parameter |
|
Deduce the template parameter |
|
Deduce the template parameters |
|
|
Deduce the template parameters |
|
Deduce the template parameters |
|
Deduce the template parameters |
|
Deduce the template parameter |
Friends
Name |
Description |
This component private |
|
Constructs a string with contents equal to the specified |
|
Constructs a string with contents equal to the specified |
|
Constructs a string with contents equal to the specified |
|
Constructs a string with contents equal to the specified |
|
Constructs a string with contents equal to the specified |
|
|
Non-Member Functions
Name |
Description |
Erase (in‐place) all the elements from the specified |
|
Erase (in‐place) all the elements from the specified |
|
Return a hash value for the specified |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Return the concatenation of strings constructed from the specified |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Same as the primary |
|
Perform a lexicographic three‐way comparison of the specified |
|
Perform a lexicographic three‐way comparison of the specified |
|
Perform a lexicographic three‐way comparison of the specified |
|
Return |
|
Same as the two‐argument |
|
Same as the two‐argument |
|
Return an object, containing quoted version of the specified |
|
Return an object, containing quoted version of the specified |
|
Exchange the value of the specified |
|
|
Return the concatenation of the specified |
|
Return a |
|
Return the concatenation of the specified C string and string ref. |
|
Return the concatenation of the specified |
|
Return the concatenation of the specified |
|
Return the concatenation of the specified string ref and C string. |
|
Return the concatenation of the specified |
Created with MrDocs