1 // Components for manipulating sequences of characters -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
32 // ISO C++ 14882: 21 Strings library
35 /** @file basic_string.h
36 * This is an internal header file, included by other library headers.
37 * You should not attempt to use it directly.
40 #ifndef _BASIC_STRING_H
41 #define _BASIC_STRING_H 1
43 #pragma GCC system_header
45 #include <bits/atomicity.h>
46 #include <debug/debug.h>
51 * @class basic_string basic_string.h <string>
52 * @brief Managing sequences of characters and character-like objects.
57 * Meets the requirements of a <a href="tables.html#65">container</a>, a
58 * <a href="tables.html#66">reversible container</a>, and a
59 * <a href="tables.html#67">sequence</a>. Of the
60 * <a href="tables.html#68">optional sequence requirements</a>, only
61 * @c push_back, @c at, and array access are supported.
67 * Documentation? What's that?
68 * Nathan Myers <ncm@cantrip.org>.
70 * A string looks like this:
75 * [basic_string<char_type>] _M_capacity
76 * _M_dataplus _M_refcount
77 * _M_p ----------------> unnamed array of char_type
80 * Where the _M_p points to the first character in the string, and
81 * you cast it to a pointer-to-_Rep and subtract 1 to get a
82 * pointer to the header.
84 * This approach has the enormous advantage that a string object
85 * requires only one allocation. All the ugliness is confined
86 * within a single pair of inline functions, which each compile to
87 * a single "add" instruction: _Rep::_M_data(), and
88 * string::_M_rep(); and the allocation function which gets a
89 * block of raw bytes and with room enough and constructs a _Rep
90 * object at the front.
92 * The reason you want _M_data pointing to the character array and
93 * not the _Rep is so that the debugger can see the string
94 * contents. (Probably we should add a non-inline member to get
95 * the _Rep for the debugger to use, so users can check the actual
98 * Note that the _Rep object is a POD so that you can have a
99 * static "empty string" _Rep object already "constructed" before
100 * static constructors have run. The reference-count encoding is
101 * chosen so that a 0 indicates one reference, so you never try to
102 * destroy the empty-string _Rep object.
104 * All but the last paragraph is considered pretty conventional
105 * for a C++ string implementation.
108 // 21.3 Template class basic_string
109 template<typename _CharT, typename _Traits, typename _Alloc>
114 typedef _Traits traits_type;
115 typedef typename _Traits::char_type value_type;
116 typedef _Alloc allocator_type;
117 typedef typename _Alloc::size_type size_type;
118 typedef typename _Alloc::difference_type difference_type;
119 typedef typename _Alloc::reference reference;
120 typedef typename _Alloc::const_reference const_reference;
121 typedef typename _Alloc::pointer pointer;
122 typedef typename _Alloc::const_pointer const_pointer;
123 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
124 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
126 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
127 typedef std::reverse_iterator<iterator> reverse_iterator;
130 // _Rep: string representation
132 // 1. String really contains _M_length + 1 characters: due to 21.3.4
133 // must be kept null-terminated.
134 // 2. _M_capacity >= _M_length
135 // Allocated memory is always (_M_capacity + 1) * sizeof(_CharT).
136 // 3. _M_refcount has three states:
137 // -1: leaked, one reference, no ref-copies allowed, non-const.
138 // 0: one reference, non-const.
139 // n>0: n + 1 references, operations require a lock, const.
140 // 4. All fields==0 is an empty string, given the extra storage
141 // beyond-the-end for a null terminator; thus, the shared
142 // empty string representation needs no constructor.
147 size_type _M_capacity;
148 _Atomic_word _M_refcount;
151 struct _Rep : _Rep_base
154 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
156 // (Public) Data members:
158 // The maximum number of individual char_type elements of an
159 // individual string is determined by _S_max_size. This is the
160 // value that will be returned by max_size(). (Whereas npos
161 // is the maximum number of bytes the allocator can allocate.)
162 // If one was to divvy up the theoretical largest size string,
163 // with a terminating character and m _CharT elements, it'd
165 // npos = sizeof(_Rep) + (m * sizeof(_CharT)) + sizeof(_CharT)
167 // m = ((npos - sizeof(_Rep))/sizeof(CharT)) - 1
168 // In addition, this implementation quarters this amount.
169 static const size_type _S_max_size;
170 static const _CharT _S_terminal;
172 // The following storage is init'd to 0 by the linker, resulting
173 // (carefully) in an empty string with one reference.
174 static size_type _S_empty_rep_storage[];
178 { return *reinterpret_cast<_Rep*>(&_S_empty_rep_storage); }
182 { return this->_M_refcount < 0; }
186 { return this->_M_refcount > 0; }
190 { this->_M_refcount = -1; }
194 { this->_M_refcount = 0; }
198 { return reinterpret_cast<_CharT*>(this + 1); }
201 _M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2)
203 return (!_M_is_leaked() && __alloc1 == __alloc2)
204 ? _M_refcopy() : _M_clone(__alloc1);
209 _S_create(size_type, size_type, const _Alloc&);
212 _M_dispose(const _Alloc& __a)
214 #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
215 if (__builtin_expect(this != &_S_empty_rep(), false))
217 if (__gnu_cxx::__exchange_and_add(&this->_M_refcount, -1) <= 0)
222 _M_destroy(const _Alloc&) throw();
227 #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
228 if (__builtin_expect(this != &_S_empty_rep(), false))
230 __gnu_cxx::__atomic_add(&this->_M_refcount, 1);
235 _M_clone(const _Alloc&, size_type __res = 0);
238 // Use empty-base optimization: http://www.cantrip.org/emptyopt.html
239 struct _Alloc_hider : _Alloc
241 _Alloc_hider(_CharT* __dat, const _Alloc& __a)
242 : _Alloc(__a), _M_p(__dat) { }
244 _CharT* _M_p; // The actual data.
248 // Data Members (public):
249 // NB: This is an unsigned type, and thus represents the maximum
250 // size that the allocator can hold.
252 /// Value returned by various member functions when they fail.
253 static const size_type npos = static_cast<size_type>(-1);
256 // Data Members (private):
257 mutable _Alloc_hider _M_dataplus;
261 { return _M_dataplus._M_p; }
265 { return (_M_dataplus._M_p = __p); }
269 { return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); }
271 // For the internal use we have functions similar to `begin'/`end'
272 // but they do not call _M_leak.
275 { return iterator(_M_data()); }
279 { return iterator(_M_data() + this->size()); }
282 _M_leak() // for use in begin() & non-const op[]
284 if (!_M_rep()->_M_is_leaked())
289 _M_check(size_type __pos, const char* __s) const
291 if (__pos > this->size())
292 __throw_out_of_range(__N(__s));
296 // NB: _M_limit doesn't check for a bad __pos value.
298 _M_limit(size_type __pos, size_type __off) const
300 const bool __testoff = __off < this->size() - __pos;
301 return __testoff ? __off : this->size() - __pos;
304 // _S_copy_chars is a separate template to permit specialization
305 // to optimize for the common case of pointers as iterators.
306 template<class _Iterator>
308 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
310 for (; __k1 != __k2; ++__k1, ++__p)
311 traits_type::assign(*__p, *__k1); // These types are off.
315 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
316 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
319 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
320 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
323 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
324 { traits_type::copy(__p, __k1, __k2 - __k1); }
327 _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
328 { traits_type::copy(__p, __k1, __k2 - __k1); }
331 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
338 { return _Rep::_S_empty_rep(); }
341 // Construct/copy/destroy:
342 // NB: We overload ctors in some cases instead of using default
343 // arguments, per 17.4.4.4 para. 2 item 2.
346 * @brief Default constructor creates an empty string.
352 * @brief Construct an empty string using allocator a.
355 basic_string(const _Alloc& __a);
357 // NB: per LWG issue 42, semantics different from IS:
359 * @brief Construct string with copy of value of @a str.
360 * @param str Source string.
362 basic_string(const basic_string& __str);
364 * @brief Construct string as copy of a substring.
365 * @param str Source string.
366 * @param pos Index of first character to copy from.
367 * @param n Number of characters to copy (default remainder).
369 basic_string(const basic_string& __str, size_type __pos,
370 size_type __n = npos);
372 * @brief Construct string as copy of a substring.
373 * @param str Source string.
374 * @param pos Index of first character to copy from.
375 * @param n Number of characters to copy.
376 * @param a Allocator to use.
378 basic_string(const basic_string& __str, size_type __pos,
379 size_type __n, const _Alloc& __a);
382 * @brief Construct string initialized by a character array.
383 * @param s Source character array.
384 * @param n Number of characters to copy.
385 * @param a Allocator to use (default is default allocator).
387 * NB: s must have at least n characters, '\0' has no special
390 basic_string(const _CharT* __s, size_type __n,
391 const _Alloc& __a = _Alloc());
393 * @brief Construct string as copy of a C string.
394 * @param s Source C string.
395 * @param a Allocator to use (default is default allocator).
397 basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
399 * @brief Construct string as multiple characters.
400 * @param n Number of characters.
401 * @param c Character to use.
402 * @param a Allocator to use (default is default allocator).
404 basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc());
407 * @brief Construct string as copy of a range.
408 * @param beg Start of range.
409 * @param end End of range.
410 * @param a Allocator to use (default is default allocator).
412 template<class _InputIterator>
413 basic_string(_InputIterator __beg, _InputIterator __end,
414 const _Alloc& __a = _Alloc());
417 * @brief Destroy the string instance.
420 { _M_rep()->_M_dispose(this->get_allocator()); }
423 * @brief Assign the value of @a str to this string.
424 * @param str Source string.
427 operator=(const basic_string& __str)
428 { return this->assign(__str); }
431 * @brief Copy contents of @a s into this string.
432 * @param s Source null-terminated string.
435 operator=(const _CharT* __s)
436 { return this->assign(__s); }
439 * @brief Set value to string of length 1.
440 * @param c Source character.
442 * Assigning to a character makes this string length 1 and
443 * (*this)[0] == @a c.
446 operator=(_CharT __c)
448 this->assign(1, __c);
454 * Returns a read/write iterator that points to the first character in
455 * the %string. Unshares the string.
461 return iterator(_M_data());
465 * Returns a read-only (constant) iterator that points to the first
466 * character in the %string.
470 { return const_iterator(_M_data()); }
473 * Returns a read/write iterator that points one past the last
474 * character in the %string. Unshares the string.
480 return iterator(_M_data() + this->size());
484 * Returns a read-only (constant) iterator that points one past the
485 * last character in the %string.
489 { return const_iterator(_M_data() + this->size()); }
492 * Returns a read/write reverse iterator that points to the last
493 * character in the %string. Iteration is done in reverse element
494 * order. Unshares the string.
498 { return reverse_iterator(this->end()); }
501 * Returns a read-only (constant) reverse iterator that points
502 * to the last character in the %string. Iteration is done in
503 * reverse element order.
505 const_reverse_iterator
507 { return const_reverse_iterator(this->end()); }
510 * Returns a read/write reverse iterator that points to one before the
511 * first character in the %string. Iteration is done in reverse
512 * element order. Unshares the string.
516 { return reverse_iterator(this->begin()); }
519 * Returns a read-only (constant) reverse iterator that points
520 * to one before the first character in the %string. Iteration
521 * is done in reverse element order.
523 const_reverse_iterator
525 { return const_reverse_iterator(this->begin()); }
529 /// Returns the number of characters in the string, not including any
530 /// null-termination.
533 { return _M_rep()->_M_length; }
535 /// Returns the number of characters in the string, not including any
536 /// null-termination.
539 { return _M_rep()->_M_length; }
541 /// Returns the size() of the largest possible %string.
544 { return _Rep::_S_max_size; }
547 * @brief Resizes the %string to the specified number of characters.
548 * @param n Number of characters the %string should contain.
549 * @param c Character to fill any new elements.
551 * This function will %resize the %string to the specified
552 * number of characters. If the number is smaller than the
553 * %string's current size the %string is truncated, otherwise
554 * the %string is extended and new elements are set to @a c.
557 resize(size_type __n, _CharT __c);
560 * @brief Resizes the %string to the specified number of characters.
561 * @param n Number of characters the %string should contain.
563 * This function will resize the %string to the specified length. If
564 * the new size is smaller than the %string's current size the %string
565 * is truncated, otherwise the %string is extended and new characters
566 * are default-constructed. For basic types such as char, this means
570 resize(size_type __n)
571 { this->resize(__n, _CharT()); }
574 * Returns the total number of characters that the %string can hold
575 * before needing to allocate more memory.
579 { return _M_rep()->_M_capacity; }
582 * @brief Attempt to preallocate enough memory for specified number of
584 * @param n Number of characters required.
585 * @throw std::length_error If @a n exceeds @c max_size().
587 * This function attempts to reserve enough memory for the
588 * %string to hold the specified number of characters. If the
589 * number requested is more than max_size(), length_error is
592 * The advantage of this function is that if optimal code is a
593 * necessity and the user can determine the string length that will be
594 * required, the user can reserve the memory in %advance, and thus
595 * prevent a possible reallocation of memory and copying of %string
599 reserve(size_type __res_arg = 0);
602 * Erases the string, making it empty.
606 { _M_mutate(0, this->size(), 0); }
609 * Returns true if the %string is empty. Equivalent to *this == "".
613 { return this->size() == 0; }
617 * @brief Subscript access to the data contained in the %string.
618 * @param n The index of the character to access.
619 * @return Read-only (constant) reference to the character.
621 * This operator allows for easy, array-style, data access.
622 * Note that data access with this operator is unchecked and
623 * out_of_range lookups are not defined. (For checked lookups
627 operator[] (size_type __pos) const
629 _GLIBCXX_DEBUG_ASSERT(__pos <= size());
630 return _M_data()[__pos];
634 * @brief Subscript access to the data contained in the %string.
635 * @param n The index of the character to access.
636 * @return Read/write reference to the character.
638 * This operator allows for easy, array-style, data access.
639 * Note that data access with this operator is unchecked and
640 * out_of_range lookups are not defined. (For checked lookups
641 * see at().) Unshares the string.
644 operator[](size_type __pos)
646 _GLIBCXX_DEBUG_ASSERT(__pos < size());
648 return _M_data()[__pos];
652 * @brief Provides access to the data contained in the %string.
653 * @param n The index of the character to access.
654 * @return Read-only (const) reference to the character.
655 * @throw std::out_of_range If @a n is an invalid index.
657 * This function provides for safer data access. The parameter is
658 * first checked that it is in the range of the string. The function
659 * throws out_of_range if the check fails.
662 at(size_type __n) const
664 if (__n >= this->size())
665 __throw_out_of_range(__N("basic_string::at"));
666 return _M_data()[__n];
670 * @brief Provides access to the data contained in the %string.
671 * @param n The index of the character to access.
672 * @return Read/write reference to the character.
673 * @throw std::out_of_range If @a n is an invalid index.
675 * This function provides for safer data access. The parameter is
676 * first checked that it is in the range of the string. The function
677 * throws out_of_range if the check fails. Success results in
678 * unsharing the string.
684 __throw_out_of_range(__N("basic_string::at"));
686 return _M_data()[__n];
691 * @brief Append a string to this string.
692 * @param str The string to append.
693 * @return Reference to this string.
696 operator+=(const basic_string& __str)
697 { return this->append(__str); }
700 * @brief Append a C string.
701 * @param s The C string to append.
702 * @return Reference to this string.
705 operator+=(const _CharT* __s)
706 { return this->append(__s); }
709 * @brief Append a character.
710 * @param s The character to append.
711 * @return Reference to this string.
714 operator+=(_CharT __c)
715 { return this->append(size_type(1), __c); }
718 * @brief Append a string to this string.
719 * @param str The string to append.
720 * @return Reference to this string.
723 append(const basic_string& __str);
726 * @brief Append a substring.
727 * @param str The string to append.
728 * @param pos Index of the first character of str to append.
729 * @param n The number of characters to append.
730 * @return Reference to this string.
731 * @throw std::out_of_range if @a pos is not a valid index.
733 * This function appends @a n characters from @a str starting at @a pos
734 * to this string. If @a n is is larger than the number of available
735 * characters in @a str, the remainder of @a str is appended.
738 append(const basic_string& __str, size_type __pos, size_type __n);
741 * @brief Append a C substring.
742 * @param s The C string to append.
743 * @param n The number of characters to append.
744 * @return Reference to this string.
747 append(const _CharT* __s, size_type __n);
750 * @brief Append a C string.
751 * @param s The C string to append.
752 * @return Reference to this string.
755 append(const _CharT* __s)
757 __glibcxx_requires_string(__s);
758 return this->append(__s, traits_type::length(__s));
762 * @brief Append multiple characters.
763 * @param n The number of characters to append.
764 * @param c The character to use.
765 * @return Reference to this string.
767 * Appends n copies of c to this string.
770 append(size_type __n, _CharT __c)
771 { return _M_replace_aux(this->size(), size_type(0), __n, __c); }
774 * @brief Append a range of characters.
775 * @param first Iterator referencing the first character to append.
776 * @param last Iterator marking the end of the range.
777 * @return Reference to this string.
779 * Appends characters in the range [first,last) to this string.
781 template<class _InputIterator>
783 append(_InputIterator __first, _InputIterator __last)
784 { return this->replace(_M_iend(), _M_iend(), __first, __last); }
787 * @brief Append a single character.
788 * @param c Character to append.
791 push_back(_CharT __c)
792 { _M_replace_aux(this->size(), size_type(0), size_type(1), __c); }
795 * @brief Set value to contents of another string.
796 * @param str Source string to use.
797 * @return Reference to this string.
800 assign(const basic_string& __str);
803 * @brief Set value to a substring of a string.
804 * @param str The string to use.
805 * @param pos Index of the first character of str.
806 * @param n Number of characters to use.
807 * @return Reference to this string.
808 * @throw std::out_of_range if @a pos is not a valid index.
810 * This function sets this string to the substring of @a str consisting
811 * of @a n characters at @a pos. If @a n is is larger than the number
812 * of available characters in @a str, the remainder of @a str is used.
815 assign(const basic_string& __str, size_type __pos, size_type __n)
816 { return this->assign(__str._M_data()
817 + __str._M_check(__pos, "basic_string::assign"),
818 __str._M_limit(__pos, __n)); }
821 * @brief Set value to a C substring.
822 * @param s The C string to use.
823 * @param n Number of characters to use.
824 * @return Reference to this string.
826 * This function sets the value of this string to the first @a n
827 * characters of @a s. If @a n is is larger than the number of
828 * available characters in @a s, the remainder of @a s is used.
831 assign(const _CharT* __s, size_type __n);
834 * @brief Set value to contents of a C string.
835 * @param s The C string to use.
836 * @return Reference to this string.
838 * This function sets the value of this string to the value of @a s.
839 * The data is copied, so there is no dependence on @a s once the
843 assign(const _CharT* __s)
845 __glibcxx_requires_string(__s);
846 return this->assign(__s, traits_type::length(__s));
850 * @brief Set value to multiple characters.
851 * @param n Length of the resulting string.
852 * @param c The character to use.
853 * @return Reference to this string.
855 * This function sets the value of this string to @a n copies of
859 assign(size_type __n, _CharT __c)
860 { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
863 * @brief Set value to a range of characters.
864 * @param first Iterator referencing the first character to append.
865 * @param last Iterator marking the end of the range.
866 * @return Reference to this string.
868 * Sets value of string to characters in the range [first,last).
870 template<class _InputIterator>
872 assign(_InputIterator __first, _InputIterator __last)
873 { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
876 * @brief Insert multiple characters.
877 * @param p Iterator referencing location in string to insert at.
878 * @param n Number of characters to insert
879 * @param c The character to insert.
880 * @throw std::length_error If new length exceeds @c max_size().
882 * Inserts @a n copies of character @a c starting at the position
883 * referenced by iterator @a p. If adding characters causes the length
884 * to exceed max_size(), length_error is thrown. The value of the
885 * string doesn't change if an error is thrown.
888 insert(iterator __p, size_type __n, _CharT __c)
889 { this->replace(__p, __p, __n, __c); }
892 * @brief Insert a range of characters.
893 * @param p Iterator referencing location in string to insert at.
894 * @param beg Start of range.
895 * @param end End of range.
896 * @throw std::length_error If new length exceeds @c max_size().
898 * Inserts characters in range [beg,end). If adding characters causes
899 * the length to exceed max_size(), length_error is thrown. The value
900 * of the string doesn't change if an error is thrown.
902 template<class _InputIterator>
903 void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
904 { this->replace(__p, __p, __beg, __end); }
907 * @brief Insert value of a string.
908 * @param pos1 Iterator referencing location in string to insert at.
909 * @param str The string to insert.
910 * @return Reference to this string.
911 * @throw std::length_error If new length exceeds @c max_size().
913 * Inserts value of @a str starting at @a pos1. If adding characters
914 * causes the length to exceed max_size(), length_error is thrown. The
915 * value of the string doesn't change if an error is thrown.
918 insert(size_type __pos1, const basic_string& __str)
919 { return this->insert(__pos1, __str, size_type(0), __str.size()); }
922 * @brief Insert a substring.
923 * @param pos1 Iterator referencing location in string to insert at.
924 * @param str The string to insert.
925 * @param pos2 Start of characters in str to insert.
926 * @param n Number of characters to insert.
927 * @return Reference to this string.
928 * @throw std::length_error If new length exceeds @c max_size().
929 * @throw std::out_of_range If @a pos1 > size() or
930 * @a pos2 > @a str.size().
932 * Starting at @a pos1, insert @a n character of @a str beginning with
933 * @a pos2. If adding characters causes the length to exceed
934 * max_size(), length_error is thrown. If @a pos1 is beyond the end of
935 * this string or @a pos2 is beyond the end of @a str, out_of_range is
936 * thrown. The value of the string doesn't change if an error is
940 insert(size_type __pos1, const basic_string& __str,
941 size_type __pos2, size_type __n)
942 { return this->insert(__pos1, __str._M_data()
943 + __str._M_check(__pos2, "basic_string::insert"),
944 __str._M_limit(__pos2, __n)); }
947 * @brief Insert a C substring.
948 * @param pos Iterator referencing location in string to insert at.
949 * @param s The C string to insert.
950 * @param n The number of characters to insert.
951 * @return Reference to this string.
952 * @throw std::length_error If new length exceeds @c max_size().
953 * @throw std::out_of_range If @a pos is beyond the end of this
956 * Inserts the first @a n characters of @a s starting at @a pos. If
957 * adding characters causes the length to exceed max_size(),
958 * length_error is thrown. If @a pos is beyond end(), out_of_range is
959 * thrown. The value of the string doesn't change if an error is
963 insert(size_type __pos, const _CharT* __s, size_type __n);
966 * @brief Insert a C string.
967 * @param pos Iterator referencing location in string to insert at.
968 * @param s The C string to insert.
969 * @return Reference to this string.
970 * @throw std::length_error If new length exceeds @c max_size().
971 * @throw std::out_of_range If @a pos is beyond the end of this
974 * Inserts the first @a n characters of @a s starting at @a pos. If
975 * adding characters causes the length to exceed max_size(),
976 * length_error is thrown. If @a pos is beyond end(), out_of_range is
977 * thrown. The value of the string doesn't change if an error is
981 insert(size_type __pos, const _CharT* __s)
983 __glibcxx_requires_string(__s);
984 return this->insert(__pos, __s, traits_type::length(__s));
988 * @brief Insert multiple characters.
989 * @param pos Index in string to insert at.
990 * @param n Number of characters to insert
991 * @param c The character to insert.
992 * @return Reference to this string.
993 * @throw std::length_error If new length exceeds @c max_size().
994 * @throw std::out_of_range If @a pos is beyond the end of this
997 * Inserts @a n copies of character @a c starting at index @a pos. If
998 * adding characters causes the length to exceed max_size(),
999 * length_error is thrown. If @a pos > length(), out_of_range is
1000 * thrown. The value of the string doesn't change if an error is
1004 insert(size_type __pos, size_type __n, _CharT __c)
1005 { return _M_replace_aux(_M_check(__pos, "basic_string::insert"),
1006 size_type(0), __n, __c); }
1009 * @brief Insert one character.
1010 * @param p Iterator referencing position in string to insert at.
1011 * @param c The character to insert.
1012 * @return Iterator referencing newly inserted char.
1013 * @throw std::length_error If new length exceeds @c max_size().
1015 * Inserts character @a c at position referenced by @a p. If adding
1016 * character causes the length to exceed max_size(), length_error is
1017 * thrown. If @a p is beyond end of string, out_of_range is thrown.
1018 * The value of the string doesn't change if an error is thrown.
1021 insert(iterator __p, _CharT __c)
1023 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
1024 const size_type __pos = __p - _M_ibegin();
1025 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1026 _M_rep()->_M_set_leaked();
1027 return this->_M_ibegin() + __pos;
1031 * @brief Remove characters.
1032 * @param pos Index of first character to remove (default 0).
1033 * @param n Number of characters to remove (default remainder).
1034 * @return Reference to this string.
1035 * @throw std::out_of_range If @a pos is beyond the end of this
1038 * Removes @a n characters from this string starting at @a pos. The
1039 * length of the string is reduced by @a n. If there are < @a n
1040 * characters to remove, the remainder of the string is truncated. If
1041 * @a p is beyond end of string, out_of_range is thrown. The value of
1042 * the string doesn't change if an error is thrown.
1045 erase(size_type __pos = 0, size_type __n = npos)
1046 { return _M_replace_safe(_M_check(__pos, "basic_string::erase"),
1047 _M_limit(__pos, __n), NULL, size_type(0)); }
1050 * @brief Remove one character.
1051 * @param position Iterator referencing the character to remove.
1052 * @return iterator referencing same location after removal.
1054 * Removes the character at @a position from this string. The value
1055 * of the string doesn't change if an error is thrown.
1058 erase(iterator __position)
1060 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
1061 && __position < _M_iend());
1062 const size_type __pos = __position - _M_ibegin();
1063 _M_replace_safe(__pos, size_type(1), NULL, size_type(0));
1064 _M_rep()->_M_set_leaked();
1065 return _M_ibegin() + __pos;
1069 * @brief Remove a range of characters.
1070 * @param first Iterator referencing the first character to remove.
1071 * @param last Iterator referencing the end of the range.
1072 * @return Iterator referencing location of first after removal.
1074 * Removes the characters in the range [first,last) from this string.
1075 * The value of the string doesn't change if an error is thrown.
1078 erase(iterator __first, iterator __last)
1080 _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
1081 && __last <= _M_iend());
1082 const size_type __pos = __first - _M_ibegin();
1083 _M_replace_safe(__pos, __last - __first, NULL, size_type(0));
1084 _M_rep()->_M_set_leaked();
1085 return _M_ibegin() + __pos;
1089 * @brief Replace characters with value from another string.
1090 * @param pos Index of first character to replace.
1091 * @param n Number of characters to be replaced.
1092 * @param str String to insert.
1093 * @return Reference to this string.
1094 * @throw std::out_of_range If @a pos is beyond the end of this
1096 * @throw std::length_error If new length exceeds @c max_size().
1098 * Removes the characters in the range [pos,pos+n) from this string.
1099 * In place, the value of @a str is inserted. If @a pos is beyond end
1100 * of string, out_of_range is thrown. If the length of the result
1101 * exceeds max_size(), length_error is thrown. The value of the string
1102 * doesn't change if an error is thrown.
1105 replace(size_type __pos, size_type __n, const basic_string& __str)
1106 { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
1109 * @brief Replace characters with value from another string.
1110 * @param pos1 Index of first character to replace.
1111 * @param n1 Number of characters to be replaced.
1112 * @param str String to insert.
1113 * @param pos2 Index of first character of str to use.
1114 * @param n2 Number of characters from str to use.
1115 * @return Reference to this string.
1116 * @throw std::out_of_range If @a pos1 > size() or @a pos2 >
1118 * @throw std::length_error If new length exceeds @c max_size().
1120 * Removes the characters in the range [pos1,pos1 + n) from this
1121 * string. In place, the value of @a str is inserted. If @a pos is
1122 * beyond end of string, out_of_range is thrown. If the length of the
1123 * result exceeds max_size(), length_error is thrown. The value of the
1124 * string doesn't change if an error is thrown.
1127 replace(size_type __pos1, size_type __n1, const basic_string& __str,
1128 size_type __pos2, size_type __n2)
1129 { return this->replace(__pos1, __n1, __str._M_data()
1130 + __str._M_check(__pos2, "basic_string::replace"),
1131 __str._M_limit(__pos2, __n2)); }
1134 * @brief Replace characters with value of a C substring.
1135 * @param pos Index of first character to replace.
1136 * @param n1 Number of characters to be replaced.
1137 * @param str C string to insert.
1138 * @param n2 Number of characters from str to use.
1139 * @return Reference to this string.
1140 * @throw std::out_of_range If @a pos1 > size().
1141 * @throw std::length_error If new length exceeds @c max_size().
1143 * Removes the characters in the range [pos,pos + n1) from this string.
1144 * In place, the first @a n2 characters of @a str are inserted, or all
1145 * of @a str if @a n2 is too large. If @a pos is beyond end of string,
1146 * out_of_range is thrown. If the length of result exceeds max_size(),
1147 * length_error is thrown. The value of the string doesn't change if
1148 * an error is thrown.
1151 replace(size_type __pos, size_type __n1, const _CharT* __s,
1155 * @brief Replace characters with value of a C string.
1156 * @param pos Index of first character to replace.
1157 * @param n1 Number of characters to be replaced.
1158 * @param str C string to insert.
1159 * @return Reference to this string.
1160 * @throw std::out_of_range If @a pos > size().
1161 * @throw std::length_error If new length exceeds @c max_size().
1163 * Removes the characters in the range [pos,pos + n1) from this string.
1164 * In place, the first @a n characters of @a str are inserted. If @a
1165 * pos is beyond end of string, out_of_range is thrown. If the length
1166 * of result exceeds max_size(), length_error is thrown. The value of
1167 * the string doesn't change if an error is thrown.
1170 replace(size_type __pos, size_type __n1, const _CharT* __s)
1172 __glibcxx_requires_string(__s);
1173 return this->replace(__pos, __n1, __s, traits_type::length(__s));
1177 * @brief Replace characters with multiple characters.
1178 * @param pos Index of first character to replace.
1179 * @param n1 Number of characters to be replaced.
1180 * @param n2 Number of characters to insert.
1181 * @param c Character to insert.
1182 * @return Reference to this string.
1183 * @throw std::out_of_range If @a pos > size().
1184 * @throw std::length_error If new length exceeds @c max_size().
1186 * Removes the characters in the range [pos,pos + n1) from this string.
1187 * In place, @a n2 copies of @a c are inserted. If @a pos is beyond
1188 * end of string, out_of_range is thrown. If the length of result
1189 * exceeds max_size(), length_error is thrown. The value of the string
1190 * doesn't change if an error is thrown.
1193 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1194 { return _M_replace_aux(_M_check(__pos, "basic_string::replace"),
1195 _M_limit(__pos, __n1), __n2, __c); }
1198 * @brief Replace range of characters with string.
1199 * @param i1 Iterator referencing start of range to replace.
1200 * @param i2 Iterator referencing end of range to replace.
1201 * @param str String value to insert.
1202 * @return Reference to this string.
1203 * @throw std::length_error If new length exceeds @c max_size().
1205 * Removes the characters in the range [i1,i2). In place, the value of
1206 * @a str is inserted. If the length of result exceeds max_size(),
1207 * length_error is thrown. The value of the string doesn't change if
1208 * an error is thrown.
1211 replace(iterator __i1, iterator __i2, const basic_string& __str)
1212 { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
1215 * @brief Replace range of characters with C substring.
1216 * @param i1 Iterator referencing start of range to replace.
1217 * @param i2 Iterator referencing end of range to replace.
1218 * @param s C string value to insert.
1219 * @param n Number of characters from s to insert.
1220 * @return Reference to this string.
1221 * @throw std::length_error If new length exceeds @c max_size().
1223 * Removes the characters in the range [i1,i2). In place, the first @a
1224 * n characters of @a s are inserted. If the length of result exceeds
1225 * max_size(), length_error is thrown. The value of the string doesn't
1226 * change if an error is thrown.
1229 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
1231 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1232 && __i2 <= _M_iend());
1233 return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
1237 * @brief Replace range of characters with C string.
1238 * @param i1 Iterator referencing start of range to replace.
1239 * @param i2 Iterator referencing end of range to replace.
1240 * @param s C string value to insert.
1241 * @return Reference to this string.
1242 * @throw std::length_error If new length exceeds @c max_size().
1244 * Removes the characters in the range [i1,i2). In place, the
1245 * characters of @a s are inserted. If the length of result exceeds
1246 * max_size(), length_error is thrown. The value of the string doesn't
1247 * change if an error is thrown.
1250 replace(iterator __i1, iterator __i2, const _CharT* __s)
1252 __glibcxx_requires_string(__s);
1253 return this->replace(__i1, __i2, __s, traits_type::length(__s));
1257 * @brief Replace range of characters with multiple characters
1258 * @param i1 Iterator referencing start of range to replace.
1259 * @param i2 Iterator referencing end of range to replace.
1260 * @param n Number of characters to insert.
1261 * @param c Character to insert.
1262 * @return Reference to this string.
1263 * @throw std::length_error If new length exceeds @c max_size().
1265 * Removes the characters in the range [i1,i2). In place, @a n copies
1266 * of @a c are inserted. If the length of result exceeds max_size(),
1267 * length_error is thrown. The value of the string doesn't change if
1268 * an error is thrown.
1271 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
1273 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1274 && __i2 <= _M_iend());
1275 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
1279 * @brief Replace range of characters with range.
1280 * @param i1 Iterator referencing start of range to replace.
1281 * @param i2 Iterator referencing end of range to replace.
1282 * @param k1 Iterator referencing start of range to insert.
1283 * @param k2 Iterator referencing end of range to insert.
1284 * @return Reference to this string.
1285 * @throw std::length_error If new length exceeds @c max_size().
1287 * Removes the characters in the range [i1,i2). In place, characters
1288 * in the range [k1,k2) are inserted. If the length of result exceeds
1289 * max_size(), length_error is thrown. The value of the string doesn't
1290 * change if an error is thrown.
1292 template<class _InputIterator>
1294 replace(iterator __i1, iterator __i2,
1295 _InputIterator __k1, _InputIterator __k2)
1297 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1298 && __i2 <= _M_iend());
1299 __glibcxx_requires_valid_range(__k1, __k2);
1300 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
1301 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1304 // Specializations for the common case of pointer and iterator:
1305 // useful to avoid the overhead of temporary buffering in _M_replace.
1307 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
1309 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1310 && __i2 <= _M_iend());
1311 __glibcxx_requires_valid_range(__k1, __k2);
1312 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1317 replace(iterator __i1, iterator __i2,
1318 const _CharT* __k1, const _CharT* __k2)
1320 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1321 && __i2 <= _M_iend());
1322 __glibcxx_requires_valid_range(__k1, __k2);
1323 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1328 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
1330 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1331 && __i2 <= _M_iend());
1332 __glibcxx_requires_valid_range(__k1, __k2);
1333 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1334 __k1.base(), __k2 - __k1);
1338 replace(iterator __i1, iterator __i2,
1339 const_iterator __k1, const_iterator __k2)
1341 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1342 && __i2 <= _M_iend());
1343 __glibcxx_requires_valid_range(__k1, __k2);
1344 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1345 __k1.base(), __k2 - __k1);
1349 template<class _Integer>
1351 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
1352 _Integer __val, __true_type)
1353 { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
1355 template<class _InputIterator>
1357 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
1358 _InputIterator __k2, __false_type);
1361 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1364 if (this->max_size() - (this->size() - __n1) < __n2)
1365 __throw_length_error(__N("basic_string::_M_replace_aux"));
1366 _M_mutate(__pos1, __n1, __n2);
1368 _M_data()[__pos1] = __c;
1370 traits_type::assign(_M_data() + __pos1, __n2, __c);
1375 _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
1378 _M_mutate(__pos1, __n1, __n2);
1380 _M_data()[__pos1] = *__s;
1382 traits_type::copy(_M_data() + __pos1, __s, __n2);
1386 // _S_construct_aux is used to implement the 21.3.1 para 15 which
1387 // requires special behaviour if _InIter is an integral type
1388 template<class _InIterator>
1390 _S_construct_aux(_InIterator __beg, _InIterator __end,
1391 const _Alloc& __a, __false_type)
1393 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
1394 return _S_construct(__beg, __end, __a, _Tag());
1397 template<class _InIterator>
1399 _S_construct_aux(_InIterator __beg, _InIterator __end,
1400 const _Alloc& __a, __true_type)
1401 { return _S_construct(static_cast<size_type>(__beg),
1402 static_cast<value_type>(__end), __a); }
1404 template<class _InIterator>
1406 _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
1408 typedef typename _Is_integer<_InIterator>::_Integral _Integral;
1409 return _S_construct_aux(__beg, __end, __a, _Integral());
1412 // For Input Iterators, used in istreambuf_iterators, etc.
1413 template<class _InIterator>
1415 _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
1416 input_iterator_tag);
1418 // For forward_iterators up to random_access_iterators, used for
1419 // string::iterator, _CharT*, etc.
1420 template<class _FwdIterator>
1422 _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
1423 forward_iterator_tag);
1426 _S_construct(size_type __req, _CharT __c, const _Alloc& __a);
1431 * @brief Copy substring into C string.
1432 * @param s C string to copy value into.
1433 * @param n Number of characters to copy.
1434 * @param pos Index of first character to copy.
1435 * @return Number of characters actually copied
1436 * @throw std::out_of_range If pos > size().
1438 * Copies up to @a n characters starting at @a pos into the C string @a
1439 * s. If @a pos is greater than size(), out_of_range is thrown.
1442 copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
1445 * @brief Swap contents with another string.
1446 * @param s String to swap with.
1448 * Exchanges the contents of this string with that of @a s in constant
1452 swap(basic_string& __s);
1454 // String operations:
1456 * @brief Return const pointer to null-terminated contents.
1458 * This is a handle to internal data. Do not modify or dire things may
1463 { return _M_data(); }
1466 * @brief Return const pointer to contents.
1468 * This is a handle to internal data. Do not modify or dire things may
1473 { return _M_data(); }
1476 * @brief Return copy of allocator used to construct this string.
1479 get_allocator() const
1480 { return _M_dataplus; }
1483 * @brief Find position of a C substring.
1484 * @param s C string to locate.
1485 * @param pos Index of character to search from.
1486 * @param n Number of characters from @a s to search for.
1487 * @return Index of start of first occurrence.
1489 * Starting from @a pos, searches forward for the first @a n characters
1490 * in @a s within this string. If found, returns the index where it
1491 * begins. If not found, returns npos.
1494 find(const _CharT* __s, size_type __pos, size_type __n) const;
1497 * @brief Find position of a string.
1498 * @param str String to locate.
1499 * @param pos Index of character to search from (default 0).
1500 * @return Index of start of first occurrence.
1502 * Starting from @a pos, searches forward for value of @a str within
1503 * this string. If found, returns the index where it begins. If not
1504 * found, returns npos.
1507 find(const basic_string& __str, size_type __pos = 0) const
1508 { return this->find(__str.data(), __pos, __str.size()); }
1511 * @brief Find position of a C string.
1512 * @param s C string to locate.
1513 * @param pos Index of character to search from (default 0).
1514 * @return Index of start of first occurrence.
1516 * Starting from @a pos, searches forward for the value of @a s within
1517 * this string. If found, returns the index where it begins. If not
1518 * found, returns npos.
1521 find(const _CharT* __s, size_type __pos = 0) const
1523 __glibcxx_requires_string(__s);
1524 return this->find(__s, __pos, traits_type::length(__s));
1528 * @brief Find position of a character.
1529 * @param c Character to locate.
1530 * @param pos Index of character to search from (default 0).
1531 * @return Index of first occurrence.
1533 * Starting from @a pos, searches forward for @a c within this string.
1534 * If found, returns the index where it was found. If not found,
1538 find(_CharT __c, size_type __pos = 0) const;
1541 * @brief Find last position of a string.
1542 * @param str String to locate.
1543 * @param pos Index of character to search back from (default end).
1544 * @return Index of start of last occurrence.
1546 * Starting from @a pos, searches backward for value of @a str within
1547 * this string. If found, returns the index where it begins. If not
1548 * found, returns npos.
1551 rfind(const basic_string& __str, size_type __pos = npos) const
1552 { return this->rfind(__str.data(), __pos, __str.size()); }
1555 * @brief Find last position of a C substring.
1556 * @param s C string to locate.
1557 * @param pos Index of character to search back from.
1558 * @param n Number of characters from s to search for.
1559 * @return Index of start of last occurrence.
1561 * Starting from @a pos, searches backward for the first @a n
1562 * characters in @a s within this string. If found, returns the index
1563 * where it begins. If not found, returns npos.
1566 rfind(const _CharT* __s, size_type __pos, size_type __n) const;
1569 * @brief Find last position of a C string.
1570 * @param s C string to locate.
1571 * @param pos Index of character to start search at (default 0).
1572 * @return Index of start of last occurrence.
1574 * Starting from @a pos, searches backward for the value of @a s within
1575 * this string. If found, returns the index where it begins. If not
1576 * found, returns npos.
1579 rfind(const _CharT* __s, size_type __pos = npos) const
1581 __glibcxx_requires_string(__s);
1582 return this->rfind(__s, __pos, traits_type::length(__s));
1586 * @brief Find last position of a character.
1587 * @param c Character to locate.
1588 * @param pos Index of character to search back from (default 0).
1589 * @return Index of last occurrence.
1591 * Starting from @a pos, searches backward for @a c within this string.
1592 * If found, returns the index where it was found. If not found,
1596 rfind(_CharT __c, size_type __pos = npos) const;
1599 * @brief Find position of a character of string.
1600 * @param str String containing characters to locate.
1601 * @param pos Index of character to search from (default 0).
1602 * @return Index of first occurrence.
1604 * Starting from @a pos, searches forward for one of the characters of
1605 * @a str within this string. If found, returns the index where it was
1606 * found. If not found, returns npos.
1609 find_first_of(const basic_string& __str, size_type __pos = 0) const
1610 { return this->find_first_of(__str.data(), __pos, __str.size()); }
1613 * @brief Find position of a character of C substring.
1614 * @param s String containing characters to locate.
1615 * @param pos Index of character to search from (default 0).
1616 * @param n Number of characters from s to search for.
1617 * @return Index of first occurrence.
1619 * Starting from @a pos, searches forward for one of the first @a n
1620 * characters of @a s within this string. If found, returns the index
1621 * where it was found. If not found, returns npos.
1624 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
1627 * @brief Find position of a character of C string.
1628 * @param s String containing characters to locate.
1629 * @param pos Index of character to search from (default 0).
1630 * @return Index of first occurrence.
1632 * Starting from @a pos, searches forward for one of the characters of
1633 * @a s within this string. If found, returns the index where it was
1634 * found. If not found, returns npos.
1637 find_first_of(const _CharT* __s, size_type __pos = 0) const
1639 __glibcxx_requires_string(__s);
1640 return this->find_first_of(__s, __pos, traits_type::length(__s));
1644 * @brief Find position of a character.
1645 * @param c Character to locate.
1646 * @param pos Index of character to search from (default 0).
1647 * @return Index of first occurrence.
1649 * Starting from @a pos, searches forward for the character @a c within
1650 * this string. If found, returns the index where it was found. If
1651 * not found, returns npos.
1653 * Note: equivalent to find(c, pos).
1656 find_first_of(_CharT __c, size_type __pos = 0) const
1657 { return this->find(__c, __pos); }
1660 * @brief Find last position of a character of string.
1661 * @param str String containing characters to locate.
1662 * @param pos Index of character to search back from (default end).
1663 * @return Index of last occurrence.
1665 * Starting from @a pos, searches backward for one of the characters of
1666 * @a str within this string. If found, returns the index where it was
1667 * found. If not found, returns npos.
1670 find_last_of(const basic_string& __str, size_type __pos = npos) const
1671 { return this->find_last_of(__str.data(), __pos, __str.size()); }
1674 * @brief Find last position of a character of C substring.
1675 * @param s C string containing characters to locate.
1676 * @param pos Index of character to search back from (default end).
1677 * @param n Number of characters from s to search for.
1678 * @return Index of last occurrence.
1680 * Starting from @a pos, searches backward for one of the first @a n
1681 * characters of @a s within this string. If found, returns the index
1682 * where it was found. If not found, returns npos.
1685 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
1688 * @brief Find last position of a character of C string.
1689 * @param s C string containing characters to locate.
1690 * @param pos Index of character to search back from (default end).
1691 * @return Index of last occurrence.
1693 * Starting from @a pos, searches backward for one of the characters of
1694 * @a s within this string. If found, returns the index where it was
1695 * found. If not found, returns npos.
1698 find_last_of(const _CharT* __s, size_type __pos = npos) const
1700 __glibcxx_requires_string(__s);
1701 return this->find_last_of(__s, __pos, traits_type::length(__s));
1705 * @brief Find last position of a character.
1706 * @param c Character to locate.
1707 * @param pos Index of character to search back from (default 0).
1708 * @return Index of last occurrence.
1710 * Starting from @a pos, searches backward for @a c within this string.
1711 * If found, returns the index where it was found. If not found,
1714 * Note: equivalent to rfind(c, pos).
1717 find_last_of(_CharT __c, size_type __pos = npos) const
1718 { return this->rfind(__c, __pos); }
1721 * @brief Find position of a character not in string.
1722 * @param str String containing characters to avoid.
1723 * @param pos Index of character to search from (default 0).
1724 * @return Index of first occurrence.
1726 * Starting from @a pos, searches forward for a character not contained
1727 * in @a str within this string. If found, returns the index where it
1728 * was found. If not found, returns npos.
1731 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
1732 { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
1735 * @brief Find position of a character not in C substring.
1736 * @param s C string containing characters to avoid.
1737 * @param pos Index of character to search from (default 0).
1738 * @param n Number of characters from s to consider.
1739 * @return Index of first occurrence.
1741 * Starting from @a pos, searches forward for a character not contained
1742 * in the first @a n characters of @a s within this string. If found,
1743 * returns the index where it was found. If not found, returns npos.
1746 find_first_not_of(const _CharT* __s, size_type __pos,
1747 size_type __n) const;
1750 * @brief Find position of a character not in C string.
1751 * @param s C string containing characters to avoid.
1752 * @param pos Index of character to search from (default 0).
1753 * @return Index of first occurrence.
1755 * Starting from @a pos, searches forward for a character not contained
1756 * in @a s within this string. If found, returns the index where it
1757 * was found. If not found, returns npos.
1760 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
1762 __glibcxx_requires_string(__s);
1763 return this->find_first_not_of(__s, __pos, traits_type::length(__s));
1767 * @brief Find position of a different character.
1768 * @param c Character to avoid.
1769 * @param pos Index of character to search from (default 0).
1770 * @return Index of first occurrence.
1772 * Starting from @a pos, searches forward for a character other than @a c
1773 * within this string. If found, returns the index where it was found.
1774 * If not found, returns npos.
1777 find_first_not_of(_CharT __c, size_type __pos = 0) const;
1780 * @brief Find last position of a character not in string.
1781 * @param str String containing characters to avoid.
1782 * @param pos Index of character to search from (default 0).
1783 * @return Index of first occurrence.
1785 * Starting from @a pos, searches backward for a character not
1786 * contained in @a str within this string. If found, returns the index
1787 * where it was found. If not found, returns npos.
1790 find_last_not_of(const basic_string& __str, size_type __pos = npos) const
1791 { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
1794 * @brief Find last position of a character not in C substring.
1795 * @param s C string containing characters to avoid.
1796 * @param pos Index of character to search from (default 0).
1797 * @param n Number of characters from s to consider.
1798 * @return Index of first occurrence.
1800 * Starting from @a pos, searches backward for a character not
1801 * contained in the first @a n characters of @a s within this string.
1802 * If found, returns the index where it was found. If not found,
1806 find_last_not_of(const _CharT* __s, size_type __pos,
1807 size_type __n) const;
1809 * @brief Find position of a character not in C string.
1810 * @param s C string containing characters to avoid.
1811 * @param pos Index of character to search from (default 0).
1812 * @return Index of first occurrence.
1814 * Starting from @a pos, searches backward for a character not
1815 * contained in @a s within this string. If found, returns the index
1816 * where it was found. If not found, returns npos.
1819 find_last_not_of(const _CharT* __s, size_type __pos = npos) const
1821 __glibcxx_requires_string(__s);
1822 return this->find_last_not_of(__s, __pos, traits_type::length(__s));
1826 * @brief Find last position of a different character.
1827 * @param c Character to avoid.
1828 * @param pos Index of character to search from (default 0).
1829 * @return Index of first occurrence.
1831 * Starting from @a pos, searches backward for a character other than
1832 * @a c within this string. If found, returns the index where it was
1833 * found. If not found, returns npos.
1836 find_last_not_of(_CharT __c, size_type __pos = npos) const;
1839 * @brief Get a substring.
1840 * @param pos Index of first character (default 0).
1841 * @param n Number of characters in substring (default remainder).
1842 * @return The new string.
1843 * @throw std::out_of_range If pos > size().
1845 * Construct and return a new string using the @a n characters starting
1846 * at @a pos. If the string is too short, use the remainder of the
1847 * characters. If @a pos is beyond the end of the string, out_of_range
1851 substr(size_type __pos = 0, size_type __n = npos) const
1852 { return basic_string(*this,
1853 _M_check(__pos, "basic_string::substr"), __n); }
1856 * @brief Compare to a string.
1857 * @param str String to compare against.
1858 * @return Integer < 0, 0, or > 0.
1860 * Returns an integer < 0 if this string is ordered before @a str, 0 if
1861 * their values are equivalent, or > 0 if this string is ordered after
1862 * @a str. If the lengths of @a str and this string are different, the
1863 * shorter one is ordered first. If they are the same, returns the
1864 * result of traits::compare(data(),str.data(),size());
1867 compare(const basic_string& __str) const
1869 const size_type __size = this->size();
1870 const size_type __osize = __str.size();
1871 const size_type __len = std::min(__size, __osize);
1873 int __r = traits_type::compare(_M_data(), __str.data(), __len);
1875 __r = __size - __osize;
1880 * @brief Compare substring to a string.
1881 * @param pos Index of first character of substring.
1882 * @param n Number of characters in substring.
1883 * @param str String to compare against.
1884 * @return Integer < 0, 0, or > 0.
1886 * Form the substring of this string from the @a n characters starting
1887 * at @a pos. Returns an integer < 0 if the substring is ordered
1888 * before @a str, 0 if their values are equivalent, or > 0 if the
1889 * substring is ordered after @a str. If the lengths @a of str and the
1890 * substring are different, the shorter one is ordered first. If they
1891 * are the same, returns the result of
1892 * traits::compare(substring.data(),str.data(),size());
1895 compare(size_type __pos, size_type __n, const basic_string& __str) const;
1898 * @brief Compare substring to a substring.
1899 * @param pos1 Index of first character of substring.
1900 * @param n1 Number of characters in substring.
1901 * @param str String to compare against.
1902 * @param pos2 Index of first character of substring of str.
1903 * @param n2 Number of characters in substring of str.
1904 * @return Integer < 0, 0, or > 0.
1906 * Form the substring of this string from the @a n1 characters starting
1907 * at @a pos1. Form the substring of @a str from the @a n2 characters
1908 * starting at @a pos2. Returns an integer < 0 if this substring is
1909 * ordered before the substring of @a str, 0 if their values are
1910 * equivalent, or > 0 if this substring is ordered after the substring
1911 * of @a str. If the lengths of the substring of @a str and this
1912 * substring are different, the shorter one is ordered first. If they
1913 * are the same, returns the result of
1914 * traits::compare(substring.data(),str.substr(pos2,n2).data(),size());
1917 compare(size_type __pos1, size_type __n1, const basic_string& __str,
1918 size_type __pos2, size_type __n2) const;
1921 * @brief Compare to a C string.
1922 * @param s C string to compare against.
1923 * @return Integer < 0, 0, or > 0.
1925 * Returns an integer < 0 if this string is ordered before @a s, 0 if
1926 * their values are equivalent, or > 0 if this string is ordered after
1927 * @a s. If the lengths of @a s and this string are different, the
1928 * shorter one is ordered first. If they are the same, returns the
1929 * result of traits::compare(data(),s,size());
1932 compare(const _CharT* __s) const;
1934 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1935 // 5 String::compare specification questionable
1937 * @brief Compare substring to a C string.
1938 * @param pos Index of first character of substring.
1939 * @param n1 Number of characters in substring.
1940 * @param s C string to compare against.
1941 * @return Integer < 0, 0, or > 0.
1943 * Form the substring of this string from the @a n1 characters starting
1944 * at @a pos. Returns an integer < 0 if the substring is ordered
1945 * before @a s, 0 if their values are equivalent, or > 0 if the
1946 * substring is ordered after @a s. If the lengths of @a s and the
1947 * substring are different, the shorter one is ordered first. If they
1948 * are the same, returns the result of
1949 * traits::compare(substring.data(),s,size());
1952 compare(size_type __pos, size_type __n1, const _CharT* __s) const;
1955 * @brief Compare substring against a character array.
1956 * @param pos1 Index of first character of substring.
1957 * @param n1 Number of characters in substring.
1958 * @param s character array to compare against.
1959 * @param n2 Number of characters of s.
1960 * @return Integer < 0, 0, or > 0.
1962 * Form the substring of this string from the @a n1 characters starting
1963 * at @a pos1. Form a string from the first @a n2 characters of @a s.
1964 * Returns an integer < 0 if this substring is ordered before the string
1965 * from @a s, 0 if their values are equivalent, or > 0 if this substring
1966 * is ordered after the string from @a s. If the lengths of this
1967 * substring and @a n2 are different, the shorter one is ordered first.
1968 * If they are the same, returns the result of
1969 * traits::compare(substring.data(),s,size());
1971 * NB: s must have at least n2 characters, '\0' has no special
1975 compare(size_type __pos, size_type __n1, const _CharT* __s,
1976 size_type __n2) const;
1979 template<typename _CharT, typename _Traits, typename _Alloc>
1980 inline basic_string<_CharT, _Traits, _Alloc>::
1982 #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
1983 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
1985 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { }
1990 * @brief Concatenate two strings.
1991 * @param lhs First string.
1992 * @param rhs Last string.
1993 * @return New string with value of @a lhs followed by @a rhs.
1995 template<typename _CharT, typename _Traits, typename _Alloc>
1996 basic_string<_CharT, _Traits, _Alloc>
1997 operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
1998 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2000 basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
2001 __str.append(__rhs);
2006 * @brief Concatenate C string and string.
2007 * @param lhs First string.
2008 * @param rhs Last string.
2009 * @return New string with value of @a lhs followed by @a rhs.
2011 template<typename _CharT, typename _Traits, typename _Alloc>
2012 basic_string<_CharT,_Traits,_Alloc>
2013 operator+(const _CharT* __lhs,
2014 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
2017 * @brief Concatenate character and string.
2018 * @param lhs First string.
2019 * @param rhs Last string.
2020 * @return New string with @a lhs followed by @a rhs.
2022 template<typename _CharT, typename _Traits, typename _Alloc>
2023 basic_string<_CharT,_Traits,_Alloc>
2024 operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs);
2027 * @brief Concatenate string and C string.
2028 * @param lhs First string.
2029 * @param rhs Last string.
2030 * @return New string with @a lhs followed by @a rhs.
2032 template<typename _CharT, typename _Traits, typename _Alloc>
2033 inline basic_string<_CharT, _Traits, _Alloc>
2034 operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2035 const _CharT* __rhs)
2037 basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
2038 __str.append(__rhs);
2043 * @brief Concatenate string and character.
2044 * @param lhs First string.
2045 * @param rhs Last string.
2046 * @return New string with @a lhs followed by @a rhs.
2048 template<typename _CharT, typename _Traits, typename _Alloc>
2049 inline basic_string<_CharT, _Traits, _Alloc>
2050 operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
2052 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
2053 typedef typename __string_type::size_type __size_type;
2054 __string_type __str(__lhs);
2055 __str.append(__size_type(1), __rhs);
2061 * @brief Test equivalence of two strings.
2062 * @param lhs First string.
2063 * @param rhs Second string.
2064 * @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
2066 template<typename _CharT, typename _Traits, typename _Alloc>
2068 operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2069 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2070 { return __lhs.compare(__rhs) == 0; }
2073 * @brief Test equivalence of C string and string.
2074 * @param lhs C string.
2075 * @param rhs String.
2076 * @return True if @a rhs.compare(@a lhs) == 0. False otherwise.
2078 template<typename _CharT, typename _Traits, typename _Alloc>
2080 operator==(const _CharT* __lhs,
2081 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2082 { return __rhs.compare(__lhs) == 0; }
2085 * @brief Test equivalence of string and C string.
2086 * @param lhs String.
2087 * @param rhs C string.
2088 * @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
2090 template<typename _CharT, typename _Traits, typename _Alloc>
2092 operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2093 const _CharT* __rhs)
2094 { return __lhs.compare(__rhs) == 0; }
2098 * @brief Test difference of two strings.
2099 * @param lhs First string.
2100 * @param rhs Second string.
2101 * @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
2103 template<typename _CharT, typename _Traits, typename _Alloc>
2105 operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2106 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2107 { return __rhs.compare(__lhs) != 0; }
2110 * @brief Test difference of C string and string.
2111 * @param lhs C string.
2112 * @param rhs String.
2113 * @return True if @a rhs.compare(@a lhs) != 0. False otherwise.
2115 template<typename _CharT, typename _Traits, typename _Alloc>
2117 operator!=(const _CharT* __lhs,
2118 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2119 { return __rhs.compare(__lhs) != 0; }
2122 * @brief Test difference of string and C string.
2123 * @param lhs String.
2124 * @param rhs C string.
2125 * @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
2127 template<typename _CharT, typename _Traits, typename _Alloc>
2129 operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2130 const _CharT* __rhs)
2131 { return __lhs.compare(__rhs) != 0; }
2135 * @brief Test if string precedes string.
2136 * @param lhs First string.
2137 * @param rhs Second string.
2138 * @return True if @a lhs precedes @a rhs. False otherwise.
2140 template<typename _CharT, typename _Traits, typename _Alloc>
2142 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2143 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2144 { return __lhs.compare(__rhs) < 0; }
2147 * @brief Test if string precedes C string.
2148 * @param lhs String.
2149 * @param rhs C string.
2150 * @return True if @a lhs precedes @a rhs. False otherwise.
2152 template<typename _CharT, typename _Traits, typename _Alloc>
2154 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2155 const _CharT* __rhs)
2156 { return __lhs.compare(__rhs) < 0; }
2159 * @brief Test if C string precedes string.
2160 * @param lhs C string.
2161 * @param rhs String.
2162 * @return True if @a lhs precedes @a rhs. False otherwise.
2164 template<typename _CharT, typename _Traits, typename _Alloc>
2166 operator<(const _CharT* __lhs,
2167 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2168 { return __rhs.compare(__lhs) > 0; }
2172 * @brief Test if string follows string.
2173 * @param lhs First string.
2174 * @param rhs Second string.
2175 * @return True if @a lhs follows @a rhs. False otherwise.
2177 template<typename _CharT, typename _Traits, typename _Alloc>
2179 operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2180 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2181 { return __lhs.compare(__rhs) > 0; }
2184 * @brief Test if string follows C string.
2185 * @param lhs String.
2186 * @param rhs C string.
2187 * @return True if @a lhs follows @a rhs. False otherwise.
2189 template<typename _CharT, typename _Traits, typename _Alloc>
2191 operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2192 const _CharT* __rhs)
2193 { return __lhs.compare(__rhs) > 0; }
2196 * @brief Test if C string follows string.
2197 * @param lhs C string.
2198 * @param rhs String.
2199 * @return True if @a lhs follows @a rhs. False otherwise.
2201 template<typename _CharT, typename _Traits, typename _Alloc>
2203 operator>(const _CharT* __lhs,
2204 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2205 { return __rhs.compare(__lhs) < 0; }
2209 * @brief Test if string doesn't follow string.
2210 * @param lhs First string.
2211 * @param rhs Second string.
2212 * @return True if @a lhs doesn't follow @a rhs. False otherwise.
2214 template<typename _CharT, typename _Traits, typename _Alloc>
2216 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2217 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2218 { return __lhs.compare(__rhs) <= 0; }
2221 * @brief Test if string doesn't follow C string.
2222 * @param lhs String.
2223 * @param rhs C string.
2224 * @return True if @a lhs doesn't follow @a rhs. False otherwise.
2226 template<typename _CharT, typename _Traits, typename _Alloc>
2228 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2229 const _CharT* __rhs)
2230 { return __lhs.compare(__rhs) <= 0; }
2233 * @brief Test if C string doesn't follow string.
2234 * @param lhs C string.
2235 * @param rhs String.
2236 * @return True if @a lhs doesn't follow @a rhs. False otherwise.
2238 template<typename _CharT, typename _Traits, typename _Alloc>
2240 operator<=(const _CharT* __lhs,
2241 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2242 { return __rhs.compare(__lhs) >= 0; }
2246 * @brief Test if string doesn't precede string.
2247 * @param lhs First string.
2248 * @param rhs Second string.
2249 * @return True if @a lhs doesn't precede @a rhs. False otherwise.
2251 template<typename _CharT, typename _Traits, typename _Alloc>
2253 operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2254 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2255 { return __lhs.compare(__rhs) >= 0; }
2258 * @brief Test if string doesn't precede C string.
2259 * @param lhs String.
2260 * @param rhs C string.
2261 * @return True if @a lhs doesn't precede @a rhs. False otherwise.
2263 template<typename _CharT, typename _Traits, typename _Alloc>
2265 operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2266 const _CharT* __rhs)
2267 { return __lhs.compare(__rhs) >= 0; }
2270 * @brief Test if C string doesn't precede string.
2271 * @param lhs C string.
2272 * @param rhs String.
2273 * @return True if @a lhs doesn't precede @a rhs. False otherwise.
2275 template<typename _CharT, typename _Traits, typename _Alloc>
2277 operator>=(const _CharT* __lhs,
2278 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2279 { return __rhs.compare(__lhs) <= 0; }
2282 * @brief Swap contents of two strings.
2283 * @param lhs First string.
2284 * @param rhs Second string.
2286 * Exchanges the contents of @a lhs and @a rhs in constant time.
2288 template<typename _CharT, typename _Traits, typename _Alloc>
2290 swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
2291 basic_string<_CharT, _Traits, _Alloc>& __rhs)
2292 { __lhs.swap(__rhs); }
2295 * @brief Read stream into a string.
2296 * @param is Input stream.
2297 * @param str Buffer to store into.
2298 * @return Reference to the input stream.
2300 * Stores characters from @a is into @a str until whitespace is found, the
2301 * end of the stream is encountered, or str.max_size() is reached. If
2302 * is.width() is non-zero, that is the limit on the number of characters
2303 * stored into @a str. Any previous contents of @a str are erased.
2305 template<typename _CharT, typename _Traits, typename _Alloc>
2306 basic_istream<_CharT, _Traits>&
2307 operator>>(basic_istream<_CharT, _Traits>& __is,
2308 basic_string<_CharT, _Traits, _Alloc>& __str);
2311 * @brief Write string to a stream.
2312 * @param os Output stream.
2313 * @param str String to write out.
2314 * @return Reference to the output stream.
2316 * Output characters of @a str into os following the same rules as for
2317 * writing a C string.
2319 template<typename _CharT, typename _Traits, typename _Alloc>
2320 basic_ostream<_CharT, _Traits>&
2321 operator<<(basic_ostream<_CharT, _Traits>& __os,
2322 const basic_string<_CharT, _Traits, _Alloc>& __str);
2325 * @brief Read a line from stream into a string.
2326 * @param is Input stream.
2327 * @param str Buffer to store into.
2328 * @param delim Character marking end of line.
2329 * @return Reference to the input stream.
2331 * Stores characters from @a is into @a str until @a delim is found, the
2332 * end of the stream is encountered, or str.max_size() is reached. If
2333 * is.width() is non-zero, that is the limit on the number of characters
2334 * stored into @a str. Any previous contents of @a str are erased. If @a
2335 * delim was encountered, it is extracted but not stored into @a str.
2337 template<typename _CharT, typename _Traits, typename _Alloc>
2338 basic_istream<_CharT,_Traits>&
2339 getline(basic_istream<_CharT, _Traits>& __is,
2340 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
2343 * @brief Read a line from stream into a string.
2344 * @param is Input stream.
2345 * @param str Buffer to store into.
2346 * @return Reference to the input stream.
2348 * Stores characters from is into @a str until '\n' is found, the end of
2349 * the stream is encountered, or str.max_size() is reached. If is.width()
2350 * is non-zero, that is the limit on the number of characters stored into
2351 * @a str. Any previous contents of @a str are erased. If end of line was
2352 * encountered, it is extracted but not stored into @a str.
2354 template<typename _CharT, typename _Traits, typename _Alloc>
2355 inline basic_istream<_CharT,_Traits>&
2356 getline(basic_istream<_CharT, _Traits>& __is,
2357 basic_string<_CharT, _Traits, _Alloc>& __str);
2360 #endif /* _BASIC_STRING_H */