![]() |
Home | Libraries | People | FAQ | More |
boost::container::basic_string
// In header: <boost/container/string.hpp> template<typename CharT, typename Traits = CharT>, typename Allocator = void> class basic_string : private { public: // types typedef Traits ; typedef CharT ; typedef real_allocator< CharT, Allocator >:: ; typedef ::boost::container::allocator_traits< ; typedef ::boost::container::allocator_traits< ; typedef ::boost::container::allocator_traits< ; typedef ::boost::container::allocator_traits< ; typedef ::boost::container::allocator_traits< ; typedef ::boost::container::allocator_traits< ; typedef implementation_defined ; typedef implementation_defined ; typedef implementation_defined ; typedef implementation_defined ; typedef implementation_defined ; // construct/copy/destruct () ; (const ) ; (const basic_string &); template< BasicStringView> (BasicStringView< CharT, Traits >, const = ); (basic_string &&) ; (const basic_string &, const ); (basic_string &&, const ); (const basic_string &, , = ); (const basic_string &, , , const ); (const CharT *, ); (const CharT *, , const ); (const CharT *); (const CharT *, const ); (, CharT); (, CharT, const ); (, default_init_t); (, default_init_t, const ); template<typename InputIterator> (InputIterator, InputIterator); template<typename InputIterator> (InputIterator, InputIterator, const ); (value_type >, const = ); basic_string & (const basic_string &); basic_string & (basic_string &&) ; basic_string & (const CharT *); basic_string & (CharT); template< BasicStringView> basic_string & (BasicStringView< CharT, Traits >); basic_string & (CharT >); ~(); // public member functions () ; stored_allocator_type & () ; const stored_allocator_type & () ; iterator () ; const_iterator () ; iterator () ; const_iterator () ; reverse_iterator () ; const_reverse_iterator () ; reverse_iterator () ; const_reverse_iterator () ; const_iterator () ; const_iterator () ; const_reverse_iterator () ; const_reverse_iterator () ; bool () ; () ; () ; () ; void (, CharT); void (); void (, default_init_t); () ; void (); void (); reference () ; const_reference () ; reference () ; const_reference () ; reference () ; const_reference () ; reference (); const_reference () ; basic_string & (const basic_string &); template< BasicStringView> basic_string & (BasicStringView< CharT, Traits >); basic_string & (const CharT *); basic_string & (CharT); basic_string & (CharT >); basic_string & (const basic_string &); template< BasicStringView> basic_string & (BasicStringView< CharT, Traits >); basic_string & (const basic_string &, , = ); basic_string & (const CharT *, ); basic_string & (const CharT *); basic_string & (, CharT); template<typename InputIter> basic_string & (InputIter, InputIter); basic_string & (CharT >); void (CharT); basic_string & (const basic_string &); template< BasicStringView> basic_string & (BasicStringView< CharT, Traits >); basic_string & (basic_string &&) ; basic_string & (const basic_string &, , ); basic_string & (const CharT *, ); basic_string & (const CharT *); basic_string & (, CharT); basic_string & (const CharT *, const CharT *); template<typename InputIter> basic_string & (InputIter, InputIter); basic_string & (CharT >); basic_string & (, const basic_string &); basic_string & (, const basic_string &, , = ); basic_string & (, const CharT *, ); basic_string & (, const CharT *); basic_string & (, , CharT); template< BasicStringView> basic_string & (, BasicStringView< CharT, Traits >); iterator (const_iterator, CharT); iterator (const_iterator, , CharT); template<typename InputIter> iterator (const_iterator, InputIter, InputIter); iterator (const_iterator, CharT >); void () ; basic_string & ( = , = ); iterator (const_iterator) ; iterator (const_iterator, const_iterator) ; void () ; basic_string & (, , const basic_string &); template< BasicStringView> basic_string & (, , BasicStringView< CharT, Traits >); basic_string & (, , const basic_string &, , = ); template< BasicStringView> basic_string & (, , BasicStringView< CharT, Traits >, , = ); basic_string & (, , const CharT *, ); basic_string & (, , const CharT *); basic_string & (, , , CharT); basic_string & (const_iterator, const_iterator, const basic_string &); basic_string & (const_iterator, const_iterator, const CharT *, ); basic_string & (const_iterator, const_iterator, const CharT *); basic_string & (const_iterator, const_iterator, , CharT); template<typename InputIter> basic_string & (const_iterator, const_iterator, InputIter, InputIter); template< BasicStringView> basic_string & (const_iterator, const_iterator, BasicStringView< CharT, Traits >); basic_string & (const_iterator, const_iterator, CharT >); (CharT *, , = ) ; void (basic_string &) ; const CharT * () ; const CharT * () ; CharT * () ; template< BasicStringView> () ; template<typename BasicStringView> BasicStringView () ; (const basic_string &, = ) ; template< BasicStringView> (BasicStringView< CharT, Traits >, = ) ; (const CharT *, , ) ; (const CharT *, = ) ; (CharT, = ) ; (const basic_string &, = ) ; template< BasicStringView> (BasicStringView< CharT, Traits >, = ) ; (const CharT *, , ) ; (const CharT *, = ) ; (CharT, = ) ; (const basic_string &, = ) ; template< BasicStringView> (BasicStringView< CharT, Traits >, = ) ; (const CharT *, , ) ; (const CharT *, = ) ; (CharT, = ) ; (const basic_string &, = ) ; template< BasicStringView> (BasicStringView< CharT, Traits >, = ) ; (const CharT *, , ) ; (const CharT *, = ) ; (CharT, = ) ; (const basic_string &, = ) ; template< BasicStringView> (BasicStringView< CharT, Traits >, = ) ; (const CharT *, , ) ; (const CharT *, = ) ; (CharT, = ) ; (const basic_string &, = ) ; template< BasicStringView> (BasicStringView< CharT, Traits >, = ) ; (const CharT *, , ) ; (const CharT *, = ) ; (CharT, = ) ; basic_string ( = , = ) ; int (const basic_string &) ; template< BasicStringView> int (BasicStringView< CharT, Traits >) ; int (, , const basic_string &) ; template< BasicStringView> int (, , BasicStringView< CharT, Traits >) ; int (, , const basic_string &, , = ) ; template< BasicStringView> int (, , BasicStringView< CharT, Traits >, , ) ; int (const CharT *) ; int (, , const CharT *, ) ; int (, , const CharT *) ; // public data members static const npos; };
The basic_string class represents a Sequence of characters. It contains all the usual operations of a Sequence, and, additionally, it contains standard string operations such as search and concatenation.
The basic_string class is parameterized by character type, and by that type's Character Traits.
This class has performance characteristics very much like vector<>, meaning, for example, that it does not perform reference-count or copy-on-write, and that concatenation of two strings is an O(N) operation.
Some of basic_string's member functions use an unusual method of specifying positions and ranges. In addition to the conventional method using iterators, many of basic_string's member functions use a single value pos of type size_type to represent a position (in which case the position is begin() + pos, and many of basic_string's member functions use two values, pos and n, to represent a range. In that case pos is the beginning of the range and n is its size. That is, the range is [begin() + pos, begin() + pos + n).
Note that the C++ standard does not specify the complexity of basic_string operations. In this implementation, basic_string has performance characteristics very similar to those of vector: access to a single character is O(1), while copy and concatenation are O(N).
In this implementation, begin(), end(), rbegin(), rend(), operator[], c_str(), and data() do not invalidate iterators. In this implementation, iterators are only invalidated by member functions that explicitly change the string's contents.
basic_string
public
construct/copy/destruct() ;
Effects: Default constructs a basic_string
.
Throws: If allocator_type's default constructor throws.
(const a) ;
Effects: Constructs a basic_string
taking the allocator as parameter.
Throws: Nothing
(const basic_string & s);
Effects: Copy constructs a basic_string
.
Postcondition: x == *this.
Throws: If allocator_type's default constructor or allocation throws.
template< BasicStringView> (BasicStringView< CharT, Traits > sv, const a = );
Effects: Same as basic_string
(sv.data(), sv.size(), a).
Throws: If allocator_type's default constructor or allocation throws.
(basic_string && s) ;
Effects: Move constructor. Moves s's resources to *this.
Throws: Nothing.
Complexity: Constant.
(const basic_string & s, const a);
Effects: Copy constructs a basic_string
using the specified allocator.
Postcondition: x == *this.
Throws: If allocation throws.
(basic_string && s, const a);
Effects: Move constructor using the specified allocator. Moves s's resources to *this.
Throws: If allocation throws.
Complexity: Constant if a == s.get_allocator(), linear otherwise.
(const basic_string & s, pos, n = );
Effects: Constructs a basic_string
with a default-constructed allocator, and is initialized by a specific number of characters of the s string.
(const basic_string & s, pos, n, const a);
Effects: Constructs a basic_string
taking the allocator as parameter, and is initialized by a specific number of characters of the s string.
(const CharT * s, n);
Effects: Constructs a basic_string
taking a default-constructed allocator, and is initialized by a specific number of characters of the s c-string.
(const CharT * s, n, const a);
Effects: Constructs a basic_string
taking the allocator as parameter, and is initialized by a specific number of characters of the s c-string.
(const CharT * s);
Effects: Constructs a basic_string
with a default-constructed allocator, and is initialized by the null-terminated s c-string.
(const CharT * s, const a);
Effects: Constructs a basic_string
taking the allocator as parameter, and is initialized by the null-terminated s c-string.
( n, CharT c);
Effects: Constructs a basic_string
with a default-constructed allocator, and is initialized by n copies of c.
( n, CharT c, const a);
Effects: Constructs a basic_string
taking the allocator as parameter, and is initialized by n copies of c.
( n, default_init_t);
Effects: Constructs a basic_string
with a default-constructed allocator, and is initialized by n default-initialized characters.
( n, default_init_t, const a);
Effects: Constructs a basic_string
taking the allocator as parameter, and is initialized by n default-initialized characters.
template<typename InputIterator> (InputIterator f, InputIterator l);
Effects: Constructs a basic_string
with a default-constructed allocator, and a range of iterators.
template<typename InputIterator> (InputIterator f, InputIterator l, const a);
Effects: Constructs a basic_string
taking the allocator as parameter, and a range of iterators.
(value_type > il, const a = );
Effects: Same as basic_string
(il.begin(), il.end(), a).
basic_string & (const basic_string & x);
Effects: Copy constructs a string.
Postcondition: x == *this.
Complexity: Linear to the elements x contains.
basic_string & (basic_string && x) ;
Effects: Move constructor. Moves x's resources to *this.
Throws: If allocator_traits_type::propagate_on_container_move_assignment is false and allocation throws
Complexity: Constant if allocator_traits_type:: propagate_on_container_move_assignment is true or this->get>allocator() == x.get_allocator(). Linear otherwise.
basic_string & (const CharT * s);
Effects: Assignment from a null-terminated c-string.
basic_string & (CharT c);
Effects: Returns *this = basic_string(1, c).
template< BasicStringView> basic_string & (BasicStringView< CharT, Traits > sv);
Effects: Equivalent to return assign(sv).
basic_string & (CharT > il);
Effects: Returns *this = basic_string(il);
~();
Effects: Destroys the basic_string
. All used memory is deallocated.
Throws: Nothing.
Complexity: Constant.
basic_string
public member functions() ;
Effects: Returns a copy of the internal allocator.
Throws: If allocator's copy constructor throws.
Complexity: Constant.
stored_allocator_type & () ;
Effects: Returns a reference to the internal allocator.
Throws: Nothing
Complexity: Constant.
Note: Non-standard extension.
const stored_allocator_type & () ;
Effects: Returns a reference to the internal allocator.
Throws: Nothing
Complexity: Constant.
Note: Non-standard extension.
iterator () ;
Effects: Returns an iterator to the first element contained in the vector.
Throws: Nothing.
Complexity: Constant.
const_iterator () ;
Effects: Returns a const_iterator to the first element contained in the vector.
Throws: Nothing.
Complexity: Constant.
iterator () ;
Effects: Returns an iterator to the end of the vector.
Throws: Nothing.
Complexity: Constant.
const_iterator () ;
Effects: Returns a const_iterator to the end of the vector.
Throws: Nothing.
Complexity: Constant.
reverse_iterator () ;
Effects: Returns a reverse_iterator pointing to the beginning of the reversed vector.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator () ;
Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector.
Throws: Nothing.
Complexity: Constant.
reverse_iterator () ;
Effects: Returns a reverse_iterator pointing to the end of the reversed vector.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator () ;
Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector.
Throws: Nothing.
Complexity: Constant.
const_iterator () ;
Effects: Returns a const_iterator to the first element contained in the vector.
Throws: Nothing.
Complexity: Constant.
const_iterator () ;
Effects: Returns a const_iterator to the end of the vector.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator () ;
Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator () ;
Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector.
Throws: Nothing.
Complexity: Constant.
bool () ;
Effects: Returns true if the vector contains no elements.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns the number of the elements contained in the vector.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns the number of the elements contained in the vector.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns the largest possible size of the vector.
Throws: Nothing.
Complexity: Constant
void ( n, CharT c);
Effects: Inserts or erases elements at the end such that the size becomes n. New elements are copy constructed from x.
Throws: If memory allocation throws
Complexity: Linear to the difference between size() and new_size.
void ( n);
Effects: Inserts or erases elements at the end such that the size becomes n. New elements are value initialized.
Throws: If memory allocation throws
Complexity: Linear to the difference between size() and new_size.
void ( n, default_init_t);
Effects: Inserts or erases elements at the end such that the size becomes n. New elements are uninitialized.
Throws: If memory allocation throws
Complexity: Linear to the difference between size() and new_size.
Note: Non-standard extension
() ;
Effects: Number of elements for which memory has been allocated. capacity() is always greater than or equal to size().
Throws: Nothing.
Complexity: Constant.
void ( res_arg);
Effects: If n is less than or equal to capacity(), this call has no effect. Otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
Throws: If memory allocation allocation throws
void ();
Effects: Tries to deallocate the excess of memory created with previous allocations. The size of the string is unchanged
Throws: Nothing
Complexity: Linear to size().
reference () ;
Requires: !empty()
Effects: Returns a reference to the first element of the container.
Throws: Nothing.
Complexity: Constant.
const_reference () ;
Requires: !empty()
Effects: Returns a const reference to the first element of the container.
Throws: Nothing.
Complexity: Constant.
reference () ;
Requires: !empty()
Effects: Returns a reference to the last element of the container.
Throws: Nothing.
Complexity: Constant.
const_reference () ;
Requires: !empty()
Effects: Returns a const reference to the last element of the container.
Throws: Nothing.
Complexity: Constant.
reference ( n) ;
Requires: size() > n.
Effects: Returns a reference to the nth element from the beginning of the container.
Throws: Nothing.
Complexity: Constant.
const_reference ( n) ;
Requires: size() > n.
Effects: Returns a const reference to the nth element from the beginning of the container.
Throws: Nothing.
Complexity: Constant.
reference ( n);
Requires: size() > n.
Effects: Returns a reference to the nth element from the beginning of the container.
Throws: range_error if n >= size()
Complexity: Constant.
const_reference ( n) ;
Requires: size() > n.
Effects: Returns a const reference to the nth element from the beginning of the container.
Throws: range_error if n >= size()
Complexity: Constant.
basic_string & (const basic_string & s);
Effects: Calls append(str.data, str.size()).
Returns: *this
template< BasicStringView> basic_string & (BasicStringView< CharT, Traits > sv);
Effects: Same as return append(sv)
.
basic_string & (const CharT * s);
Effects: Calls append(s).
Returns: *this
basic_string & (CharT c);
Effects: Calls append(1, c).
Returns: *this
basic_string & (CharT > il);
Effects: Returns append(il)
basic_string & (const basic_string & s);
Effects: Calls append(str.data(), str.size()).
Returns: *this
template< BasicStringView> basic_string & (BasicStringView< CharT, Traits > sv);
Effects: Same as return append(sv.data(), sv.size()).
basic_string & (const basic_string & s, pos, n = );
Requires: pos <= str.size()
Effects: Determines the effective length rlen of the string to append as the smaller of n and str.size() - pos and calls append(str.data() + pos, rlen).
Throws: If memory allocation throws and out_of_range
if pos > str.size()
Returns: *this
basic_string & (const CharT * s, n);
Requires: s points to an array of at least n elements of CharT.
Effects: The function replaces the string controlled by *this with a string of length size() + n whose irst size() elements are a copy of the original string controlled by *this and whose remaining elements are a copy of the initial n elements of s.
Throws: If memory allocation throws length_error
if size() + n > max_size().
Returns: *this
basic_string & (const CharT * s);
Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
Effects: Calls append(s, traits::length(s)).
Returns: *this
basic_string & ( n, CharT c);
Effects: Equivalent to append(basic_string(n, c)).
Returns: *this
template<typename InputIter> basic_string & (InputIter first, InputIter last);
Requires: [first,last) is a valid range.
Effects: Equivalent to append(basic_string(first, last)).
Returns: *this
basic_string & (CharT > il);
Effects: Returns append(il.begin(), il.size()).
void (CharT c);
Effects: Equivalent to append(static_cast<size_type>(1), c).
basic_string & (const basic_string & s);
Effects: Equivalent to assign(str, 0, npos).
Returns: *this
template< BasicStringView> basic_string & (BasicStringView< CharT, Traits > sv);
Effects: Equivalent to return assign(sv.data(), sv.size()).
Returns: *this
basic_string & (basic_string && ms) ;
Effects: The function replaces the string controlled by *this with a string of length str.size() whose elements are a copy of the string controlled by str. Leaves str in a valid but unspecified state.
Throws: Nothing
Returns: *this
basic_string & (const basic_string & s, pos, n);
Requires: pos <= str.size()
Effects: Determines the effective length rlen of the string to assign as the smaller of n and str.size() - pos and calls assign(str.data() + pos rlen).
Throws: If memory allocation throws or out_of_range
if pos > str.size().
Returns: *this
basic_string & (const CharT * s, n);
Requires: s points to an array of at least n elements of CharT.
Effects: Replaces the string controlled by *this with a string of length n whose elements are a copy of those pointed to by s.
Throws: If memory allocation throws or length_error
if n > max_size().
Returns: *this
basic_string & (const CharT * s);
Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
Effects: Calls assign(s, traits::length(s)).
Returns: *this
basic_string & ( n, CharT c);
Effects: Equivalent to assign(basic_string(n, c)).
Returns: *this
basic_string & (const CharT * first, const CharT * last);
Effects: Equivalent to assign(basic_string(first, last)). Returns: *this
template<typename InputIter> basic_string & (InputIter first, InputIter last);
Effects: Equivalent to assign(basic_string(first, last)).
Returns: *this
basic_string & (CharT > il);
Effects: Returns assign(il.begin(), il.size()).
basic_string & ( pos, const basic_string & s);
Requires: pos <= size().
Effects: Calls insert(pos, str.data(), str.size()).
Throws: If memory allocation throws or out_of_range
if pos > size().
Returns: *this
basic_string & ( pos1, const basic_string & s, pos2, n = );
Requires: pos1 <= size() and pos2 <= str.size()
Effects: Determines the effective length rlen of the string to insert as the smaller of n and str.size() - pos2 and calls insert(pos1, str.data() + pos2, rlen).
Throws: If memory allocation throws or out_of_range
if pos1 > size() or pos2 > str.size().
Returns: *this
basic_string & ( pos, const CharT * s, n);
Requires: s points to an array of at least n elements of CharT and pos <= size().
Effects: Replaces the string controlled by *this with a string of length size() + n whose first pos elements are a copy of the initial elements of the original string controlled by *this and whose next n elements are a copy of the elements in s and whose remaining elements are a copy of the remaining elements of the original string controlled by *this.
Throws: If memory allocation throws, out_of_range
if pos > size() or length_error
if size() + n > max_size().
Returns: *this
basic_string & ( pos, const CharT * s);
Requires: pos <= size() and s points to an array of at least traits::length(s) + 1 elements of CharT
Effects: Calls insert(pos, s, traits::length(s)).
Throws: If memory allocation throws, out_of_range
if pos > size() length_error
if size() > max_size() - Traits::length(s)
Returns: *this
basic_string & ( pos, n, CharT c);
Effects: Equivalent to insert(pos, basic_string(n, c)).
Throws: If memory allocation throws, out_of_range
if pos > size() length_error
if size() > max_size() - n
Returns: *this
template< BasicStringView> basic_string & ( pos, BasicStringView< CharT, Traits > sv);
Effects: Same as return insert(pos, sv.data(), sv.size())
.
iterator (const_iterator p, CharT c);
Requires: p is a valid iterator on *this.
Effects: inserts a copy of c before the character referred to by p.
Returns: An iterator which refers to the copy of the inserted character.
iterator (const_iterator p, n, CharT c);
Requires: p is a valid iterator on *this.
Effects: Inserts n copies of c before the character referred to by p.
Returns: an iterator to the first inserted element or p if n is 0.
template<typename InputIter> iterator (const_iterator p, InputIter first, InputIter last);
Requires: p is a valid iterator on *this. [first,last) is a valid range.
Effects: Equivalent to insert(p - begin(), basic_string(first, last)).
Returns: an iterator to the first inserted element or p if first == last.
iterator (const_iterator p, CharT > il);
Effects: As if by insert(p, il.begin(), il.end()).
Returns: An iterator which refers to the copy of the first inserted character, or p if i1 is empty.
void () ;
Effects: Removes the last element from the container.
Throws: Nothing.
Complexity: Constant time.
basic_string & ( pos = , n = );
Requires: pos <= size()
Effects: Determines the effective length xlen of the string to be removed as the smaller of n and size() - pos. The function then replaces the string controlled by *this with a string of length size() - xlen whose first pos elements are a copy of the initial elements of the original string controlled by *this, and whose remaining elements are a copy of the elements of the original string controlled by *this beginning at position pos + xlen.
Throws: out_of_range
if pos > size().
Returns: *this
iterator (const_iterator p) ;
Effects: Removes the character referred to by p.
Throws: Nothing
Returns: An iterator which points to the element immediately following p prior to the element being erased. If no such element exists, end() is returned.
iterator (const_iterator first, const_iterator last) ;
Requires: first and last are valid iterators on *this, defining a range [first,last).
Effects: Removes the characters in the range [first,last).
Throws: Nothing
Returns: An iterator which points to the element pointed to by last prior to the other elements being erased. If no such element exists, end() is returned.
void () ;
Effects: Erases all the elements of the vector.
Throws: Nothing.
Complexity: Linear to the number of elements in the vector.
basic_string & ( pos1, n1, const basic_string & str);
Requires: pos1 <= size().
Effects: Calls replace(pos1, n1, str.data(), str.size()).
Throws: if memory allocation throws or out_of_range
if pos1 > size().
Returns: *this
template< BasicStringView> basic_string & ( pos1, n1, BasicStringView< CharT, Traits > sv);
Effects: Calls return replace(pos1, n1, sv.data(), sv.size());
.
basic_string & ( pos1, n1, const basic_string & str, pos2, n2 = );
Requires: pos1 <= size() and pos2 <= str.size().
Effects: Determines the effective length rlen of the string to be inserted as the smaller of n2 and str.size() - pos2 and calls replace(pos1, n1, str.data() + pos2, rlen).
Throws: if memory allocation throws, out_of_range
if pos1 > size() or pos2 > str.size().
Returns: *this
template< BasicStringView> basic_string & ( pos1, n1, BasicStringView< CharT, Traits > sv, pos2, n2 = );
Throws: out_of_range
if pos1 > size() or pos2 > sv.size().
Effects: Determines the effective length rlen of the string to be inserted as the smaller of n2 and sv.size() - pos2 and calls replace(pos1, n1, sv.data() + pos2, rlen)
.
Returns: *this.
basic_string & ( pos1, n1, const CharT * s, n2);
Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT.
Effects: Determines the effective length xlen of the string to be removed as the smaller of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error
. Otherwise, the function replaces the string controlled by *this with a string of length size() - xlen + n2 whose first pos1 elements are a copy of the initial elements of the original string controlled by *this, whose next n2 elements are a copy of the initial n2 elements of s, and whose remaining elements are a copy of the elements of the original string controlled by *this beginning at position pos + xlen.
Throws: if memory allocation throws, out_of_range
if pos1 > size() or length_error
if the length of the resulting string would exceed max_size()
Returns: *this
basic_string & ( pos, n1, const CharT * s);
Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT.
Effects: Determines the effective length xlen of the string to be removed as the smaller of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error
. Otherwise, the function replaces the string controlled by *this with a string of length size() - xlen + n2 whose first pos1 elements are a copy of the initial elements of the original string controlled by *this, whose next n2 elements are a copy of the initial n2 elements of s, and whose remaining elements are a copy of the elements of the original string controlled by *this beginning at position pos + xlen.
Throws: if memory allocation throws, out_of_range
if pos1 > size() or length_error
if the length of the resulting string would exceed max_size()
Returns: *this
basic_string & ( pos1, n1, n2, CharT c);
Requires: pos1 <= size().
Effects: Equivalent to replace(pos1, n1, basic_string(n2, c)).
Throws: if memory allocation throws, out_of_range
if pos1 > size() or length_error
if the length of the resulting string would exceed max_size()
Returns: *this
basic_string & (const_iterator i1, const_iterator i2, const basic_string & str);
Requires: [begin(),i1) and [i1,i2) are valid ranges.
Effects: Calls replace(i1 - begin(), i2 - i1, str).
Throws: if memory allocation throws
Returns: *this
basic_string & (const_iterator i1, const_iterator i2, const CharT * s, n);
Requires: [begin(),i1) and [i1,i2) are valid ranges and s points to an array of at least n elements
Effects: Calls replace(i1 - begin(), i2 - i1, s, n).
Throws: if memory allocation throws
Returns: *this
basic_string & (const_iterator i1, const_iterator i2, const CharT * s);
Requires: [begin(),i1) and [i1,i2) are valid ranges and s points to an array of at least traits::length(s) + 1 elements of CharT.
Effects: Calls replace(i1 - begin(), i2 - i1, s, traits::length(s)).
Throws: if memory allocation throws
Returns: *this
basic_string & (const_iterator i1, const_iterator i2, n, CharT c);
Requires: [begin(),i1) and [i1,i2) are valid ranges.
Effects: Calls replace(i1 - begin(), i2 - i1, basic_string(n, c)).
Throws: if memory allocation throws
Returns: *this
template<typename InputIter> basic_string & (const_iterator i1, const_iterator i2, InputIter j1, InputIter j2);
Requires: [begin(),i1), [i1,i2) and [j1,j2) are valid ranges.
Effects: Calls replace(i1 - begin(), i2 - i1, basic_string(j1, j2)).
Throws: if memory allocation throws
Returns: *this
template< BasicStringView> basic_string & (const_iterator i1, const_iterator i2, BasicStringView< CharT, Traits > sv);
Requires: [begin(), i1) and [i1, i2) are valid ranges.
Effects: Calls replace(i1 - begin(), i2 - i1, sv).
.
Returns: *this.
basic_string & (const_iterator i1, const_iterator i2, CharT > il);
Requires: [begin(), i1) and [i1, i2) are valid ranges.
Effects: Calls replace(i1 - begin(), i2 - i1, il.begin(), il.size()).
Returns: *this.
(CharT * s, n, pos = ) ;
Requires: pos <= size()
Effects: Determines the effective length rlen of the string to copy as the smaller of n and size() - pos. s shall designate an array of at least rlen elements. The function then replaces the string designated by s with a string of length rlen whose elements are a copy of the string controlled by *this beginning at position pos. The function does not append a null object to the string designated by s.
Throws: if memory allocation throws, out_of_range
if pos > size().
Returns: rlen
void (basic_string & x) ;
Effects: *this contains the same sequence of characters that was in s, s contains the same sequence of characters that was in *this.
Throws: Nothing
const CharT * () ;
Requires: The program shall not alter any of the values stored in the character array.
Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
Complexity: constant time.
const CharT * () ;
Requires: The program shall not alter any of the values stored in the character array.
Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
Complexity: constant time.
CharT * () ;
Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
Complexity: constant time.
template< BasicStringView> () ;
Returns: a string_view to the characters in the string.
Complexity: constant time.
template<typename BasicStringView> BasicStringView () ;
Returns: a string_view to the characters in the string.
Complexity: constant time.
Note: This function is available to write portable code for compilers that don't support templated conversion operators.
(const basic_string & s, pos = ) ;
Effects: Determines the lowest position xpos, if possible, such that both of the following conditions hold: 1) pos <= xpos and xpos + str.size() <= size(); 2) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
template< BasicStringView> (BasicStringView< CharT, Traits > sv, pos = ) ;
Effects: Determines the lowest position xpos, if possible, such that both of the following conditions hold: 1) pos <= xpos and xpos + sv.size() <= size(); 2) traits::eq(at(xpos+I), sv.at(I)) for all elements I of the string controlled by sv.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
(const CharT * s, pos, n) ;
Requires: s points to an array of at least n elements of CharT.
Throws: Nothing
Returns: find(basic_string<CharT,traits,allocator_type>(s,n),pos).
(const CharT * s, pos = ) ;
Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
Throws: Nothing
Returns: find(basic_string(s), pos).
(CharT c, pos = ) ;
Throws: Nothing
Returns: find(basic_string<CharT,traits,allocator_type>(1,c), pos).
(const basic_string & str, pos = ) ;
Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos + str.size() <= size(); b) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
template< BasicStringView> (BasicStringView< CharT, Traits > sv, pos = ) ;
Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos + sv.size() <= size(); b) traits::eq(at(xpos+I), sv.at(I)) for all elements I of the string controlled by sv.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
(const CharT * s, pos, n) ;
Requires: s points to an array of at least n elements of CharT.
Throws: Nothing
Returns: rfind(basic_string(s, n), pos).
(const CharT * s, pos = ) ;
Requires: pos <= size() and s points to an array of at least traits::length(s) + 1 elements of CharT.
Throws: Nothing
Returns: rfind(basic_string(s), pos).
(CharT c, pos = ) ;
Throws: Nothing
Returns: rfind(basic_string<CharT,traits,allocator_type>(1,c),pos).
(const basic_string & str, pos = ) ;
Effects: Determines the lowest position xpos, if possible, such that both of the following conditions obtain: a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
template< BasicStringView> (BasicStringView< CharT, Traits > sv, pos = ) ;
Effects: Determines the lowest position xpos, if possible, such that both of the following conditions obtain: a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), sv.at(I)) for some element I of the string controlled by sv.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
(const CharT * s, pos, n) ;
Requires: s points to an array of at least n elements of CharT.
Throws: Nothing
Returns: find_first_of(basic_string(s, n), pos).
(const CharT * s, pos = ) ;
Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
Throws: Nothing
Returns: find_first_of(basic_string(s), pos).
(CharT c, pos = ) ;
Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
Throws: Nothing
Returns: find_first_of(basic_string<CharT,traits,allocator_type>(1,c), pos).
(const basic_string & str, pos = ) ;
Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
template< BasicStringView> (BasicStringView< CharT, Traits > sv, pos = ) ;
Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
(const CharT * s, pos, n) ;
Requires: s points to an array of at least n elements of CharT.
Throws: Nothing
Returns: find_last_of(basic_string(s, n), pos).
(const CharT * s, pos = ) ;
Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
Throws: Nothing
Returns: find_last_of(basic_string<CharT,traits,allocator_type>(1,c),pos).
(CharT c, pos = ) ;
Throws: Nothing
Returns: find_last_of(basic_string(s), pos).
(const basic_string & str, pos = ) ;
Effects: Determines the lowest position xpos, if possible, such that both of the following conditions obtain: a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for no element I of the string controlled by str.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
template< BasicStringView> (BasicStringView< CharT, Traits > sv, pos = ) ;
Effects: Determines the lowest position xpos, if possible, such that both of the following conditions obtain: a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), sv.at(I)) for no element I of the string controlled by sv.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
(const CharT * s, pos, n) ;
Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
Throws: Nothing
Returns: find_first_not_of(basic_string(s, n), pos).
(const CharT * s, pos = ) ;
Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
Throws: Nothing
Returns: find_first_not_of(basic_string(s), pos).
(CharT c, pos = ) ;
Throws: Nothing
Returns: find_first_not_of(basic_string(1, c), pos).
(const basic_string & str, pos = ) ;
Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for no element I of the string controlled by str.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
template< BasicStringView> (BasicStringView< CharT, Traits > sv, pos = ) ;
Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos < size(); b) traits::eq(at(xpos), sv.at(I)) for no element I of the string controlled by sv.
Throws: Nothing
Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
(const CharT * s, pos, n) ;
Requires: s points to an array of at least n elements of CharT.
Throws: Nothing
Returns: find_last_not_of(basic_string(s, n), pos).
(const CharT * s, pos = ) ;
Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.
Throws: Nothing
Returns: find_last_not_of(basic_string(s), pos).
(CharT c, pos = ) ;
Throws: Nothing
Returns: find_last_not_of(basic_string(1, c), pos).
basic_string ( pos = , n = ) ;
Requires: Requires: pos <= size()
Effects: Determines the effective length rlen of the string to copy as the smaller of n and size() - pos.
Throws: If memory allocation throws or out_of_range
if pos > size().
Returns: basic_string<CharT,traits,allocator_type>(data()+pos,rlen).
int (const basic_string & str) ;
Effects: Determines the effective length rlen of the string to compare as the smaller of size() and str.size(). The function then compares the two strings by calling traits::compare(data(), str.data(), rlen).
Throws: Nothing
Returns: The nonzero result if the result of the comparison is nonzero. Otherwise, returns a value < 0 if size() < str.size(), a 0 value if size() == str.size(), and value > 0 if size() > str.size()
template< BasicStringView> int (BasicStringView< CharT, Traits > sv) ;
Throws: Nothing
Returns: compare(basic_string(sv)).
int ( pos1, n1, const basic_string & str) ;
Requires: pos1 <= size()
Effects: Determines the effective length rlen of the string to compare as the smaller of (this->size() - pos1), n1 and str.size(). The function then compares the two strings by calling traits::compare(data()+pos1, str.data(), rlen).
Throws: out_of_range
if pos1 > size()
Returns:basic_string(*this,pos1,n1).compare(str).
template< BasicStringView> int ( pos1, n1, BasicStringView< CharT, Traits > sv) ;
Requires: pos1 <= size()
Throws: out_of_range
if pos1 > size()
Returns:basic_string(*this,pos1,n1).compare(sv).
int ( pos1, n1, const basic_string & str, pos2, n2 = ) ;
Requires: pos1 <= size() and pos2 <= str.size()
Effects: Determines the effective length rlen of the string to copy as the smaller of
Throws: out_of_range
if pos1 > size() or pos2 > str.size()
Returns: basic_string(*this, pos1, n1).compare(basic_string(str, pos2, n2)).
template< BasicStringView> int ( pos1, n1, BasicStringView< CharT, Traits > sv, pos2, n2) ;
Requires: pos1 <= size() and pos2 <= str.size()
Effects: Determines the effective length rlen of the string to copy as the smaller of
Throws: out_of_range
if pos1 > size() or pos2 > sv.size()
Returns: basic_string(*this, pos1, n1).compare(BasicStringView<CharT, Traits>(sv, pos2, n2)).
int (const CharT * s) ;
Throws: Nothing
Returns: compare(basic_string(s)).
int ( pos1, n1, const CharT * s, n2) ;
Requires: pos1 > size() and s points to an array of at least n2 elements of CharT.
Throws: out_of_range
if pos1 > size()
Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)).
int ( pos1, n1, const CharT * s) ;
Requires: pos1 > size() and s points to an array of at least traits::length(s) + 1 elements of CharT.
Throws: out_of_range
if pos1 > size()
Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)).