Merge from mainline
[official-gcc.git] / libstdc++-v3 / include / ext / vstring.h
bloba117c5826eebbb68dd7eda4e30b8fa7ae6bfb647
1 // Versatile string -*- C++ -*-
3 // Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 /** @file ext/vstring.h
31 * This file is a GNU extension to the Standard C++ Library.
34 #ifndef _VSTRING_H
35 #define _VSTRING_H 1
37 #pragma GCC system_header
39 #include <ext/vstring_util.h>
40 #include <ext/rc_string_base.h>
41 #include <ext/sso_string_base.h>
43 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
45 /**
46 * @class __versa_string vstring.h
47 * @brief Managing sequences of characters and character-like objects.
50 // Template class __versa_string
51 template<typename _CharT, typename _Traits, typename _Alloc,
52 template <typename, typename, typename> class _Base>
53 class __versa_string
54 : private _Base<_CharT, _Traits, _Alloc>
56 typedef _Base<_CharT, _Traits, _Alloc> __vstring_base;
57 typedef typename __vstring_base::_CharT_alloc_type _CharT_alloc_type;
59 // Types:
60 public:
61 typedef _Traits traits_type;
62 typedef typename _Traits::char_type value_type;
63 typedef _Alloc allocator_type;
64 typedef typename _CharT_alloc_type::size_type size_type;
65 typedef typename _CharT_alloc_type::difference_type difference_type;
66 typedef typename _CharT_alloc_type::reference reference;
67 typedef typename _CharT_alloc_type::const_reference const_reference;
68 typedef typename _CharT_alloc_type::pointer pointer;
69 typedef typename _CharT_alloc_type::const_pointer const_pointer;
70 typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator;
71 typedef __gnu_cxx::__normal_iterator<const_pointer, __versa_string>
72 const_iterator;
73 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
74 typedef std::reverse_iterator<iterator> reverse_iterator;
76 // Data Member (public):
77 // NB: This is an unsigned type, and thus represents the maximum
78 // size that the allocator can hold.
79 /// Value returned by various member functions when they fail.
80 static const size_type npos = static_cast<size_type>(-1);
82 private:
83 size_type
84 _M_check(size_type __pos, const char* __s) const
86 if (__pos > this->size())
87 std::__throw_out_of_range(__N(__s));
88 return __pos;
91 void
92 _M_check_length(size_type __n1, size_type __n2, const char* __s) const
94 if (this->max_size() - (this->size() - __n1) < __n2)
95 std::__throw_length_error(__N(__s));
98 // NB: _M_limit doesn't check for a bad __pos value.
99 size_type
100 _M_limit(size_type __pos, size_type __off) const
102 const bool __testoff = __off < this->size() - __pos;
103 return __testoff ? __off : this->size() - __pos;
106 // True if _Rep and source do not overlap.
107 bool
108 _M_disjunct(const _CharT* __s) const
110 return (std::less<const _CharT*>()(__s, this->_M_data())
111 || std::less<const _CharT*>()(this->_M_data()
112 + this->size(), __s));
115 // For the internal use we have functions similar to `begin'/`end'
116 // but they do not call _M_leak.
117 iterator
118 _M_ibegin() const
119 { return iterator(this->_M_data()); }
121 iterator
122 _M_iend() const
123 { return iterator(this->_M_data() + this->_M_length()); }
125 public:
126 // Construct/copy/destroy:
127 // NB: We overload ctors in some cases instead of using default
128 // arguments, per 17.4.4.4 para. 2 item 2.
131 * @brief Default constructor creates an empty string.
133 __versa_string()
134 : __vstring_base() { }
137 * @brief Construct an empty string using allocator @a a.
139 explicit
140 __versa_string(const _Alloc& __a)
141 : __vstring_base(__a) { }
143 // NB: per LWG issue 42, semantics different from IS:
145 * @brief Construct string with copy of value of @a str.
146 * @param str Source string.
148 __versa_string(const __versa_string& __str)
149 : __vstring_base(__str) { }
152 * @brief Construct string as copy of a substring.
153 * @param str Source string.
154 * @param pos Index of first character to copy from.
155 * @param n Number of characters to copy (default remainder).
157 __versa_string(const __versa_string& __str, size_type __pos,
158 size_type __n = npos)
159 : __vstring_base(__str._M_data()
160 + __str._M_check(__pos,
161 "__versa_string::__versa_string"),
162 __str._M_data() + __str._M_limit(__pos, __n)
163 + __pos, _Alloc()) { }
166 * @brief Construct string as copy of a substring.
167 * @param str Source string.
168 * @param pos Index of first character to copy from.
169 * @param n Number of characters to copy.
170 * @param a Allocator to use.
172 __versa_string(const __versa_string& __str, size_type __pos,
173 size_type __n, const _Alloc& __a)
174 : __vstring_base(__str._M_data()
175 + __str._M_check(__pos,
176 "__versa_string::__versa_string"),
177 __str._M_data() + __str._M_limit(__pos, __n)
178 + __pos, __a) { }
181 * @brief Construct string initialized by a character array.
182 * @param s Source character array.
183 * @param n Number of characters to copy.
184 * @param a Allocator to use (default is default allocator).
186 * NB: @a s must have at least @a n characters, '\0' has no special
187 * meaning.
189 __versa_string(const _CharT* __s, size_type __n,
190 const _Alloc& __a = _Alloc())
191 : __vstring_base(__s, __s + __n, __a) { }
194 * @brief Construct string as copy of a C string.
195 * @param s Source C string.
196 * @param a Allocator to use (default is default allocator).
198 __versa_string(const _CharT* __s, const _Alloc& __a = _Alloc())
199 : __vstring_base(__s, __s ? __s + traits_type::length(__s) :
200 __s + npos, __a) { }
203 * @brief Construct string as multiple characters.
204 * @param n Number of characters.
205 * @param c Character to use.
206 * @param a Allocator to use (default is default allocator).
208 __versa_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
209 : __vstring_base(__n, __c, __a) { }
212 * @brief Construct string as copy of a range.
213 * @param beg Start of range.
214 * @param end End of range.
215 * @param a Allocator to use (default is default allocator).
217 template<class _InputIterator>
218 __versa_string(_InputIterator __beg, _InputIterator __end,
219 const _Alloc& __a = _Alloc())
220 : __vstring_base(__beg, __end, __a) { }
223 * @brief Destroy the string instance.
225 ~__versa_string() { }
228 * @brief Assign the value of @a str to this string.
229 * @param str Source string.
231 __versa_string&
232 operator=(const __versa_string& __str)
233 { return this->assign(__str); }
236 * @brief Copy contents of @a s into this string.
237 * @param s Source null-terminated string.
239 __versa_string&
240 operator=(const _CharT* __s)
241 { return this->assign(__s); }
244 * @brief Set value to string of length 1.
245 * @param c Source character.
247 * Assigning to a character makes this string length 1 and
248 * (*this)[0] == @a c.
250 __versa_string&
251 operator=(_CharT __c)
253 this->assign(1, __c);
254 return *this;
257 // Iterators:
259 * Returns a read/write iterator that points to the first character in
260 * the %string. Unshares the string.
262 iterator
263 begin()
265 this->_M_leak();
266 return iterator(this->_M_data());
270 * Returns a read-only (constant) iterator that points to the first
271 * character in the %string.
273 const_iterator
274 begin() const
275 { return const_iterator(this->_M_data()); }
278 * Returns a read/write iterator that points one past the last
279 * character in the %string. Unshares the string.
281 iterator
282 end()
284 this->_M_leak();
285 return iterator(this->_M_data() + this->size());
289 * Returns a read-only (constant) iterator that points one past the
290 * last character in the %string.
292 const_iterator
293 end() const
294 { return const_iterator(this->_M_data() + this->size()); }
297 * Returns a read/write reverse iterator that points to the last
298 * character in the %string. Iteration is done in reverse element
299 * order. Unshares the string.
301 reverse_iterator
302 rbegin()
303 { return reverse_iterator(this->end()); }
306 * Returns a read-only (constant) reverse iterator that points
307 * to the last character in the %string. Iteration is done in
308 * reverse element order.
310 const_reverse_iterator
311 rbegin() const
312 { return const_reverse_iterator(this->end()); }
315 * Returns a read/write reverse iterator that points to one before the
316 * first character in the %string. Iteration is done in reverse
317 * element order. Unshares the string.
319 reverse_iterator
320 rend()
321 { return reverse_iterator(this->begin()); }
324 * Returns a read-only (constant) reverse iterator that points
325 * to one before the first character in the %string. Iteration
326 * is done in reverse element order.
328 const_reverse_iterator
329 rend() const
330 { return const_reverse_iterator(this->begin()); }
332 public:
333 // Capacity:
334 /// Returns the number of characters in the string, not including any
335 /// null-termination.
336 size_type
337 size() const
338 { return this->_M_length(); }
340 /// Returns the number of characters in the string, not including any
341 /// null-termination.
342 size_type
343 length() const
344 { return this->_M_length(); }
346 /// Returns the size() of the largest possible %string.
347 size_type
348 max_size() const
349 { return this->_M_max_size(); }
352 * @brief Resizes the %string to the specified number of characters.
353 * @param n Number of characters the %string should contain.
354 * @param c Character to fill any new elements.
356 * This function will %resize the %string to the specified
357 * number of characters. If the number is smaller than the
358 * %string's current size the %string is truncated, otherwise
359 * the %string is extended and new elements are set to @a c.
361 void
362 resize(size_type __n, _CharT __c);
365 * @brief Resizes the %string to the specified number of characters.
366 * @param n Number of characters the %string should contain.
368 * This function will resize the %string to the specified length. If
369 * the new size is smaller than the %string's current size the %string
370 * is truncated, otherwise the %string is extended and new characters
371 * are default-constructed. For basic types such as char, this means
372 * setting them to 0.
374 void
375 resize(size_type __n)
376 { this->resize(__n, _CharT()); }
379 * Returns the total number of characters that the %string can hold
380 * before needing to allocate more memory.
382 size_type
383 capacity() const
384 { return this->_M_capacity(); }
387 * @brief Attempt to preallocate enough memory for specified number of
388 * characters.
389 * @param res_arg Number of characters required.
390 * @throw std::length_error If @a res_arg exceeds @c max_size().
392 * This function attempts to reserve enough memory for the
393 * %string to hold the specified number of characters. If the
394 * number requested is more than max_size(), length_error is
395 * thrown.
397 * The advantage of this function is that if optimal code is a
398 * necessity and the user can determine the string length that will be
399 * required, the user can reserve the memory in %advance, and thus
400 * prevent a possible reallocation of memory and copying of %string
401 * data.
403 void
404 reserve(size_type __res_arg = 0)
405 { this->_M_reserve(__res_arg); }
408 * Erases the string, making it empty.
410 void
411 clear()
412 { this->_M_erase(size_type(0), this->size()); }
415 * Returns true if the %string is empty. Equivalent to *this == "".
417 bool
418 empty() const
419 { return this->size() == 0; }
421 // Element access:
423 * @brief Subscript access to the data contained in the %string.
424 * @param pos The index of the character to access.
425 * @return Read-only (constant) reference to the character.
427 * This operator allows for easy, array-style, data access.
428 * Note that data access with this operator is unchecked and
429 * out_of_range lookups are not defined. (For checked lookups
430 * see at().)
432 const_reference
433 operator[] (size_type __pos) const
435 _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
436 return this->_M_data()[__pos];
440 * @brief Subscript access to the data contained in the %string.
441 * @param pos The index of the character to access.
442 * @return Read/write reference to the character.
444 * This operator allows for easy, array-style, data access.
445 * Note that data access with this operator is unchecked and
446 * out_of_range lookups are not defined. (For checked lookups
447 * see at().) Unshares the string.
449 reference
450 operator[](size_type __pos)
452 _GLIBCXX_DEBUG_ASSERT(__pos < this->size());
453 this->_M_leak();
454 return this->_M_data()[__pos];
458 * @brief Provides access to the data contained in the %string.
459 * @param n The index of the character to access.
460 * @return Read-only (const) reference to the character.
461 * @throw std::out_of_range If @a n is an invalid index.
463 * This function provides for safer data access. The parameter is
464 * first checked that it is in the range of the string. The function
465 * throws out_of_range if the check fails.
467 const_reference
468 at(size_type __n) const
470 if (__n >= this->size())
471 std::__throw_out_of_range(__N("__versa_string::at"));
472 return this->_M_data()[__n];
476 * @brief Provides access to the data contained in the %string.
477 * @param n The index of the character to access.
478 * @return Read/write reference to the character.
479 * @throw std::out_of_range If @a n is an invalid index.
481 * This function provides for safer data access. The parameter is
482 * first checked that it is in the range of the string. The function
483 * throws out_of_range if the check fails. Success results in
484 * unsharing the string.
486 reference
487 at(size_type __n)
489 if (__n >= this->size())
490 std::__throw_out_of_range(__N("__versa_string::at"));
491 this->_M_leak();
492 return this->_M_data()[__n];
495 // Modifiers:
497 * @brief Append a string to this string.
498 * @param str The string to append.
499 * @return Reference to this string.
501 __versa_string&
502 operator+=(const __versa_string& __str)
503 { return this->append(__str); }
506 * @brief Append a C string.
507 * @param s The C string to append.
508 * @return Reference to this string.
510 __versa_string&
511 operator+=(const _CharT* __s)
512 { return this->append(__s); }
515 * @brief Append a character.
516 * @param c The character to append.
517 * @return Reference to this string.
519 __versa_string&
520 operator+=(_CharT __c)
522 this->push_back(__c);
523 return *this;
527 * @brief Append a string to this string.
528 * @param str The string to append.
529 * @return Reference to this string.
531 __versa_string&
532 append(const __versa_string& __str)
533 { return _M_append(__str._M_data(), __str.size()); }
536 * @brief Append a substring.
537 * @param str The string to append.
538 * @param pos Index of the first character of str to append.
539 * @param n The number of characters to append.
540 * @return Reference to this string.
541 * @throw std::out_of_range if @a pos is not a valid index.
543 * This function appends @a n characters from @a str starting at @a pos
544 * to this string. If @a n is is larger than the number of available
545 * characters in @a str, the remainder of @a str is appended.
547 __versa_string&
548 append(const __versa_string& __str, size_type __pos, size_type __n)
549 { return _M_append(__str._M_data()
550 + __str._M_check(__pos, "__versa_string::append"),
551 __str._M_limit(__pos, __n)); }
554 * @brief Append a C substring.
555 * @param s The C string to append.
556 * @param n The number of characters to append.
557 * @return Reference to this string.
559 __versa_string&
560 append(const _CharT* __s, size_type __n)
562 __glibcxx_requires_string_len(__s, __n);
563 _M_check_length(size_type(0), __n, "__versa_string::append");
564 return _M_append(__s, __n);
568 * @brief Append a C string.
569 * @param s The C string to append.
570 * @return Reference to this string.
572 __versa_string&
573 append(const _CharT* __s)
575 __glibcxx_requires_string(__s);
576 const size_type __n = traits_type::length(__s);
577 _M_check_length(size_type(0), __n, "__versa_string::append");
578 return _M_append(__s, __n);
582 * @brief Append multiple characters.
583 * @param n The number of characters to append.
584 * @param c The character to use.
585 * @return Reference to this string.
587 * Appends n copies of c to this string.
589 __versa_string&
590 append(size_type __n, _CharT __c)
591 { return _M_replace_aux(this->size(), size_type(0), __n, __c); }
594 * @brief Append a range of characters.
595 * @param first Iterator referencing the first character to append.
596 * @param last Iterator marking the end of the range.
597 * @return Reference to this string.
599 * Appends characters in the range [first,last) to this string.
601 template<class _InputIterator>
602 __versa_string&
603 append(_InputIterator __first, _InputIterator __last)
604 { return this->replace(_M_iend(), _M_iend(), __first, __last); }
607 * @brief Append a single character.
608 * @param c Character to append.
610 void
611 push_back(_CharT __c)
613 const size_type __size = this->size();
614 if (__size + 1 > this->capacity() || this->_M_is_shared())
615 this->_M_mutate(__size, size_type(0), 0, size_type(1));
616 traits_type::assign(this->_M_data()[__size], __c);
617 this->_M_set_length(__size + 1);
621 * @brief Set value to contents of another string.
622 * @param str Source string to use.
623 * @return Reference to this string.
625 __versa_string&
626 assign(const __versa_string& __str)
628 this->_M_assign(__str);
629 return *this;
633 * @brief Set value to a substring of a string.
634 * @param str The string to use.
635 * @param pos Index of the first character of str.
636 * @param n Number of characters to use.
637 * @return Reference to this string.
638 * @throw std::out_of_range if @a pos is not a valid index.
640 * This function sets this string to the substring of @a str consisting
641 * of @a n characters at @a pos. If @a n is is larger than the number
642 * of available characters in @a str, the remainder of @a str is used.
644 __versa_string&
645 assign(const __versa_string& __str, size_type __pos, size_type __n)
646 { return _M_replace(size_type(0), this->size(), __str._M_data()
647 + __str._M_check(__pos, "__versa_string::assign"),
648 __str._M_limit(__pos, __n)); }
651 * @brief Set value to a C substring.
652 * @param s The C string to use.
653 * @param n Number of characters to use.
654 * @return Reference to this string.
656 * This function sets the value of this string to the first @a n
657 * characters of @a s. If @a n is is larger than the number of
658 * available characters in @a s, the remainder of @a s is used.
660 __versa_string&
661 assign(const _CharT* __s, size_type __n)
663 __glibcxx_requires_string_len(__s, __n);
664 return _M_replace(size_type(0), this->size(), __s, __n);
668 * @brief Set value to contents of a C string.
669 * @param s The C string to use.
670 * @return Reference to this string.
672 * This function sets the value of this string to the value of @a s.
673 * The data is copied, so there is no dependence on @a s once the
674 * function returns.
676 __versa_string&
677 assign(const _CharT* __s)
679 __glibcxx_requires_string(__s);
680 return _M_replace(size_type(0), this->size(), __s,
681 traits_type::length(__s));
685 * @brief Set value to multiple characters.
686 * @param n Length of the resulting string.
687 * @param c The character to use.
688 * @return Reference to this string.
690 * This function sets the value of this string to @a n copies of
691 * character @a c.
693 __versa_string&
694 assign(size_type __n, _CharT __c)
695 { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
698 * @brief Set value to a range of characters.
699 * @param first Iterator referencing the first character to append.
700 * @param last Iterator marking the end of the range.
701 * @return Reference to this string.
703 * Sets value of string to characters in the range [first,last).
705 template<class _InputIterator>
706 __versa_string&
707 assign(_InputIterator __first, _InputIterator __last)
708 { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
711 * @brief Insert multiple characters.
712 * @param p Iterator referencing location in string to insert at.
713 * @param n Number of characters to insert
714 * @param c The character to insert.
715 * @throw std::length_error If new length exceeds @c max_size().
717 * Inserts @a n copies of character @a c starting at the position
718 * referenced by iterator @a p. If adding characters causes the length
719 * to exceed max_size(), length_error is thrown. The value of the
720 * string doesn't change if an error is thrown.
722 void
723 insert(iterator __p, size_type __n, _CharT __c)
724 { this->replace(__p, __p, __n, __c); }
727 * @brief Insert a range of characters.
728 * @param p Iterator referencing location in string to insert at.
729 * @param beg Start of range.
730 * @param end End of range.
731 * @throw std::length_error If new length exceeds @c max_size().
733 * Inserts characters in range [beg,end). If adding characters causes
734 * the length to exceed max_size(), length_error is thrown. The value
735 * of the string doesn't change if an error is thrown.
737 template<class _InputIterator>
738 void
739 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
740 { this->replace(__p, __p, __beg, __end); }
743 * @brief Insert value of a string.
744 * @param pos1 Iterator referencing location in string to insert at.
745 * @param str The string to insert.
746 * @return Reference to this string.
747 * @throw std::length_error If new length exceeds @c max_size().
749 * Inserts value of @a str starting at @a pos1. If adding characters
750 * causes the length to exceed max_size(), length_error is thrown. The
751 * value of the string doesn't change if an error is thrown.
753 __versa_string&
754 insert(size_type __pos1, const __versa_string& __str)
755 { return this->replace(__pos1, size_type(0),
756 __str._M_data(), __str.size()); }
759 * @brief Insert a substring.
760 * @param pos1 Iterator referencing location in string to insert at.
761 * @param str The string to insert.
762 * @param pos2 Start of characters in str to insert.
763 * @param n Number of characters to insert.
764 * @return Reference to this string.
765 * @throw std::length_error If new length exceeds @c max_size().
766 * @throw std::out_of_range If @a pos1 > size() or
767 * @a pos2 > @a str.size().
769 * Starting at @a pos1, insert @a n character of @a str beginning with
770 * @a pos2. If adding characters causes the length to exceed
771 * max_size(), length_error is thrown. If @a pos1 is beyond the end of
772 * this string or @a pos2 is beyond the end of @a str, out_of_range is
773 * thrown. The value of the string doesn't change if an error is
774 * thrown.
776 __versa_string&
777 insert(size_type __pos1, const __versa_string& __str,
778 size_type __pos2, size_type __n)
779 { return this->replace(__pos1, size_type(0), __str._M_data()
780 + __str._M_check(__pos2, "__versa_string::insert"),
781 __str._M_limit(__pos2, __n)); }
784 * @brief Insert a C substring.
785 * @param pos Iterator referencing location in string to insert at.
786 * @param s The C string to insert.
787 * @param n The number of characters to insert.
788 * @return Reference to this string.
789 * @throw std::length_error If new length exceeds @c max_size().
790 * @throw std::out_of_range If @a pos is beyond the end of this
791 * string.
793 * Inserts the first @a n characters of @a s starting at @a pos. If
794 * adding characters causes the length to exceed max_size(),
795 * length_error is thrown. If @a pos is beyond end(), out_of_range is
796 * thrown. The value of the string doesn't change if an error is
797 * thrown.
799 __versa_string&
800 insert(size_type __pos, const _CharT* __s, size_type __n)
801 { return this->replace(__pos, size_type(0), __s, __n); }
804 * @brief Insert a C string.
805 * @param pos Iterator referencing location in string to insert at.
806 * @param s The C string to insert.
807 * @return Reference to this string.
808 * @throw std::length_error If new length exceeds @c max_size().
809 * @throw std::out_of_range If @a pos is beyond the end of this
810 * string.
812 * Inserts the first @a n characters of @a s starting at @a pos. If
813 * adding characters causes the length to exceed max_size(),
814 * length_error is thrown. If @a pos is beyond end(), out_of_range is
815 * thrown. The value of the string doesn't change if an error is
816 * thrown.
818 __versa_string&
819 insert(size_type __pos, const _CharT* __s)
821 __glibcxx_requires_string(__s);
822 return this->replace(__pos, size_type(0), __s,
823 traits_type::length(__s));
827 * @brief Insert multiple characters.
828 * @param pos Index in string to insert at.
829 * @param n Number of characters to insert
830 * @param c The character to insert.
831 * @return Reference to this string.
832 * @throw std::length_error If new length exceeds @c max_size().
833 * @throw std::out_of_range If @a pos is beyond the end of this
834 * string.
836 * Inserts @a n copies of character @a c starting at index @a pos. If
837 * adding characters causes the length to exceed max_size(),
838 * length_error is thrown. If @a pos > length(), out_of_range is
839 * thrown. The value of the string doesn't change if an error is
840 * thrown.
842 __versa_string&
843 insert(size_type __pos, size_type __n, _CharT __c)
844 { return _M_replace_aux(_M_check(__pos, "__versa_string::insert"),
845 size_type(0), __n, __c); }
848 * @brief Insert one character.
849 * @param p Iterator referencing position in string to insert at.
850 * @param c The character to insert.
851 * @return Iterator referencing newly inserted char.
852 * @throw std::length_error If new length exceeds @c max_size().
854 * Inserts character @a c at position referenced by @a p. If adding
855 * character causes the length to exceed max_size(), length_error is
856 * thrown. If @a p is beyond end of string, out_of_range is thrown.
857 * The value of the string doesn't change if an error is thrown.
859 iterator
860 insert(iterator __p, _CharT __c)
862 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
863 const size_type __pos = __p - _M_ibegin();
864 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
865 this->_M_set_leaked();
866 return iterator(this->_M_data() + __pos);
870 * @brief Remove characters.
871 * @param pos Index of first character to remove (default 0).
872 * @param n Number of characters to remove (default remainder).
873 * @return Reference to this string.
874 * @throw std::out_of_range If @a pos is beyond the end of this
875 * string.
877 * Removes @a n characters from this string starting at @a pos. The
878 * length of the string is reduced by @a n. If there are < @a n
879 * characters to remove, the remainder of the string is truncated. If
880 * @a p is beyond end of string, out_of_range is thrown. The value of
881 * the string doesn't change if an error is thrown.
883 __versa_string&
884 erase(size_type __pos = 0, size_type __n = npos)
886 this->_M_erase(_M_check(__pos, "__versa_string::erase"),
887 _M_limit(__pos, __n));
888 return *this;
892 * @brief Remove one character.
893 * @param position Iterator referencing the character to remove.
894 * @return iterator referencing same location after removal.
896 * Removes the character at @a position from this string. The value
897 * of the string doesn't change if an error is thrown.
899 iterator
900 erase(iterator __position)
902 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
903 && __position < _M_iend());
904 const size_type __pos = __position - _M_ibegin();
905 this->_M_erase(__pos, size_type(1));
906 this->_M_set_leaked();
907 return iterator(this->_M_data() + __pos);
911 * @brief Remove a range of characters.
912 * @param first Iterator referencing the first character to remove.
913 * @param last Iterator referencing the end of the range.
914 * @return Iterator referencing location of first after removal.
916 * Removes the characters in the range [first,last) from this string.
917 * The value of the string doesn't change if an error is thrown.
919 iterator
920 erase(iterator __first, iterator __last)
922 _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
923 && __last <= _M_iend());
924 const size_type __pos = __first - _M_ibegin();
925 this->_M_erase(__pos, __last - __first);
926 this->_M_set_leaked();
927 return iterator(this->_M_data() + __pos);
931 * @brief Replace characters with value from another string.
932 * @param pos Index of first character to replace.
933 * @param n Number of characters to be replaced.
934 * @param str String to insert.
935 * @return Reference to this string.
936 * @throw std::out_of_range If @a pos is beyond the end of this
937 * string.
938 * @throw std::length_error If new length exceeds @c max_size().
940 * Removes the characters in the range [pos,pos+n) from this string.
941 * In place, the value of @a str is inserted. If @a pos is beyond end
942 * of string, out_of_range is thrown. If the length of the result
943 * exceeds max_size(), length_error is thrown. The value of the string
944 * doesn't change if an error is thrown.
946 __versa_string&
947 replace(size_type __pos, size_type __n, const __versa_string& __str)
948 { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
951 * @brief Replace characters with value from another string.
952 * @param pos1 Index of first character to replace.
953 * @param n1 Number of characters to be replaced.
954 * @param str String to insert.
955 * @param pos2 Index of first character of str to use.
956 * @param n2 Number of characters from str to use.
957 * @return Reference to this string.
958 * @throw std::out_of_range If @a pos1 > size() or @a pos2 >
959 * str.size().
960 * @throw std::length_error If new length exceeds @c max_size().
962 * Removes the characters in the range [pos1,pos1 + n) from this
963 * string. In place, the value of @a str is inserted. If @a pos is
964 * beyond end of string, out_of_range is thrown. If the length of the
965 * result exceeds max_size(), length_error is thrown. The value of the
966 * string doesn't change if an error is thrown.
968 __versa_string&
969 replace(size_type __pos1, size_type __n1, const __versa_string& __str,
970 size_type __pos2, size_type __n2)
972 return this->replace(__pos1, __n1, __str._M_data()
973 + __str._M_check(__pos2,
974 "__versa_string::replace"),
975 __str._M_limit(__pos2, __n2));
979 * @brief Replace characters with value of a C substring.
980 * @param pos Index of first character to replace.
981 * @param n1 Number of characters to be replaced.
982 * @param s C string to insert.
983 * @param n2 Number of characters from @a s to use.
984 * @return Reference to this string.
985 * @throw std::out_of_range If @a pos1 > size().
986 * @throw std::length_error If new length exceeds @c max_size().
988 * Removes the characters in the range [pos,pos + n1) from this string.
989 * In place, the first @a n2 characters of @a s are inserted, or all
990 * of @a s if @a n2 is too large. If @a pos is beyond end of string,
991 * out_of_range is thrown. If the length of result exceeds max_size(),
992 * length_error is thrown. The value of the string doesn't change if
993 * an error is thrown.
995 __versa_string&
996 replace(size_type __pos, size_type __n1, const _CharT* __s,
997 size_type __n2)
999 __glibcxx_requires_string_len(__s, __n2);
1000 return _M_replace(_M_check(__pos, "__versa_string::replace"),
1001 _M_limit(__pos, __n1), __s, __n2);
1005 * @brief Replace characters with value of a C string.
1006 * @param pos Index of first character to replace.
1007 * @param n1 Number of characters to be replaced.
1008 * @param s C string to insert.
1009 * @return Reference to this string.
1010 * @throw std::out_of_range If @a pos > size().
1011 * @throw std::length_error If new length exceeds @c max_size().
1013 * Removes the characters in the range [pos,pos + n1) from this string.
1014 * In place, the first @a n characters of @a s are inserted. If @a
1015 * pos is beyond end of string, out_of_range is thrown. If the length
1016 * of result exceeds max_size(), length_error is thrown. The value of
1017 * the string doesn't change if an error is thrown.
1019 __versa_string&
1020 replace(size_type __pos, size_type __n1, const _CharT* __s)
1022 __glibcxx_requires_string(__s);
1023 return this->replace(__pos, __n1, __s, traits_type::length(__s));
1027 * @brief Replace characters with multiple characters.
1028 * @param pos Index of first character to replace.
1029 * @param n1 Number of characters to be replaced.
1030 * @param n2 Number of characters to insert.
1031 * @param c Character to insert.
1032 * @return Reference to this string.
1033 * @throw std::out_of_range If @a pos > size().
1034 * @throw std::length_error If new length exceeds @c max_size().
1036 * Removes the characters in the range [pos,pos + n1) from this string.
1037 * In place, @a n2 copies of @a c are inserted. If @a pos is beyond
1038 * end of string, out_of_range is thrown. If the length of result
1039 * exceeds max_size(), length_error is thrown. The value of the string
1040 * doesn't change if an error is thrown.
1042 __versa_string&
1043 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1044 { return _M_replace_aux(_M_check(__pos, "__versa_string::replace"),
1045 _M_limit(__pos, __n1), __n2, __c); }
1048 * @brief Replace range of characters with string.
1049 * @param i1 Iterator referencing start of range to replace.
1050 * @param i2 Iterator referencing end of range to replace.
1051 * @param str String value to insert.
1052 * @return Reference to this string.
1053 * @throw std::length_error If new length exceeds @c max_size().
1055 * Removes the characters in the range [i1,i2). In place, the value of
1056 * @a str is inserted. If the length of result exceeds max_size(),
1057 * length_error is thrown. The value of the string doesn't change if
1058 * an error is thrown.
1060 __versa_string&
1061 replace(iterator __i1, iterator __i2, const __versa_string& __str)
1062 { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
1065 * @brief Replace range of characters with C substring.
1066 * @param i1 Iterator referencing start of range to replace.
1067 * @param i2 Iterator referencing end of range to replace.
1068 * @param s C string value to insert.
1069 * @param n Number of characters from s to insert.
1070 * @return Reference to this string.
1071 * @throw std::length_error If new length exceeds @c max_size().
1073 * Removes the characters in the range [i1,i2). In place, the first @a
1074 * n characters of @a s are inserted. If the length of result exceeds
1075 * max_size(), length_error is thrown. The value of the string doesn't
1076 * change if an error is thrown.
1078 __versa_string&
1079 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
1081 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1082 && __i2 <= _M_iend());
1083 return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
1087 * @brief Replace range of characters with C string.
1088 * @param i1 Iterator referencing start of range to replace.
1089 * @param i2 Iterator referencing end of range to replace.
1090 * @param s C string value to insert.
1091 * @return Reference to this string.
1092 * @throw std::length_error If new length exceeds @c max_size().
1094 * Removes the characters in the range [i1,i2). In place, the
1095 * characters of @a s are inserted. If the length of result exceeds
1096 * max_size(), length_error is thrown. The value of the string doesn't
1097 * change if an error is thrown.
1099 __versa_string&
1100 replace(iterator __i1, iterator __i2, const _CharT* __s)
1102 __glibcxx_requires_string(__s);
1103 return this->replace(__i1, __i2, __s, traits_type::length(__s));
1107 * @brief Replace range of characters with multiple characters
1108 * @param i1 Iterator referencing start of range to replace.
1109 * @param i2 Iterator referencing end of range to replace.
1110 * @param n Number of characters to insert.
1111 * @param c Character to insert.
1112 * @return Reference to this string.
1113 * @throw std::length_error If new length exceeds @c max_size().
1115 * Removes the characters in the range [i1,i2). In place, @a n copies
1116 * of @a c are inserted. If the length of result exceeds max_size(),
1117 * length_error is thrown. The value of the string doesn't change if
1118 * an error is thrown.
1120 __versa_string&
1121 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
1123 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1124 && __i2 <= _M_iend());
1125 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
1129 * @brief Replace range of characters with range.
1130 * @param i1 Iterator referencing start of range to replace.
1131 * @param i2 Iterator referencing end of range to replace.
1132 * @param k1 Iterator referencing start of range to insert.
1133 * @param k2 Iterator referencing end of range to insert.
1134 * @return Reference to this string.
1135 * @throw std::length_error If new length exceeds @c max_size().
1137 * Removes the characters in the range [i1,i2). In place, characters
1138 * in the range [k1,k2) are inserted. If the length of result exceeds
1139 * max_size(), length_error is thrown. The value of the string doesn't
1140 * change if an error is thrown.
1142 template<class _InputIterator>
1143 __versa_string&
1144 replace(iterator __i1, iterator __i2,
1145 _InputIterator __k1, _InputIterator __k2)
1147 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1148 && __i2 <= _M_iend());
1149 __glibcxx_requires_valid_range(__k1, __k2);
1150 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1151 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1154 // Specializations for the common case of pointer and iterator:
1155 // useful to avoid the overhead of temporary buffering in _M_replace.
1156 __versa_string&
1157 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
1159 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1160 && __i2 <= _M_iend());
1161 __glibcxx_requires_valid_range(__k1, __k2);
1162 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1163 __k1, __k2 - __k1);
1166 __versa_string&
1167 replace(iterator __i1, iterator __i2,
1168 const _CharT* __k1, const _CharT* __k2)
1170 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1171 && __i2 <= _M_iend());
1172 __glibcxx_requires_valid_range(__k1, __k2);
1173 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1174 __k1, __k2 - __k1);
1177 __versa_string&
1178 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
1180 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1181 && __i2 <= _M_iend());
1182 __glibcxx_requires_valid_range(__k1, __k2);
1183 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1184 __k1.base(), __k2 - __k1);
1187 __versa_string&
1188 replace(iterator __i1, iterator __i2,
1189 const_iterator __k1, const_iterator __k2)
1191 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1192 && __i2 <= _M_iend());
1193 __glibcxx_requires_valid_range(__k1, __k2);
1194 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1195 __k1.base(), __k2 - __k1);
1198 private:
1199 template<class _Integer>
1200 __versa_string&
1201 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
1202 _Integer __val, __true_type)
1203 { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
1205 template<class _InputIterator>
1206 __versa_string&
1207 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
1208 _InputIterator __k2, __false_type);
1210 __versa_string&
1211 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1212 _CharT __c);
1214 __versa_string&
1215 _M_replace(size_type __pos, size_type __len1, const _CharT* __s,
1216 const size_type __len2);
1218 __versa_string&
1219 _M_append(const _CharT* __s, size_type __n);
1221 public:
1224 * @brief Copy substring into C string.
1225 * @param s C string to copy value into.
1226 * @param n Number of characters to copy.
1227 * @param pos Index of first character to copy.
1228 * @return Number of characters actually copied
1229 * @throw std::out_of_range If pos > size().
1231 * Copies up to @a n characters starting at @a pos into the C string @a
1232 * s. If @a pos is greater than size(), out_of_range is thrown.
1234 size_type
1235 copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
1238 * @brief Swap contents with another string.
1239 * @param s String to swap with.
1241 * Exchanges the contents of this string with that of @a s in constant
1242 * time.
1244 void
1245 swap(__versa_string& __s)
1246 { this->_M_swap(__s); }
1248 // String operations:
1250 * @brief Return const pointer to null-terminated contents.
1252 * This is a handle to internal data. Do not modify or dire things may
1253 * happen.
1255 const _CharT*
1256 c_str() const
1257 { return this->_M_data(); }
1260 * @brief Return const pointer to contents.
1262 * This is a handle to internal data. Do not modify or dire things may
1263 * happen.
1265 const _CharT*
1266 data() const
1267 { return this->_M_data(); }
1270 * @brief Return copy of allocator used to construct this string.
1272 allocator_type
1273 get_allocator() const
1274 { return allocator_type(this->_M_get_allocator()); }
1277 * @brief Find position of a C substring.
1278 * @param s C string to locate.
1279 * @param pos Index of character to search from.
1280 * @param n Number of characters from @a s to search for.
1281 * @return Index of start of first occurrence.
1283 * Starting from @a pos, searches forward for the first @a n characters
1284 * in @a s within this string. If found, returns the index where it
1285 * begins. If not found, returns npos.
1287 size_type
1288 find(const _CharT* __s, size_type __pos, size_type __n) const;
1291 * @brief Find position of a string.
1292 * @param str String to locate.
1293 * @param pos Index of character to search from (default 0).
1294 * @return Index of start of first occurrence.
1296 * Starting from @a pos, searches forward for value of @a str within
1297 * this string. If found, returns the index where it begins. If not
1298 * found, returns npos.
1300 size_type
1301 find(const __versa_string& __str, size_type __pos = 0) const
1302 { return this->find(__str.data(), __pos, __str.size()); }
1305 * @brief Find position of a C string.
1306 * @param s C string to locate.
1307 * @param pos Index of character to search from (default 0).
1308 * @return Index of start of first occurrence.
1310 * Starting from @a pos, searches forward for the value of @a s within
1311 * this string. If found, returns the index where it begins. If not
1312 * found, returns npos.
1314 size_type
1315 find(const _CharT* __s, size_type __pos = 0) const
1317 __glibcxx_requires_string(__s);
1318 return this->find(__s, __pos, traits_type::length(__s));
1322 * @brief Find position of a character.
1323 * @param c Character to locate.
1324 * @param pos Index of character to search from (default 0).
1325 * @return Index of first occurrence.
1327 * Starting from @a pos, searches forward for @a c within this string.
1328 * If found, returns the index where it was found. If not found,
1329 * returns npos.
1331 size_type
1332 find(_CharT __c, size_type __pos = 0) const;
1335 * @brief Find last position of a string.
1336 * @param str String to locate.
1337 * @param pos Index of character to search back from (default end).
1338 * @return Index of start of last occurrence.
1340 * Starting from @a pos, searches backward for value of @a str within
1341 * this string. If found, returns the index where it begins. If not
1342 * found, returns npos.
1344 size_type
1345 rfind(const __versa_string& __str, size_type __pos = npos) const
1346 { return this->rfind(__str.data(), __pos, __str.size()); }
1349 * @brief Find last position of a C substring.
1350 * @param s C string to locate.
1351 * @param pos Index of character to search back from.
1352 * @param n Number of characters from s to search for.
1353 * @return Index of start of last occurrence.
1355 * Starting from @a pos, searches backward for the first @a n
1356 * characters in @a s within this string. If found, returns the index
1357 * where it begins. If not found, returns npos.
1359 size_type
1360 rfind(const _CharT* __s, size_type __pos, size_type __n) const;
1363 * @brief Find last position of a C string.
1364 * @param s C string to locate.
1365 * @param pos Index of character to start search at (default 0).
1366 * @return Index of start of last occurrence.
1368 * Starting from @a pos, searches backward for the value of @a s within
1369 * this string. If found, returns the index where it begins. If not
1370 * found, returns npos.
1372 size_type
1373 rfind(const _CharT* __s, size_type __pos = npos) const
1375 __glibcxx_requires_string(__s);
1376 return this->rfind(__s, __pos, traits_type::length(__s));
1380 * @brief Find last position of a character.
1381 * @param c Character to locate.
1382 * @param pos Index of character to search back from (default 0).
1383 * @return Index of last occurrence.
1385 * Starting from @a pos, searches backward for @a c within this string.
1386 * If found, returns the index where it was found. If not found,
1387 * returns npos.
1389 size_type
1390 rfind(_CharT __c, size_type __pos = npos) const;
1393 * @brief Find position of a character of string.
1394 * @param str String containing characters to locate.
1395 * @param pos Index of character to search from (default 0).
1396 * @return Index of first occurrence.
1398 * Starting from @a pos, searches forward for one of the characters of
1399 * @a str within this string. If found, returns the index where it was
1400 * found. If not found, returns npos.
1402 size_type
1403 find_first_of(const __versa_string& __str, size_type __pos = 0) const
1404 { return this->find_first_of(__str.data(), __pos, __str.size()); }
1407 * @brief Find position of a character of C substring.
1408 * @param s String containing characters to locate.
1409 * @param pos Index of character to search from (default 0).
1410 * @param n Number of characters from s to search for.
1411 * @return Index of first occurrence.
1413 * Starting from @a pos, searches forward for one of the first @a n
1414 * characters of @a s within this string. If found, returns the index
1415 * where it was found. If not found, returns npos.
1417 size_type
1418 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
1421 * @brief Find position of a character of C string.
1422 * @param s String containing characters to locate.
1423 * @param pos Index of character to search from (default 0).
1424 * @return Index of first occurrence.
1426 * Starting from @a pos, searches forward for one of the characters of
1427 * @a s within this string. If found, returns the index where it was
1428 * found. If not found, returns npos.
1430 size_type
1431 find_first_of(const _CharT* __s, size_type __pos = 0) const
1433 __glibcxx_requires_string(__s);
1434 return this->find_first_of(__s, __pos, traits_type::length(__s));
1438 * @brief Find position of a character.
1439 * @param c Character to locate.
1440 * @param pos Index of character to search from (default 0).
1441 * @return Index of first occurrence.
1443 * Starting from @a pos, searches forward for the character @a c within
1444 * this string. If found, returns the index where it was found. If
1445 * not found, returns npos.
1447 * Note: equivalent to find(c, pos).
1449 size_type
1450 find_first_of(_CharT __c, size_type __pos = 0) const
1451 { return this->find(__c, __pos); }
1454 * @brief Find last position of a character of string.
1455 * @param str String containing characters to locate.
1456 * @param pos Index of character to search back from (default end).
1457 * @return Index of last occurrence.
1459 * Starting from @a pos, searches backward for one of the characters of
1460 * @a str within this string. If found, returns the index where it was
1461 * found. If not found, returns npos.
1463 size_type
1464 find_last_of(const __versa_string& __str, size_type __pos = npos) const
1465 { return this->find_last_of(__str.data(), __pos, __str.size()); }
1468 * @brief Find last position of a character of C substring.
1469 * @param s C string containing characters to locate.
1470 * @param pos Index of character to search back from (default end).
1471 * @param n Number of characters from s to search for.
1472 * @return Index of last occurrence.
1474 * Starting from @a pos, searches backward for one of the first @a n
1475 * characters of @a s within this string. If found, returns the index
1476 * where it was found. If not found, returns npos.
1478 size_type
1479 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
1482 * @brief Find last position of a character of C string.
1483 * @param s C string containing characters to locate.
1484 * @param pos Index of character to search back from (default end).
1485 * @return Index of last occurrence.
1487 * Starting from @a pos, searches backward for one of the characters of
1488 * @a s within this string. If found, returns the index where it was
1489 * found. If not found, returns npos.
1491 size_type
1492 find_last_of(const _CharT* __s, size_type __pos = npos) const
1494 __glibcxx_requires_string(__s);
1495 return this->find_last_of(__s, __pos, traits_type::length(__s));
1499 * @brief Find last position of a character.
1500 * @param c Character to locate.
1501 * @param pos Index of character to search back from (default 0).
1502 * @return Index of last occurrence.
1504 * Starting from @a pos, searches backward for @a c within this string.
1505 * If found, returns the index where it was found. If not found,
1506 * returns npos.
1508 * Note: equivalent to rfind(c, pos).
1510 size_type
1511 find_last_of(_CharT __c, size_type __pos = npos) const
1512 { return this->rfind(__c, __pos); }
1515 * @brief Find position of a character not in string.
1516 * @param str String containing characters to avoid.
1517 * @param pos Index of character to search from (default 0).
1518 * @return Index of first occurrence.
1520 * Starting from @a pos, searches forward for a character not contained
1521 * in @a str within this string. If found, returns the index where it
1522 * was found. If not found, returns npos.
1524 size_type
1525 find_first_not_of(const __versa_string& __str, size_type __pos = 0) const
1526 { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
1529 * @brief Find position of a character not in C substring.
1530 * @param s C string containing characters to avoid.
1531 * @param pos Index of character to search from (default 0).
1532 * @param n Number of characters from s to consider.
1533 * @return Index of first occurrence.
1535 * Starting from @a pos, searches forward for a character not contained
1536 * in the first @a n characters of @a s within this string. If found,
1537 * returns the index where it was found. If not found, returns npos.
1539 size_type
1540 find_first_not_of(const _CharT* __s, size_type __pos,
1541 size_type __n) const;
1544 * @brief Find position of a character not in C string.
1545 * @param s C string containing characters to avoid.
1546 * @param pos Index of character to search from (default 0).
1547 * @return Index of first occurrence.
1549 * Starting from @a pos, searches forward for a character not contained
1550 * in @a s within this string. If found, returns the index where it
1551 * was found. If not found, returns npos.
1553 size_type
1554 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
1556 __glibcxx_requires_string(__s);
1557 return this->find_first_not_of(__s, __pos, traits_type::length(__s));
1561 * @brief Find position of a different character.
1562 * @param c Character to avoid.
1563 * @param pos Index of character to search from (default 0).
1564 * @return Index of first occurrence.
1566 * Starting from @a pos, searches forward for a character other than @a c
1567 * within this string. If found, returns the index where it was found.
1568 * If not found, returns npos.
1570 size_type
1571 find_first_not_of(_CharT __c, size_type __pos = 0) const;
1574 * @brief Find last position of a character not in string.
1575 * @param str String containing characters to avoid.
1576 * @param pos Index of character to search from (default 0).
1577 * @return Index of first occurrence.
1579 * Starting from @a pos, searches backward for a character not
1580 * contained in @a str within this string. If found, returns the index
1581 * where it was found. If not found, returns npos.
1583 size_type
1584 find_last_not_of(const __versa_string& __str,
1585 size_type __pos = npos) const
1586 { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
1589 * @brief Find last position of a character not in C substring.
1590 * @param s C string containing characters to avoid.
1591 * @param pos Index of character to search from (default 0).
1592 * @param n Number of characters from s to consider.
1593 * @return Index of first occurrence.
1595 * Starting from @a pos, searches backward for a character not
1596 * contained in the first @a n characters of @a s within this string.
1597 * If found, returns the index where it was found. If not found,
1598 * returns npos.
1600 size_type
1601 find_last_not_of(const _CharT* __s, size_type __pos,
1602 size_type __n) const;
1604 * @brief Find position of a character not in C string.
1605 * @param s C string containing characters to avoid.
1606 * @param pos Index of character to search from (default 0).
1607 * @return Index of first occurrence.
1609 * Starting from @a pos, searches backward for a character not
1610 * contained in @a s within this string. If found, returns the index
1611 * where it was found. If not found, returns npos.
1613 size_type
1614 find_last_not_of(const _CharT* __s, size_type __pos = npos) const
1616 __glibcxx_requires_string(__s);
1617 return this->find_last_not_of(__s, __pos, traits_type::length(__s));
1621 * @brief Find last position of a different character.
1622 * @param c Character to avoid.
1623 * @param pos Index of character to search from (default 0).
1624 * @return Index of first occurrence.
1626 * Starting from @a pos, searches backward for a character other than
1627 * @a c within this string. If found, returns the index where it was
1628 * found. If not found, returns npos.
1630 size_type
1631 find_last_not_of(_CharT __c, size_type __pos = npos) const;
1634 * @brief Get a substring.
1635 * @param pos Index of first character (default 0).
1636 * @param n Number of characters in substring (default remainder).
1637 * @return The new string.
1638 * @throw std::out_of_range If pos > size().
1640 * Construct and return a new string using the @a n characters starting
1641 * at @a pos. If the string is too short, use the remainder of the
1642 * characters. If @a pos is beyond the end of the string, out_of_range
1643 * is thrown.
1645 __versa_string
1646 substr(size_type __pos = 0, size_type __n = npos) const
1648 return __versa_string(*this, _M_check(__pos, "__versa_string::substr"),
1649 __n);
1653 * @brief Compare to a string.
1654 * @param str String to compare against.
1655 * @return Integer < 0, 0, or > 0.
1657 * Returns an integer < 0 if this string is ordered before @a str, 0 if
1658 * their values are equivalent, or > 0 if this string is ordered after
1659 * @a str. Determines the effective length rlen of the strings to
1660 * compare as the smallest of size() and str.size(). The function
1661 * then compares the two strings by calling traits::compare(data(),
1662 * str.data(),rlen). If the result of the comparison is nonzero returns
1663 * it, otherwise the shorter one is ordered first.
1666 compare(const __versa_string& __str) const
1668 if (this->_M_compare(__str))
1669 return 0;
1671 const size_type __size = this->size();
1672 const size_type __osize = __str.size();
1673 const size_type __len = std::min(__size, __osize);
1675 int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
1676 if (!__r)
1677 __r = __size - __osize;
1678 return __r;
1682 * @brief Compare substring to a string.
1683 * @param pos Index of first character of substring.
1684 * @param n Number of characters in substring.
1685 * @param str String to compare against.
1686 * @return Integer < 0, 0, or > 0.
1688 * Form the substring of this string from the @a n characters starting
1689 * at @a pos. Returns an integer < 0 if the substring is ordered
1690 * before @a str, 0 if their values are equivalent, or > 0 if the
1691 * substring is ordered after @a str. Determines the effective length
1692 * rlen of the strings to compare as the smallest of the length of the
1693 * substring and @a str.size(). The function then compares the two
1694 * strings by calling traits::compare(substring.data(),str.data(),rlen).
1695 * If the result of the comparison is nonzero returns it, otherwise the
1696 * shorter one is ordered first.
1699 compare(size_type __pos, size_type __n,
1700 const __versa_string& __str) const;
1703 * @brief Compare substring to a substring.
1704 * @param pos1 Index of first character of substring.
1705 * @param n1 Number of characters in substring.
1706 * @param str String to compare against.
1707 * @param pos2 Index of first character of substring of str.
1708 * @param n2 Number of characters in substring of str.
1709 * @return Integer < 0, 0, or > 0.
1711 * Form the substring of this string from the @a n1 characters starting
1712 * at @a pos1. Form the substring of @a str from the @a n2 characters
1713 * starting at @a pos2. Returns an integer < 0 if this substring is
1714 * ordered before the substring of @a str, 0 if their values are
1715 * equivalent, or > 0 if this substring is ordered after the substring
1716 * of @a str. Determines the effective length rlen of the strings
1717 * to compare as the smallest of the lengths of the substrings. The
1718 * function then compares the two strings by calling
1719 * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen).
1720 * If the result of the comparison is nonzero returns it, otherwise the
1721 * shorter one is ordered first.
1724 compare(size_type __pos1, size_type __n1, const __versa_string& __str,
1725 size_type __pos2, size_type __n2) const;
1728 * @brief Compare to a C string.
1729 * @param s C string to compare against.
1730 * @return Integer < 0, 0, or > 0.
1732 * Returns an integer < 0 if this string is ordered before @a s, 0 if
1733 * their values are equivalent, or > 0 if this string is ordered after
1734 * @a s. Determines the effective length rlen of the strings to
1735 * compare as the smallest of size() and the length of a string
1736 * constructed from @a s. The function then compares the two strings
1737 * by calling traits::compare(data(),s,rlen). If the result of the
1738 * comparison is nonzero returns it, otherwise the shorter one is
1739 * ordered first.
1742 compare(const _CharT* __s) const;
1744 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1745 // 5 String::compare specification questionable
1747 * @brief Compare substring to a C string.
1748 * @param pos Index of first character of substring.
1749 * @param n1 Number of characters in substring.
1750 * @param s C string to compare against.
1751 * @return Integer < 0, 0, or > 0.
1753 * Form the substring of this string from the @a n1 characters starting
1754 * at @a pos. Returns an integer < 0 if the substring is ordered
1755 * before @a s, 0 if their values are equivalent, or > 0 if the
1756 * substring is ordered after @a s. Determines the effective length
1757 * rlen of the strings to compare as the smallest of the length of the
1758 * substring and the length of a string constructed from @a s. The
1759 * function then compares the two string by calling
1760 * traits::compare(substring.data(),s,rlen). If the result of the
1761 * comparison is nonzero returns it, otherwise the shorter one is
1762 * ordered first.
1765 compare(size_type __pos, size_type __n1, const _CharT* __s) const;
1768 * @brief Compare substring against a character array.
1769 * @param pos1 Index of first character of substring.
1770 * @param n1 Number of characters in substring.
1771 * @param s character array to compare against.
1772 * @param n2 Number of characters of s.
1773 * @return Integer < 0, 0, or > 0.
1775 * Form the substring of this string from the @a n1 characters starting
1776 * at @a pos1. Form a string from the first @a n2 characters of @a s.
1777 * Returns an integer < 0 if this substring is ordered before the string
1778 * from @a s, 0 if their values are equivalent, or > 0 if this substring
1779 * is ordered after the string from @a s. Determines the effective
1780 * length rlen of the strings to compare as the smallest of the length
1781 * of the substring and @a n2. The function then compares the two
1782 * strings by calling traits::compare(substring.data(),s,rlen). If the
1783 * result of the comparison is nonzero returns it, otherwise the shorter
1784 * one is ordered first.
1786 * NB: s must have at least n2 characters, '\0' has no special
1787 * meaning.
1790 compare(size_type __pos, size_type __n1, const _CharT* __s,
1791 size_type __n2) const;
1794 // operator+
1796 * @brief Concatenate two strings.
1797 * @param lhs First string.
1798 * @param rhs Last string.
1799 * @return New string with value of @a lhs followed by @a rhs.
1801 template<typename _CharT, typename _Traits, typename _Alloc,
1802 template <typename, typename, typename> class _Base>
1803 __versa_string<_CharT, _Traits, _Alloc, _Base>
1804 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1805 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
1808 * @brief Concatenate C string and string.
1809 * @param lhs First string.
1810 * @param rhs Last string.
1811 * @return New string with value of @a lhs followed by @a rhs.
1813 template<typename _CharT, typename _Traits, typename _Alloc,
1814 template <typename, typename, typename> class _Base>
1815 __versa_string<_CharT, _Traits, _Alloc, _Base>
1816 operator+(const _CharT* __lhs,
1817 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
1820 * @brief Concatenate character and string.
1821 * @param lhs First string.
1822 * @param rhs Last string.
1823 * @return New string with @a lhs followed by @a rhs.
1825 template<typename _CharT, typename _Traits, typename _Alloc,
1826 template <typename, typename, typename> class _Base>
1827 __versa_string<_CharT, _Traits, _Alloc, _Base>
1828 operator+(_CharT __lhs,
1829 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
1832 * @brief Concatenate string and C string.
1833 * @param lhs First string.
1834 * @param rhs Last string.
1835 * @return New string with @a lhs followed by @a rhs.
1837 template<typename _CharT, typename _Traits, typename _Alloc,
1838 template <typename, typename, typename> class _Base>
1839 __versa_string<_CharT, _Traits, _Alloc, _Base>
1840 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1841 const _CharT* __rhs);
1844 * @brief Concatenate string and character.
1845 * @param lhs First string.
1846 * @param rhs Last string.
1847 * @return New string with @a lhs followed by @a rhs.
1849 template<typename _CharT, typename _Traits, typename _Alloc,
1850 template <typename, typename, typename> class _Base>
1851 __versa_string<_CharT, _Traits, _Alloc, _Base>
1852 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1853 _CharT __rhs);
1855 // operator ==
1857 * @brief Test equivalence of two strings.
1858 * @param lhs First string.
1859 * @param rhs Second string.
1860 * @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
1862 template<typename _CharT, typename _Traits, typename _Alloc,
1863 template <typename, typename, typename> class _Base>
1864 inline bool
1865 operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1866 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1867 { return __lhs.compare(__rhs) == 0; }
1870 * @brief Test equivalence of C string and string.
1871 * @param lhs C string.
1872 * @param rhs String.
1873 * @return True if @a rhs.compare(@a lhs) == 0. False otherwise.
1875 template<typename _CharT, typename _Traits, typename _Alloc,
1876 template <typename, typename, typename> class _Base>
1877 inline bool
1878 operator==(const _CharT* __lhs,
1879 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1880 { return __rhs.compare(__lhs) == 0; }
1883 * @brief Test equivalence of string and C string.
1884 * @param lhs String.
1885 * @param rhs C string.
1886 * @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
1888 template<typename _CharT, typename _Traits, typename _Alloc,
1889 template <typename, typename, typename> class _Base>
1890 inline bool
1891 operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1892 const _CharT* __rhs)
1893 { return __lhs.compare(__rhs) == 0; }
1895 // operator !=
1897 * @brief Test difference of two strings.
1898 * @param lhs First string.
1899 * @param rhs Second string.
1900 * @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
1902 template<typename _CharT, typename _Traits, typename _Alloc,
1903 template <typename, typename, typename> class _Base>
1904 inline bool
1905 operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1906 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1907 { return __rhs.compare(__lhs) != 0; }
1910 * @brief Test difference of C string and string.
1911 * @param lhs C string.
1912 * @param rhs String.
1913 * @return True if @a rhs.compare(@a lhs) != 0. False otherwise.
1915 template<typename _CharT, typename _Traits, typename _Alloc,
1916 template <typename, typename, typename> class _Base>
1917 inline bool
1918 operator!=(const _CharT* __lhs,
1919 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1920 { return __rhs.compare(__lhs) != 0; }
1923 * @brief Test difference of string and C string.
1924 * @param lhs String.
1925 * @param rhs C string.
1926 * @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
1928 template<typename _CharT, typename _Traits, typename _Alloc,
1929 template <typename, typename, typename> class _Base>
1930 inline bool
1931 operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1932 const _CharT* __rhs)
1933 { return __lhs.compare(__rhs) != 0; }
1935 // operator <
1937 * @brief Test if string precedes string.
1938 * @param lhs First string.
1939 * @param rhs Second string.
1940 * @return True if @a lhs precedes @a rhs. False otherwise.
1942 template<typename _CharT, typename _Traits, typename _Alloc,
1943 template <typename, typename, typename> class _Base>
1944 inline bool
1945 operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1946 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1947 { return __lhs.compare(__rhs) < 0; }
1950 * @brief Test if string precedes C string.
1951 * @param lhs String.
1952 * @param rhs C string.
1953 * @return True if @a lhs precedes @a rhs. False otherwise.
1955 template<typename _CharT, typename _Traits, typename _Alloc,
1956 template <typename, typename, typename> class _Base>
1957 inline bool
1958 operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1959 const _CharT* __rhs)
1960 { return __lhs.compare(__rhs) < 0; }
1963 * @brief Test if C string precedes string.
1964 * @param lhs C string.
1965 * @param rhs String.
1966 * @return True if @a lhs precedes @a rhs. False otherwise.
1968 template<typename _CharT, typename _Traits, typename _Alloc,
1969 template <typename, typename, typename> class _Base>
1970 inline bool
1971 operator<(const _CharT* __lhs,
1972 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1973 { return __rhs.compare(__lhs) > 0; }
1975 // operator >
1977 * @brief Test if string follows string.
1978 * @param lhs First string.
1979 * @param rhs Second string.
1980 * @return True if @a lhs follows @a rhs. False otherwise.
1982 template<typename _CharT, typename _Traits, typename _Alloc,
1983 template <typename, typename, typename> class _Base>
1984 inline bool
1985 operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1986 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1987 { return __lhs.compare(__rhs) > 0; }
1990 * @brief Test if string follows C string.
1991 * @param lhs String.
1992 * @param rhs C string.
1993 * @return True if @a lhs follows @a rhs. False otherwise.
1995 template<typename _CharT, typename _Traits, typename _Alloc,
1996 template <typename, typename, typename> class _Base>
1997 inline bool
1998 operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1999 const _CharT* __rhs)
2000 { return __lhs.compare(__rhs) > 0; }
2003 * @brief Test if C string follows string.
2004 * @param lhs C string.
2005 * @param rhs String.
2006 * @return True if @a lhs follows @a rhs. False otherwise.
2008 template<typename _CharT, typename _Traits, typename _Alloc,
2009 template <typename, typename, typename> class _Base>
2010 inline bool
2011 operator>(const _CharT* __lhs,
2012 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2013 { return __rhs.compare(__lhs) < 0; }
2015 // operator <=
2017 * @brief Test if string doesn't follow string.
2018 * @param lhs First string.
2019 * @param rhs Second string.
2020 * @return True if @a lhs doesn't follow @a rhs. False otherwise.
2022 template<typename _CharT, typename _Traits, typename _Alloc,
2023 template <typename, typename, typename> class _Base>
2024 inline bool
2025 operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2026 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2027 { return __lhs.compare(__rhs) <= 0; }
2030 * @brief Test if string doesn't follow C string.
2031 * @param lhs String.
2032 * @param rhs C string.
2033 * @return True if @a lhs doesn't follow @a rhs. False otherwise.
2035 template<typename _CharT, typename _Traits, typename _Alloc,
2036 template <typename, typename, typename> class _Base>
2037 inline bool
2038 operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2039 const _CharT* __rhs)
2040 { return __lhs.compare(__rhs) <= 0; }
2043 * @brief Test if C string doesn't follow string.
2044 * @param lhs C string.
2045 * @param rhs String.
2046 * @return True if @a lhs doesn't follow @a rhs. False otherwise.
2048 template<typename _CharT, typename _Traits, typename _Alloc,
2049 template <typename, typename, typename> class _Base>
2050 inline bool
2051 operator<=(const _CharT* __lhs,
2052 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2053 { return __rhs.compare(__lhs) >= 0; }
2055 // operator >=
2057 * @brief Test if string doesn't precede string.
2058 * @param lhs First string.
2059 * @param rhs Second string.
2060 * @return True if @a lhs doesn't precede @a rhs. False otherwise.
2062 template<typename _CharT, typename _Traits, typename _Alloc,
2063 template <typename, typename, typename> class _Base>
2064 inline bool
2065 operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2066 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2067 { return __lhs.compare(__rhs) >= 0; }
2070 * @brief Test if string doesn't precede C string.
2071 * @param lhs String.
2072 * @param rhs C string.
2073 * @return True if @a lhs doesn't precede @a rhs. False otherwise.
2075 template<typename _CharT, typename _Traits, typename _Alloc,
2076 template <typename, typename, typename> class _Base>
2077 inline bool
2078 operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2079 const _CharT* __rhs)
2080 { return __lhs.compare(__rhs) >= 0; }
2083 * @brief Test if C string doesn't precede string.
2084 * @param lhs C string.
2085 * @param rhs String.
2086 * @return True if @a lhs doesn't precede @a rhs. False otherwise.
2088 template<typename _CharT, typename _Traits, typename _Alloc,
2089 template <typename, typename, typename> class _Base>
2090 inline bool
2091 operator>=(const _CharT* __lhs,
2092 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2093 { return __rhs.compare(__lhs) <= 0; }
2096 * @brief Swap contents of two strings.
2097 * @param lhs First string.
2098 * @param rhs Second string.
2100 * Exchanges the contents of @a lhs and @a rhs in constant time.
2102 template<typename _CharT, typename _Traits, typename _Alloc,
2103 template <typename, typename, typename> class _Base>
2104 inline void
2105 swap(__versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2106 __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2107 { __lhs.swap(__rhs); }
2109 _GLIBCXX_END_NAMESPACE
2111 _GLIBCXX_BEGIN_NAMESPACE(std)
2114 * @brief Read stream into a string.
2115 * @param is Input stream.
2116 * @param str Buffer to store into.
2117 * @return Reference to the input stream.
2119 * Stores characters from @a is into @a str until whitespace is found, the
2120 * end of the stream is encountered, or str.max_size() is reached. If
2121 * is.width() is non-zero, that is the limit on the number of characters
2122 * stored into @a str. Any previous contents of @a str are erased.
2124 template<typename _CharT, typename _Traits, typename _Alloc,
2125 template <typename, typename, typename> class _Base>
2126 basic_istream<_CharT, _Traits>&
2127 operator>>(basic_istream<_CharT, _Traits>& __is,
2128 __gnu_cxx::__versa_string<_CharT, _Traits,
2129 _Alloc, _Base>& __str);
2132 * @brief Write string to a stream.
2133 * @param os Output stream.
2134 * @param str String to write out.
2135 * @return Reference to the output stream.
2137 * Output characters of @a str into os following the same rules as for
2138 * writing a C string.
2140 template<typename _CharT, typename _Traits, typename _Alloc,
2141 template <typename, typename, typename> class _Base>
2142 basic_ostream<_CharT, _Traits>&
2143 operator<<(basic_ostream<_CharT, _Traits>& __os,
2144 const __gnu_cxx::__versa_string<_CharT, _Traits,
2145 _Alloc, _Base>& __str);
2148 * @brief Read a line from stream into a string.
2149 * @param is Input stream.
2150 * @param str Buffer to store into.
2151 * @param delim Character marking end of line.
2152 * @return Reference to the input stream.
2154 * Stores characters from @a is into @a str until @a delim is found, the
2155 * end of the stream is encountered, or str.max_size() is reached. If
2156 * is.width() is non-zero, that is the limit on the number of characters
2157 * stored into @a str. Any previous contents of @a str are erased. If @a
2158 * delim was encountered, it is extracted but not stored into @a str.
2160 template<typename _CharT, typename _Traits, typename _Alloc,
2161 template <typename, typename, typename> class _Base>
2162 basic_istream<_CharT, _Traits>&
2163 getline(basic_istream<_CharT, _Traits>& __is,
2164 __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str,
2165 _CharT __delim);
2168 * @brief Read a line from stream into a string.
2169 * @param is Input stream.
2170 * @param str Buffer to store into.
2171 * @return Reference to the input stream.
2173 * Stores characters from is into @a str until '\n' is found, the end of
2174 * the stream is encountered, or str.max_size() is reached. If is.width()
2175 * is non-zero, that is the limit on the number of characters stored into
2176 * @a str. Any previous contents of @a str are erased. If end of line was
2177 * encountered, it is extracted but not stored into @a str.
2179 template<typename _CharT, typename _Traits, typename _Alloc,
2180 template <typename, typename, typename> class _Base>
2181 inline basic_istream<_CharT, _Traits>&
2182 getline(basic_istream<_CharT, _Traits>& __is,
2183 __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str)
2184 { return getline(__is, __str, __is.widen('\n')); }
2186 _GLIBCXX_END_NAMESPACE
2188 #ifndef _GLIBCXX_EXPORT_TEMPLATE
2189 # include "vstring.tcc"
2190 #endif
2192 #endif /* _VSTRING_H */