1*404b540aSrobert // Versatile string -*- C++ -*-
2*404b540aSrobert
3*404b540aSrobert // Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
4*404b540aSrobert //
5*404b540aSrobert // This file is part of the GNU ISO C++ Library. This library is free
6*404b540aSrobert // software; you can redistribute it and/or modify it under the
7*404b540aSrobert // terms of the GNU General Public License as published by the
8*404b540aSrobert // Free Software Foundation; either version 2, or (at your option)
9*404b540aSrobert // any later version.
10*404b540aSrobert
11*404b540aSrobert // This library is distributed in the hope that it will be useful,
12*404b540aSrobert // but WITHOUT ANY WARRANTY; without even the implied warranty of
13*404b540aSrobert // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*404b540aSrobert // GNU General Public License for more details.
15*404b540aSrobert
16*404b540aSrobert // You should have received a copy of the GNU General Public License along
17*404b540aSrobert // with this library; see the file COPYING. If not, write to the Free
18*404b540aSrobert // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19*404b540aSrobert // USA.
20*404b540aSrobert
21*404b540aSrobert // As a special exception, you may use this file as part of a free software
22*404b540aSrobert // library without restriction. Specifically, if other files instantiate
23*404b540aSrobert // templates or use macros or inline functions from this file, or you compile
24*404b540aSrobert // this file and link it with other files to produce an executable, this
25*404b540aSrobert // file does not by itself cause the resulting executable to be covered by
26*404b540aSrobert // the GNU General Public License. This exception does not however
27*404b540aSrobert // invalidate any other reasons why the executable file might be covered by
28*404b540aSrobert // the GNU General Public License.
29*404b540aSrobert
30*404b540aSrobert /** @file ext/vstring.h
31*404b540aSrobert * This file is a GNU extension to the Standard C++ Library.
32*404b540aSrobert */
33*404b540aSrobert
34*404b540aSrobert #ifndef _VSTRING_H
35*404b540aSrobert #define _VSTRING_H 1
36*404b540aSrobert
37*404b540aSrobert #pragma GCC system_header
38*404b540aSrobert
39*404b540aSrobert #include <ext/vstring_util.h>
40*404b540aSrobert #include <ext/rc_string_base.h>
41*404b540aSrobert #include <ext/sso_string_base.h>
42*404b540aSrobert
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)43*404b540aSrobert _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
44*404b540aSrobert
45*404b540aSrobert /**
46*404b540aSrobert * @class __versa_string vstring.h
47*404b540aSrobert * @brief Managing sequences of characters and character-like objects.
48*404b540aSrobert */
49*404b540aSrobert
50*404b540aSrobert // Template class __versa_string
51*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
52*404b540aSrobert template <typename, typename, typename> class _Base>
53*404b540aSrobert class __versa_string
54*404b540aSrobert : private _Base<_CharT, _Traits, _Alloc>
55*404b540aSrobert {
56*404b540aSrobert typedef _Base<_CharT, _Traits, _Alloc> __vstring_base;
57*404b540aSrobert typedef typename __vstring_base::_CharT_alloc_type _CharT_alloc_type;
58*404b540aSrobert
59*404b540aSrobert // Types:
60*404b540aSrobert public:
61*404b540aSrobert typedef _Traits traits_type;
62*404b540aSrobert typedef typename _Traits::char_type value_type;
63*404b540aSrobert typedef _Alloc allocator_type;
64*404b540aSrobert typedef typename _CharT_alloc_type::size_type size_type;
65*404b540aSrobert typedef typename _CharT_alloc_type::difference_type difference_type;
66*404b540aSrobert typedef typename _CharT_alloc_type::reference reference;
67*404b540aSrobert typedef typename _CharT_alloc_type::const_reference const_reference;
68*404b540aSrobert typedef typename _CharT_alloc_type::pointer pointer;
69*404b540aSrobert typedef typename _CharT_alloc_type::const_pointer const_pointer;
70*404b540aSrobert typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator;
71*404b540aSrobert typedef __gnu_cxx::__normal_iterator<const_pointer, __versa_string>
72*404b540aSrobert const_iterator;
73*404b540aSrobert typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
74*404b540aSrobert typedef std::reverse_iterator<iterator> reverse_iterator;
75*404b540aSrobert
76*404b540aSrobert // Data Member (public):
77*404b540aSrobert /// Value returned by various member functions when they fail.
78*404b540aSrobert static const size_type npos = static_cast<size_type>(-1);
79*404b540aSrobert
80*404b540aSrobert private:
81*404b540aSrobert size_type
82*404b540aSrobert _M_check(size_type __pos, const char* __s) const
83*404b540aSrobert {
84*404b540aSrobert if (__pos > this->size())
85*404b540aSrobert std::__throw_out_of_range(__N(__s));
86*404b540aSrobert return __pos;
87*404b540aSrobert }
88*404b540aSrobert
89*404b540aSrobert void
90*404b540aSrobert _M_check_length(size_type __n1, size_type __n2, const char* __s) const
91*404b540aSrobert {
92*404b540aSrobert if (this->max_size() - (this->size() - __n1) < __n2)
93*404b540aSrobert std::__throw_length_error(__N(__s));
94*404b540aSrobert }
95*404b540aSrobert
96*404b540aSrobert // NB: _M_limit doesn't check for a bad __pos value.
97*404b540aSrobert size_type
98*404b540aSrobert _M_limit(size_type __pos, size_type __off) const
99*404b540aSrobert {
100*404b540aSrobert const bool __testoff = __off < this->size() - __pos;
101*404b540aSrobert return __testoff ? __off : this->size() - __pos;
102*404b540aSrobert }
103*404b540aSrobert
104*404b540aSrobert // True if _Rep and source do not overlap.
105*404b540aSrobert bool
106*404b540aSrobert _M_disjunct(const _CharT* __s) const
107*404b540aSrobert {
108*404b540aSrobert return (std::less<const _CharT*>()(__s, this->_M_data())
109*404b540aSrobert || std::less<const _CharT*>()(this->_M_data()
110*404b540aSrobert + this->size(), __s));
111*404b540aSrobert }
112*404b540aSrobert
113*404b540aSrobert // For the internal use we have functions similar to `begin'/`end'
114*404b540aSrobert // but they do not call _M_leak.
115*404b540aSrobert iterator
116*404b540aSrobert _M_ibegin() const
117*404b540aSrobert { return iterator(this->_M_data()); }
118*404b540aSrobert
119*404b540aSrobert iterator
120*404b540aSrobert _M_iend() const
121*404b540aSrobert { return iterator(this->_M_data() + this->_M_length()); }
122*404b540aSrobert
123*404b540aSrobert public:
124*404b540aSrobert // Construct/copy/destroy:
125*404b540aSrobert // NB: We overload ctors in some cases instead of using default
126*404b540aSrobert // arguments, per 17.4.4.4 para. 2 item 2.
127*404b540aSrobert
128*404b540aSrobert /**
129*404b540aSrobert * @brief Default constructor creates an empty string.
130*404b540aSrobert */
131*404b540aSrobert __versa_string()
132*404b540aSrobert : __vstring_base() { }
133*404b540aSrobert
134*404b540aSrobert /**
135*404b540aSrobert * @brief Construct an empty string using allocator @a a.
136*404b540aSrobert */
137*404b540aSrobert explicit
138*404b540aSrobert __versa_string(const _Alloc& __a)
139*404b540aSrobert : __vstring_base(__a) { }
140*404b540aSrobert
141*404b540aSrobert // NB: per LWG issue 42, semantics different from IS:
142*404b540aSrobert /**
143*404b540aSrobert * @brief Construct string with copy of value of @a str.
144*404b540aSrobert * @param str Source string.
145*404b540aSrobert */
146*404b540aSrobert __versa_string(const __versa_string& __str)
147*404b540aSrobert : __vstring_base(__str) { }
148*404b540aSrobert
149*404b540aSrobert /**
150*404b540aSrobert * @brief Construct string as copy of a substring.
151*404b540aSrobert * @param str Source string.
152*404b540aSrobert * @param pos Index of first character to copy from.
153*404b540aSrobert * @param n Number of characters to copy (default remainder).
154*404b540aSrobert */
155*404b540aSrobert __versa_string(const __versa_string& __str, size_type __pos,
156*404b540aSrobert size_type __n = npos)
157*404b540aSrobert : __vstring_base(__str._M_data()
158*404b540aSrobert + __str._M_check(__pos,
159*404b540aSrobert "__versa_string::__versa_string"),
160*404b540aSrobert __str._M_data() + __str._M_limit(__pos, __n)
161*404b540aSrobert + __pos, _Alloc()) { }
162*404b540aSrobert
163*404b540aSrobert /**
164*404b540aSrobert * @brief Construct string as copy of a substring.
165*404b540aSrobert * @param str Source string.
166*404b540aSrobert * @param pos Index of first character to copy from.
167*404b540aSrobert * @param n Number of characters to copy.
168*404b540aSrobert * @param a Allocator to use.
169*404b540aSrobert */
170*404b540aSrobert __versa_string(const __versa_string& __str, size_type __pos,
171*404b540aSrobert size_type __n, const _Alloc& __a)
172*404b540aSrobert : __vstring_base(__str._M_data()
173*404b540aSrobert + __str._M_check(__pos,
174*404b540aSrobert "__versa_string::__versa_string"),
175*404b540aSrobert __str._M_data() + __str._M_limit(__pos, __n)
176*404b540aSrobert + __pos, __a) { }
177*404b540aSrobert
178*404b540aSrobert /**
179*404b540aSrobert * @brief Construct string initialized by a character array.
180*404b540aSrobert * @param s Source character array.
181*404b540aSrobert * @param n Number of characters to copy.
182*404b540aSrobert * @param a Allocator to use (default is default allocator).
183*404b540aSrobert *
184*404b540aSrobert * NB: @a s must have at least @a n characters, '\0' has no special
185*404b540aSrobert * meaning.
186*404b540aSrobert */
187*404b540aSrobert __versa_string(const _CharT* __s, size_type __n,
188*404b540aSrobert const _Alloc& __a = _Alloc())
189*404b540aSrobert : __vstring_base(__s, __s + __n, __a) { }
190*404b540aSrobert
191*404b540aSrobert /**
192*404b540aSrobert * @brief Construct string as copy of a C string.
193*404b540aSrobert * @param s Source C string.
194*404b540aSrobert * @param a Allocator to use (default is default allocator).
195*404b540aSrobert */
196*404b540aSrobert __versa_string(const _CharT* __s, const _Alloc& __a = _Alloc())
197*404b540aSrobert : __vstring_base(__s, __s ? __s + traits_type::length(__s) :
198*404b540aSrobert __s + npos, __a) { }
199*404b540aSrobert
200*404b540aSrobert /**
201*404b540aSrobert * @brief Construct string as multiple characters.
202*404b540aSrobert * @param n Number of characters.
203*404b540aSrobert * @param c Character to use.
204*404b540aSrobert * @param a Allocator to use (default is default allocator).
205*404b540aSrobert */
206*404b540aSrobert __versa_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
207*404b540aSrobert : __vstring_base(__n, __c, __a) { }
208*404b540aSrobert
209*404b540aSrobert /**
210*404b540aSrobert * @brief Construct string as copy of a range.
211*404b540aSrobert * @param beg Start of range.
212*404b540aSrobert * @param end End of range.
213*404b540aSrobert * @param a Allocator to use (default is default allocator).
214*404b540aSrobert */
215*404b540aSrobert template<class _InputIterator>
216*404b540aSrobert __versa_string(_InputIterator __beg, _InputIterator __end,
217*404b540aSrobert const _Alloc& __a = _Alloc())
218*404b540aSrobert : __vstring_base(__beg, __end, __a) { }
219*404b540aSrobert
220*404b540aSrobert /**
221*404b540aSrobert * @brief Destroy the string instance.
222*404b540aSrobert */
223*404b540aSrobert ~__versa_string() { }
224*404b540aSrobert
225*404b540aSrobert /**
226*404b540aSrobert * @brief Assign the value of @a str to this string.
227*404b540aSrobert * @param str Source string.
228*404b540aSrobert */
229*404b540aSrobert __versa_string&
230*404b540aSrobert operator=(const __versa_string& __str)
231*404b540aSrobert { return this->assign(__str); }
232*404b540aSrobert
233*404b540aSrobert /**
234*404b540aSrobert * @brief Copy contents of @a s into this string.
235*404b540aSrobert * @param s Source null-terminated string.
236*404b540aSrobert */
237*404b540aSrobert __versa_string&
238*404b540aSrobert operator=(const _CharT* __s)
239*404b540aSrobert { return this->assign(__s); }
240*404b540aSrobert
241*404b540aSrobert /**
242*404b540aSrobert * @brief Set value to string of length 1.
243*404b540aSrobert * @param c Source character.
244*404b540aSrobert *
245*404b540aSrobert * Assigning to a character makes this string length 1 and
246*404b540aSrobert * (*this)[0] == @a c.
247*404b540aSrobert */
248*404b540aSrobert __versa_string&
249*404b540aSrobert operator=(_CharT __c)
250*404b540aSrobert {
251*404b540aSrobert this->assign(1, __c);
252*404b540aSrobert return *this;
253*404b540aSrobert }
254*404b540aSrobert
255*404b540aSrobert // Iterators:
256*404b540aSrobert /**
257*404b540aSrobert * Returns a read/write iterator that points to the first character in
258*404b540aSrobert * the %string. Unshares the string.
259*404b540aSrobert */
260*404b540aSrobert iterator
261*404b540aSrobert begin()
262*404b540aSrobert {
263*404b540aSrobert this->_M_leak();
264*404b540aSrobert return iterator(this->_M_data());
265*404b540aSrobert }
266*404b540aSrobert
267*404b540aSrobert /**
268*404b540aSrobert * Returns a read-only (constant) iterator that points to the first
269*404b540aSrobert * character in the %string.
270*404b540aSrobert */
271*404b540aSrobert const_iterator
272*404b540aSrobert begin() const
273*404b540aSrobert { return const_iterator(this->_M_data()); }
274*404b540aSrobert
275*404b540aSrobert /**
276*404b540aSrobert * Returns a read/write iterator that points one past the last
277*404b540aSrobert * character in the %string. Unshares the string.
278*404b540aSrobert */
279*404b540aSrobert iterator
280*404b540aSrobert end()
281*404b540aSrobert {
282*404b540aSrobert this->_M_leak();
283*404b540aSrobert return iterator(this->_M_data() + this->size());
284*404b540aSrobert }
285*404b540aSrobert
286*404b540aSrobert /**
287*404b540aSrobert * Returns a read-only (constant) iterator that points one past the
288*404b540aSrobert * last character in the %string.
289*404b540aSrobert */
290*404b540aSrobert const_iterator
291*404b540aSrobert end() const
292*404b540aSrobert { return const_iterator(this->_M_data() + this->size()); }
293*404b540aSrobert
294*404b540aSrobert /**
295*404b540aSrobert * Returns a read/write reverse iterator that points to the last
296*404b540aSrobert * character in the %string. Iteration is done in reverse element
297*404b540aSrobert * order. Unshares the string.
298*404b540aSrobert */
299*404b540aSrobert reverse_iterator
300*404b540aSrobert rbegin()
301*404b540aSrobert { return reverse_iterator(this->end()); }
302*404b540aSrobert
303*404b540aSrobert /**
304*404b540aSrobert * Returns a read-only (constant) reverse iterator that points
305*404b540aSrobert * to the last character in the %string. Iteration is done in
306*404b540aSrobert * reverse element order.
307*404b540aSrobert */
308*404b540aSrobert const_reverse_iterator
309*404b540aSrobert rbegin() const
310*404b540aSrobert { return const_reverse_iterator(this->end()); }
311*404b540aSrobert
312*404b540aSrobert /**
313*404b540aSrobert * Returns a read/write reverse iterator that points to one before the
314*404b540aSrobert * first character in the %string. Iteration is done in reverse
315*404b540aSrobert * element order. Unshares the string.
316*404b540aSrobert */
317*404b540aSrobert reverse_iterator
318*404b540aSrobert rend()
319*404b540aSrobert { return reverse_iterator(this->begin()); }
320*404b540aSrobert
321*404b540aSrobert /**
322*404b540aSrobert * Returns a read-only (constant) reverse iterator that points
323*404b540aSrobert * to one before the first character in the %string. Iteration
324*404b540aSrobert * is done in reverse element order.
325*404b540aSrobert */
326*404b540aSrobert const_reverse_iterator
327*404b540aSrobert rend() const
328*404b540aSrobert { return const_reverse_iterator(this->begin()); }
329*404b540aSrobert
330*404b540aSrobert public:
331*404b540aSrobert // Capacity:
332*404b540aSrobert /// Returns the number of characters in the string, not including any
333*404b540aSrobert /// null-termination.
334*404b540aSrobert size_type
335*404b540aSrobert size() const
336*404b540aSrobert { return this->_M_length(); }
337*404b540aSrobert
338*404b540aSrobert /// Returns the number of characters in the string, not including any
339*404b540aSrobert /// null-termination.
340*404b540aSrobert size_type
341*404b540aSrobert length() const
342*404b540aSrobert { return this->_M_length(); }
343*404b540aSrobert
344*404b540aSrobert /// Returns the size() of the largest possible %string.
345*404b540aSrobert size_type
346*404b540aSrobert max_size() const
347*404b540aSrobert { return this->_M_max_size(); }
348*404b540aSrobert
349*404b540aSrobert /**
350*404b540aSrobert * @brief Resizes the %string to the specified number of characters.
351*404b540aSrobert * @param n Number of characters the %string should contain.
352*404b540aSrobert * @param c Character to fill any new elements.
353*404b540aSrobert *
354*404b540aSrobert * This function will %resize the %string to the specified
355*404b540aSrobert * number of characters. If the number is smaller than the
356*404b540aSrobert * %string's current size the %string is truncated, otherwise
357*404b540aSrobert * the %string is extended and new elements are set to @a c.
358*404b540aSrobert */
359*404b540aSrobert void
360*404b540aSrobert resize(size_type __n, _CharT __c);
361*404b540aSrobert
362*404b540aSrobert /**
363*404b540aSrobert * @brief Resizes the %string to the specified number of characters.
364*404b540aSrobert * @param n Number of characters the %string should contain.
365*404b540aSrobert *
366*404b540aSrobert * This function will resize the %string to the specified length. If
367*404b540aSrobert * the new size is smaller than the %string's current size the %string
368*404b540aSrobert * is truncated, otherwise the %string is extended and new characters
369*404b540aSrobert * are default-constructed. For basic types such as char, this means
370*404b540aSrobert * setting them to 0.
371*404b540aSrobert */
372*404b540aSrobert void
373*404b540aSrobert resize(size_type __n)
374*404b540aSrobert { this->resize(__n, _CharT()); }
375*404b540aSrobert
376*404b540aSrobert /**
377*404b540aSrobert * Returns the total number of characters that the %string can hold
378*404b540aSrobert * before needing to allocate more memory.
379*404b540aSrobert */
380*404b540aSrobert size_type
381*404b540aSrobert capacity() const
382*404b540aSrobert { return this->_M_capacity(); }
383*404b540aSrobert
384*404b540aSrobert /**
385*404b540aSrobert * @brief Attempt to preallocate enough memory for specified number of
386*404b540aSrobert * characters.
387*404b540aSrobert * @param res_arg Number of characters required.
388*404b540aSrobert * @throw std::length_error If @a res_arg exceeds @c max_size().
389*404b540aSrobert *
390*404b540aSrobert * This function attempts to reserve enough memory for the
391*404b540aSrobert * %string to hold the specified number of characters. If the
392*404b540aSrobert * number requested is more than max_size(), length_error is
393*404b540aSrobert * thrown.
394*404b540aSrobert *
395*404b540aSrobert * The advantage of this function is that if optimal code is a
396*404b540aSrobert * necessity and the user can determine the string length that will be
397*404b540aSrobert * required, the user can reserve the memory in %advance, and thus
398*404b540aSrobert * prevent a possible reallocation of memory and copying of %string
399*404b540aSrobert * data.
400*404b540aSrobert */
401*404b540aSrobert void
402*404b540aSrobert reserve(size_type __res_arg = 0)
403*404b540aSrobert { this->_M_reserve(__res_arg); }
404*404b540aSrobert
405*404b540aSrobert /**
406*404b540aSrobert * Erases the string, making it empty.
407*404b540aSrobert */
408*404b540aSrobert void
409*404b540aSrobert clear()
410*404b540aSrobert { this->_M_clear(); }
411*404b540aSrobert
412*404b540aSrobert /**
413*404b540aSrobert * Returns true if the %string is empty. Equivalent to *this == "".
414*404b540aSrobert */
415*404b540aSrobert bool
416*404b540aSrobert empty() const
417*404b540aSrobert { return this->size() == 0; }
418*404b540aSrobert
419*404b540aSrobert // Element access:
420*404b540aSrobert /**
421*404b540aSrobert * @brief Subscript access to the data contained in the %string.
422*404b540aSrobert * @param pos The index of the character to access.
423*404b540aSrobert * @return Read-only (constant) reference to the character.
424*404b540aSrobert *
425*404b540aSrobert * This operator allows for easy, array-style, data access.
426*404b540aSrobert * Note that data access with this operator is unchecked and
427*404b540aSrobert * out_of_range lookups are not defined. (For checked lookups
428*404b540aSrobert * see at().)
429*404b540aSrobert */
430*404b540aSrobert const_reference
431*404b540aSrobert operator[] (size_type __pos) const
432*404b540aSrobert {
433*404b540aSrobert _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
434*404b540aSrobert return this->_M_data()[__pos];
435*404b540aSrobert }
436*404b540aSrobert
437*404b540aSrobert /**
438*404b540aSrobert * @brief Subscript access to the data contained in the %string.
439*404b540aSrobert * @param pos The index of the character to access.
440*404b540aSrobert * @return Read/write reference to the character.
441*404b540aSrobert *
442*404b540aSrobert * This operator allows for easy, array-style, data access.
443*404b540aSrobert * Note that data access with this operator is unchecked and
444*404b540aSrobert * out_of_range lookups are not defined. (For checked lookups
445*404b540aSrobert * see at().) Unshares the string.
446*404b540aSrobert */
447*404b540aSrobert reference
448*404b540aSrobert operator[](size_type __pos)
449*404b540aSrobert {
450*404b540aSrobert // allow pos == size() as v3 extension:
451*404b540aSrobert _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
452*404b540aSrobert // but be strict in pedantic mode:
453*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(__pos < this->size());
454*404b540aSrobert this->_M_leak();
455*404b540aSrobert return this->_M_data()[__pos];
456*404b540aSrobert }
457*404b540aSrobert
458*404b540aSrobert /**
459*404b540aSrobert * @brief Provides access to the data contained in the %string.
460*404b540aSrobert * @param n The index of the character to access.
461*404b540aSrobert * @return Read-only (const) reference to the character.
462*404b540aSrobert * @throw std::out_of_range If @a n is an invalid index.
463*404b540aSrobert *
464*404b540aSrobert * This function provides for safer data access. The parameter is
465*404b540aSrobert * first checked that it is in the range of the string. The function
466*404b540aSrobert * throws out_of_range if the check fails.
467*404b540aSrobert */
468*404b540aSrobert const_reference
469*404b540aSrobert at(size_type __n) const
470*404b540aSrobert {
471*404b540aSrobert if (__n >= this->size())
472*404b540aSrobert std::__throw_out_of_range(__N("__versa_string::at"));
473*404b540aSrobert return this->_M_data()[__n];
474*404b540aSrobert }
475*404b540aSrobert
476*404b540aSrobert /**
477*404b540aSrobert * @brief Provides access to the data contained in the %string.
478*404b540aSrobert * @param n The index of the character to access.
479*404b540aSrobert * @return Read/write reference to the character.
480*404b540aSrobert * @throw std::out_of_range If @a n is an invalid index.
481*404b540aSrobert *
482*404b540aSrobert * This function provides for safer data access. The parameter is
483*404b540aSrobert * first checked that it is in the range of the string. The function
484*404b540aSrobert * throws out_of_range if the check fails. Success results in
485*404b540aSrobert * unsharing the string.
486*404b540aSrobert */
487*404b540aSrobert reference
488*404b540aSrobert at(size_type __n)
489*404b540aSrobert {
490*404b540aSrobert if (__n >= this->size())
491*404b540aSrobert std::__throw_out_of_range(__N("__versa_string::at"));
492*404b540aSrobert this->_M_leak();
493*404b540aSrobert return this->_M_data()[__n];
494*404b540aSrobert }
495*404b540aSrobert
496*404b540aSrobert // Modifiers:
497*404b540aSrobert /**
498*404b540aSrobert * @brief Append a string to this string.
499*404b540aSrobert * @param str The string to append.
500*404b540aSrobert * @return Reference to this string.
501*404b540aSrobert */
502*404b540aSrobert __versa_string&
503*404b540aSrobert operator+=(const __versa_string& __str)
504*404b540aSrobert { return this->append(__str); }
505*404b540aSrobert
506*404b540aSrobert /**
507*404b540aSrobert * @brief Append a C string.
508*404b540aSrobert * @param s The C string to append.
509*404b540aSrobert * @return Reference to this string.
510*404b540aSrobert */
511*404b540aSrobert __versa_string&
512*404b540aSrobert operator+=(const _CharT* __s)
513*404b540aSrobert { return this->append(__s); }
514*404b540aSrobert
515*404b540aSrobert /**
516*404b540aSrobert * @brief Append a character.
517*404b540aSrobert * @param c The character to append.
518*404b540aSrobert * @return Reference to this string.
519*404b540aSrobert */
520*404b540aSrobert __versa_string&
521*404b540aSrobert operator+=(_CharT __c)
522*404b540aSrobert {
523*404b540aSrobert this->push_back(__c);
524*404b540aSrobert return *this;
525*404b540aSrobert }
526*404b540aSrobert
527*404b540aSrobert /**
528*404b540aSrobert * @brief Append a string to this string.
529*404b540aSrobert * @param str The string to append.
530*404b540aSrobert * @return Reference to this string.
531*404b540aSrobert */
532*404b540aSrobert __versa_string&
533*404b540aSrobert append(const __versa_string& __str)
534*404b540aSrobert { return _M_append(__str._M_data(), __str.size()); }
535*404b540aSrobert
536*404b540aSrobert /**
537*404b540aSrobert * @brief Append a substring.
538*404b540aSrobert * @param str The string to append.
539*404b540aSrobert * @param pos Index of the first character of str to append.
540*404b540aSrobert * @param n The number of characters to append.
541*404b540aSrobert * @return Reference to this string.
542*404b540aSrobert * @throw std::out_of_range if @a pos is not a valid index.
543*404b540aSrobert *
544*404b540aSrobert * This function appends @a n characters from @a str starting at @a pos
545*404b540aSrobert * to this string. If @a n is is larger than the number of available
546*404b540aSrobert * characters in @a str, the remainder of @a str is appended.
547*404b540aSrobert */
548*404b540aSrobert __versa_string&
549*404b540aSrobert append(const __versa_string& __str, size_type __pos, size_type __n)
550*404b540aSrobert { return _M_append(__str._M_data()
551*404b540aSrobert + __str._M_check(__pos, "__versa_string::append"),
552*404b540aSrobert __str._M_limit(__pos, __n)); }
553*404b540aSrobert
554*404b540aSrobert /**
555*404b540aSrobert * @brief Append a C substring.
556*404b540aSrobert * @param s The C string to append.
557*404b540aSrobert * @param n The number of characters to append.
558*404b540aSrobert * @return Reference to this string.
559*404b540aSrobert */
560*404b540aSrobert __versa_string&
561*404b540aSrobert append(const _CharT* __s, size_type __n)
562*404b540aSrobert {
563*404b540aSrobert __glibcxx_requires_string_len(__s, __n);
564*404b540aSrobert _M_check_length(size_type(0), __n, "__versa_string::append");
565*404b540aSrobert return _M_append(__s, __n);
566*404b540aSrobert }
567*404b540aSrobert
568*404b540aSrobert /**
569*404b540aSrobert * @brief Append a C string.
570*404b540aSrobert * @param s The C string to append.
571*404b540aSrobert * @return Reference to this string.
572*404b540aSrobert */
573*404b540aSrobert __versa_string&
574*404b540aSrobert append(const _CharT* __s)
575*404b540aSrobert {
576*404b540aSrobert __glibcxx_requires_string(__s);
577*404b540aSrobert const size_type __n = traits_type::length(__s);
578*404b540aSrobert _M_check_length(size_type(0), __n, "__versa_string::append");
579*404b540aSrobert return _M_append(__s, __n);
580*404b540aSrobert }
581*404b540aSrobert
582*404b540aSrobert /**
583*404b540aSrobert * @brief Append multiple characters.
584*404b540aSrobert * @param n The number of characters to append.
585*404b540aSrobert * @param c The character to use.
586*404b540aSrobert * @return Reference to this string.
587*404b540aSrobert *
588*404b540aSrobert * Appends n copies of c to this string.
589*404b540aSrobert */
590*404b540aSrobert __versa_string&
591*404b540aSrobert append(size_type __n, _CharT __c)
592*404b540aSrobert { return _M_replace_aux(this->size(), size_type(0), __n, __c); }
593*404b540aSrobert
594*404b540aSrobert /**
595*404b540aSrobert * @brief Append a range of characters.
596*404b540aSrobert * @param first Iterator referencing the first character to append.
597*404b540aSrobert * @param last Iterator marking the end of the range.
598*404b540aSrobert * @return Reference to this string.
599*404b540aSrobert *
600*404b540aSrobert * Appends characters in the range [first,last) to this string.
601*404b540aSrobert */
602*404b540aSrobert template<class _InputIterator>
603*404b540aSrobert __versa_string&
604*404b540aSrobert append(_InputIterator __first, _InputIterator __last)
605*404b540aSrobert { return this->replace(_M_iend(), _M_iend(), __first, __last); }
606*404b540aSrobert
607*404b540aSrobert /**
608*404b540aSrobert * @brief Append a single character.
609*404b540aSrobert * @param c Character to append.
610*404b540aSrobert */
611*404b540aSrobert void
612*404b540aSrobert push_back(_CharT __c)
613*404b540aSrobert {
614*404b540aSrobert const size_type __size = this->size();
615*404b540aSrobert if (__size + 1 > this->capacity() || this->_M_is_shared())
616*404b540aSrobert this->_M_mutate(__size, size_type(0), 0, size_type(1));
617*404b540aSrobert traits_type::assign(this->_M_data()[__size], __c);
618*404b540aSrobert this->_M_set_length(__size + 1);
619*404b540aSrobert }
620*404b540aSrobert
621*404b540aSrobert /**
622*404b540aSrobert * @brief Set value to contents of another string.
623*404b540aSrobert * @param str Source string to use.
624*404b540aSrobert * @return Reference to this string.
625*404b540aSrobert */
626*404b540aSrobert __versa_string&
627*404b540aSrobert assign(const __versa_string& __str)
628*404b540aSrobert {
629*404b540aSrobert this->_M_assign(__str);
630*404b540aSrobert return *this;
631*404b540aSrobert }
632*404b540aSrobert
633*404b540aSrobert /**
634*404b540aSrobert * @brief Set value to a substring of a string.
635*404b540aSrobert * @param str The string to use.
636*404b540aSrobert * @param pos Index of the first character of str.
637*404b540aSrobert * @param n Number of characters to use.
638*404b540aSrobert * @return Reference to this string.
639*404b540aSrobert * @throw std::out_of_range if @a pos is not a valid index.
640*404b540aSrobert *
641*404b540aSrobert * This function sets this string to the substring of @a str consisting
642*404b540aSrobert * of @a n characters at @a pos. If @a n is is larger than the number
643*404b540aSrobert * of available characters in @a str, the remainder of @a str is used.
644*404b540aSrobert */
645*404b540aSrobert __versa_string&
646*404b540aSrobert assign(const __versa_string& __str, size_type __pos, size_type __n)
647*404b540aSrobert { return _M_replace(size_type(0), this->size(), __str._M_data()
648*404b540aSrobert + __str._M_check(__pos, "__versa_string::assign"),
649*404b540aSrobert __str._M_limit(__pos, __n)); }
650*404b540aSrobert
651*404b540aSrobert /**
652*404b540aSrobert * @brief Set value to a C substring.
653*404b540aSrobert * @param s The C string to use.
654*404b540aSrobert * @param n Number of characters to use.
655*404b540aSrobert * @return Reference to this string.
656*404b540aSrobert *
657*404b540aSrobert * This function sets the value of this string to the first @a n
658*404b540aSrobert * characters of @a s. If @a n is is larger than the number of
659*404b540aSrobert * available characters in @a s, the remainder of @a s is used.
660*404b540aSrobert */
661*404b540aSrobert __versa_string&
662*404b540aSrobert assign(const _CharT* __s, size_type __n)
663*404b540aSrobert {
664*404b540aSrobert __glibcxx_requires_string_len(__s, __n);
665*404b540aSrobert return _M_replace(size_type(0), this->size(), __s, __n);
666*404b540aSrobert }
667*404b540aSrobert
668*404b540aSrobert /**
669*404b540aSrobert * @brief Set value to contents of a C string.
670*404b540aSrobert * @param s The C string to use.
671*404b540aSrobert * @return Reference to this string.
672*404b540aSrobert *
673*404b540aSrobert * This function sets the value of this string to the value of @a s.
674*404b540aSrobert * The data is copied, so there is no dependence on @a s once the
675*404b540aSrobert * function returns.
676*404b540aSrobert */
677*404b540aSrobert __versa_string&
678*404b540aSrobert assign(const _CharT* __s)
679*404b540aSrobert {
680*404b540aSrobert __glibcxx_requires_string(__s);
681*404b540aSrobert return _M_replace(size_type(0), this->size(), __s,
682*404b540aSrobert traits_type::length(__s));
683*404b540aSrobert }
684*404b540aSrobert
685*404b540aSrobert /**
686*404b540aSrobert * @brief Set value to multiple characters.
687*404b540aSrobert * @param n Length of the resulting string.
688*404b540aSrobert * @param c The character to use.
689*404b540aSrobert * @return Reference to this string.
690*404b540aSrobert *
691*404b540aSrobert * This function sets the value of this string to @a n copies of
692*404b540aSrobert * character @a c.
693*404b540aSrobert */
694*404b540aSrobert __versa_string&
695*404b540aSrobert assign(size_type __n, _CharT __c)
696*404b540aSrobert { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
697*404b540aSrobert
698*404b540aSrobert /**
699*404b540aSrobert * @brief Set value to a range of characters.
700*404b540aSrobert * @param first Iterator referencing the first character to append.
701*404b540aSrobert * @param last Iterator marking the end of the range.
702*404b540aSrobert * @return Reference to this string.
703*404b540aSrobert *
704*404b540aSrobert * Sets value of string to characters in the range [first,last).
705*404b540aSrobert */
706*404b540aSrobert template<class _InputIterator>
707*404b540aSrobert __versa_string&
708*404b540aSrobert assign(_InputIterator __first, _InputIterator __last)
709*404b540aSrobert { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
710*404b540aSrobert
711*404b540aSrobert /**
712*404b540aSrobert * @brief Insert multiple characters.
713*404b540aSrobert * @param p Iterator referencing location in string to insert at.
714*404b540aSrobert * @param n Number of characters to insert
715*404b540aSrobert * @param c The character to insert.
716*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
717*404b540aSrobert *
718*404b540aSrobert * Inserts @a n copies of character @a c starting at the position
719*404b540aSrobert * referenced by iterator @a p. If adding characters causes the length
720*404b540aSrobert * to exceed max_size(), length_error is thrown. The value of the
721*404b540aSrobert * string doesn't change if an error is thrown.
722*404b540aSrobert */
723*404b540aSrobert void
724*404b540aSrobert insert(iterator __p, size_type __n, _CharT __c)
725*404b540aSrobert { this->replace(__p, __p, __n, __c); }
726*404b540aSrobert
727*404b540aSrobert /**
728*404b540aSrobert * @brief Insert a range of characters.
729*404b540aSrobert * @param p Iterator referencing location in string to insert at.
730*404b540aSrobert * @param beg Start of range.
731*404b540aSrobert * @param end End of range.
732*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
733*404b540aSrobert *
734*404b540aSrobert * Inserts characters in range [beg,end). If adding characters causes
735*404b540aSrobert * the length to exceed max_size(), length_error is thrown. The value
736*404b540aSrobert * of the string doesn't change if an error is thrown.
737*404b540aSrobert */
738*404b540aSrobert template<class _InputIterator>
739*404b540aSrobert void
740*404b540aSrobert insert(iterator __p, _InputIterator __beg, _InputIterator __end)
741*404b540aSrobert { this->replace(__p, __p, __beg, __end); }
742*404b540aSrobert
743*404b540aSrobert /**
744*404b540aSrobert * @brief Insert value of a string.
745*404b540aSrobert * @param pos1 Iterator referencing location in string to insert at.
746*404b540aSrobert * @param str The string to insert.
747*404b540aSrobert * @return Reference to this string.
748*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
749*404b540aSrobert *
750*404b540aSrobert * Inserts value of @a str starting at @a pos1. If adding characters
751*404b540aSrobert * causes the length to exceed max_size(), length_error is thrown. The
752*404b540aSrobert * value of the string doesn't change if an error is thrown.
753*404b540aSrobert */
754*404b540aSrobert __versa_string&
755*404b540aSrobert insert(size_type __pos1, const __versa_string& __str)
756*404b540aSrobert { return this->replace(__pos1, size_type(0),
757*404b540aSrobert __str._M_data(), __str.size()); }
758*404b540aSrobert
759*404b540aSrobert /**
760*404b540aSrobert * @brief Insert a substring.
761*404b540aSrobert * @param pos1 Iterator referencing location in string to insert at.
762*404b540aSrobert * @param str The string to insert.
763*404b540aSrobert * @param pos2 Start of characters in str to insert.
764*404b540aSrobert * @param n Number of characters to insert.
765*404b540aSrobert * @return Reference to this string.
766*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
767*404b540aSrobert * @throw std::out_of_range If @a pos1 > size() or
768*404b540aSrobert * @a pos2 > @a str.size().
769*404b540aSrobert *
770*404b540aSrobert * Starting at @a pos1, insert @a n character of @a str beginning with
771*404b540aSrobert * @a pos2. If adding characters causes the length to exceed
772*404b540aSrobert * max_size(), length_error is thrown. If @a pos1 is beyond the end of
773*404b540aSrobert * this string or @a pos2 is beyond the end of @a str, out_of_range is
774*404b540aSrobert * thrown. The value of the string doesn't change if an error is
775*404b540aSrobert * thrown.
776*404b540aSrobert */
777*404b540aSrobert __versa_string&
778*404b540aSrobert insert(size_type __pos1, const __versa_string& __str,
779*404b540aSrobert size_type __pos2, size_type __n)
780*404b540aSrobert { return this->replace(__pos1, size_type(0), __str._M_data()
781*404b540aSrobert + __str._M_check(__pos2, "__versa_string::insert"),
782*404b540aSrobert __str._M_limit(__pos2, __n)); }
783*404b540aSrobert
784*404b540aSrobert /**
785*404b540aSrobert * @brief Insert a C substring.
786*404b540aSrobert * @param pos Iterator referencing location in string to insert at.
787*404b540aSrobert * @param s The C string to insert.
788*404b540aSrobert * @param n The number of characters to insert.
789*404b540aSrobert * @return Reference to this string.
790*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
791*404b540aSrobert * @throw std::out_of_range If @a pos is beyond the end of this
792*404b540aSrobert * string.
793*404b540aSrobert *
794*404b540aSrobert * Inserts the first @a n characters of @a s starting at @a pos. If
795*404b540aSrobert * adding characters causes the length to exceed max_size(),
796*404b540aSrobert * length_error is thrown. If @a pos is beyond end(), out_of_range is
797*404b540aSrobert * thrown. The value of the string doesn't change if an error is
798*404b540aSrobert * thrown.
799*404b540aSrobert */
800*404b540aSrobert __versa_string&
801*404b540aSrobert insert(size_type __pos, const _CharT* __s, size_type __n)
802*404b540aSrobert { return this->replace(__pos, size_type(0), __s, __n); }
803*404b540aSrobert
804*404b540aSrobert /**
805*404b540aSrobert * @brief Insert a C string.
806*404b540aSrobert * @param pos Iterator referencing location in string to insert at.
807*404b540aSrobert * @param s The C string to insert.
808*404b540aSrobert * @return Reference to this string.
809*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
810*404b540aSrobert * @throw std::out_of_range If @a pos is beyond the end of this
811*404b540aSrobert * string.
812*404b540aSrobert *
813*404b540aSrobert * Inserts the first @a n characters of @a s starting at @a pos. If
814*404b540aSrobert * adding characters causes the length to exceed max_size(),
815*404b540aSrobert * length_error is thrown. If @a pos is beyond end(), out_of_range is
816*404b540aSrobert * thrown. The value of the string doesn't change if an error is
817*404b540aSrobert * thrown.
818*404b540aSrobert */
819*404b540aSrobert __versa_string&
820*404b540aSrobert insert(size_type __pos, const _CharT* __s)
821*404b540aSrobert {
822*404b540aSrobert __glibcxx_requires_string(__s);
823*404b540aSrobert return this->replace(__pos, size_type(0), __s,
824*404b540aSrobert traits_type::length(__s));
825*404b540aSrobert }
826*404b540aSrobert
827*404b540aSrobert /**
828*404b540aSrobert * @brief Insert multiple characters.
829*404b540aSrobert * @param pos Index in string to insert at.
830*404b540aSrobert * @param n Number of characters to insert
831*404b540aSrobert * @param c The character to insert.
832*404b540aSrobert * @return Reference to this string.
833*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
834*404b540aSrobert * @throw std::out_of_range If @a pos is beyond the end of this
835*404b540aSrobert * string.
836*404b540aSrobert *
837*404b540aSrobert * Inserts @a n copies of character @a c starting at index @a pos. If
838*404b540aSrobert * adding characters causes the length to exceed max_size(),
839*404b540aSrobert * length_error is thrown. If @a pos > length(), out_of_range is
840*404b540aSrobert * thrown. The value of the string doesn't change if an error is
841*404b540aSrobert * thrown.
842*404b540aSrobert */
843*404b540aSrobert __versa_string&
844*404b540aSrobert insert(size_type __pos, size_type __n, _CharT __c)
845*404b540aSrobert { return _M_replace_aux(_M_check(__pos, "__versa_string::insert"),
846*404b540aSrobert size_type(0), __n, __c); }
847*404b540aSrobert
848*404b540aSrobert /**
849*404b540aSrobert * @brief Insert one character.
850*404b540aSrobert * @param p Iterator referencing position in string to insert at.
851*404b540aSrobert * @param c The character to insert.
852*404b540aSrobert * @return Iterator referencing newly inserted char.
853*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
854*404b540aSrobert *
855*404b540aSrobert * Inserts character @a c at position referenced by @a p. If adding
856*404b540aSrobert * character causes the length to exceed max_size(), length_error is
857*404b540aSrobert * thrown. If @a p is beyond end of string, out_of_range is thrown.
858*404b540aSrobert * The value of the string doesn't change if an error is thrown.
859*404b540aSrobert */
860*404b540aSrobert iterator
861*404b540aSrobert insert(iterator __p, _CharT __c)
862*404b540aSrobert {
863*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
864*404b540aSrobert const size_type __pos = __p - _M_ibegin();
865*404b540aSrobert _M_replace_aux(__pos, size_type(0), size_type(1), __c);
866*404b540aSrobert this->_M_set_leaked();
867*404b540aSrobert return iterator(this->_M_data() + __pos);
868*404b540aSrobert }
869*404b540aSrobert
870*404b540aSrobert /**
871*404b540aSrobert * @brief Remove characters.
872*404b540aSrobert * @param pos Index of first character to remove (default 0).
873*404b540aSrobert * @param n Number of characters to remove (default remainder).
874*404b540aSrobert * @return Reference to this string.
875*404b540aSrobert * @throw std::out_of_range If @a pos is beyond the end of this
876*404b540aSrobert * string.
877*404b540aSrobert *
878*404b540aSrobert * Removes @a n characters from this string starting at @a pos. The
879*404b540aSrobert * length of the string is reduced by @a n. If there are < @a n
880*404b540aSrobert * characters to remove, the remainder of the string is truncated. If
881*404b540aSrobert * @a p is beyond end of string, out_of_range is thrown. The value of
882*404b540aSrobert * the string doesn't change if an error is thrown.
883*404b540aSrobert */
884*404b540aSrobert __versa_string&
885*404b540aSrobert erase(size_type __pos = 0, size_type __n = npos)
886*404b540aSrobert {
887*404b540aSrobert this->_M_erase(_M_check(__pos, "__versa_string::erase"),
888*404b540aSrobert _M_limit(__pos, __n));
889*404b540aSrobert return *this;
890*404b540aSrobert }
891*404b540aSrobert
892*404b540aSrobert /**
893*404b540aSrobert * @brief Remove one character.
894*404b540aSrobert * @param position Iterator referencing the character to remove.
895*404b540aSrobert * @return iterator referencing same location after removal.
896*404b540aSrobert *
897*404b540aSrobert * Removes the character at @a position from this string. The value
898*404b540aSrobert * of the string doesn't change if an error is thrown.
899*404b540aSrobert */
900*404b540aSrobert iterator
901*404b540aSrobert erase(iterator __position)
902*404b540aSrobert {
903*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
904*404b540aSrobert && __position < _M_iend());
905*404b540aSrobert const size_type __pos = __position - _M_ibegin();
906*404b540aSrobert this->_M_erase(__pos, size_type(1));
907*404b540aSrobert this->_M_set_leaked();
908*404b540aSrobert return iterator(this->_M_data() + __pos);
909*404b540aSrobert }
910*404b540aSrobert
911*404b540aSrobert /**
912*404b540aSrobert * @brief Remove a range of characters.
913*404b540aSrobert * @param first Iterator referencing the first character to remove.
914*404b540aSrobert * @param last Iterator referencing the end of the range.
915*404b540aSrobert * @return Iterator referencing location of first after removal.
916*404b540aSrobert *
917*404b540aSrobert * Removes the characters in the range [first,last) from this string.
918*404b540aSrobert * The value of the string doesn't change if an error is thrown.
919*404b540aSrobert */
920*404b540aSrobert iterator
921*404b540aSrobert erase(iterator __first, iterator __last)
922*404b540aSrobert {
923*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
924*404b540aSrobert && __last <= _M_iend());
925*404b540aSrobert const size_type __pos = __first - _M_ibegin();
926*404b540aSrobert this->_M_erase(__pos, __last - __first);
927*404b540aSrobert this->_M_set_leaked();
928*404b540aSrobert return iterator(this->_M_data() + __pos);
929*404b540aSrobert }
930*404b540aSrobert
931*404b540aSrobert /**
932*404b540aSrobert * @brief Replace characters with value from another string.
933*404b540aSrobert * @param pos Index of first character to replace.
934*404b540aSrobert * @param n Number of characters to be replaced.
935*404b540aSrobert * @param str String to insert.
936*404b540aSrobert * @return Reference to this string.
937*404b540aSrobert * @throw std::out_of_range If @a pos is beyond the end of this
938*404b540aSrobert * string.
939*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
940*404b540aSrobert *
941*404b540aSrobert * Removes the characters in the range [pos,pos+n) from this string.
942*404b540aSrobert * In place, the value of @a str is inserted. If @a pos is beyond end
943*404b540aSrobert * of string, out_of_range is thrown. If the length of the result
944*404b540aSrobert * exceeds max_size(), length_error is thrown. The value of the string
945*404b540aSrobert * doesn't change if an error is thrown.
946*404b540aSrobert */
947*404b540aSrobert __versa_string&
948*404b540aSrobert replace(size_type __pos, size_type __n, const __versa_string& __str)
949*404b540aSrobert { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
950*404b540aSrobert
951*404b540aSrobert /**
952*404b540aSrobert * @brief Replace characters with value from another string.
953*404b540aSrobert * @param pos1 Index of first character to replace.
954*404b540aSrobert * @param n1 Number of characters to be replaced.
955*404b540aSrobert * @param str String to insert.
956*404b540aSrobert * @param pos2 Index of first character of str to use.
957*404b540aSrobert * @param n2 Number of characters from str to use.
958*404b540aSrobert * @return Reference to this string.
959*404b540aSrobert * @throw std::out_of_range If @a pos1 > size() or @a pos2 >
960*404b540aSrobert * str.size().
961*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
962*404b540aSrobert *
963*404b540aSrobert * Removes the characters in the range [pos1,pos1 + n) from this
964*404b540aSrobert * string. In place, the value of @a str is inserted. If @a pos is
965*404b540aSrobert * beyond end of string, out_of_range is thrown. If the length of the
966*404b540aSrobert * result exceeds max_size(), length_error is thrown. The value of the
967*404b540aSrobert * string doesn't change if an error is thrown.
968*404b540aSrobert */
969*404b540aSrobert __versa_string&
970*404b540aSrobert replace(size_type __pos1, size_type __n1, const __versa_string& __str,
971*404b540aSrobert size_type __pos2, size_type __n2)
972*404b540aSrobert {
973*404b540aSrobert return this->replace(__pos1, __n1, __str._M_data()
974*404b540aSrobert + __str._M_check(__pos2,
975*404b540aSrobert "__versa_string::replace"),
976*404b540aSrobert __str._M_limit(__pos2, __n2));
977*404b540aSrobert }
978*404b540aSrobert
979*404b540aSrobert /**
980*404b540aSrobert * @brief Replace characters with value of a C substring.
981*404b540aSrobert * @param pos Index of first character to replace.
982*404b540aSrobert * @param n1 Number of characters to be replaced.
983*404b540aSrobert * @param s C string to insert.
984*404b540aSrobert * @param n2 Number of characters from @a s to use.
985*404b540aSrobert * @return Reference to this string.
986*404b540aSrobert * @throw std::out_of_range If @a pos1 > size().
987*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
988*404b540aSrobert *
989*404b540aSrobert * Removes the characters in the range [pos,pos + n1) from this string.
990*404b540aSrobert * In place, the first @a n2 characters of @a s are inserted, or all
991*404b540aSrobert * of @a s if @a n2 is too large. If @a pos is beyond end of string,
992*404b540aSrobert * out_of_range is thrown. If the length of result exceeds max_size(),
993*404b540aSrobert * length_error is thrown. The value of the string doesn't change if
994*404b540aSrobert * an error is thrown.
995*404b540aSrobert */
996*404b540aSrobert __versa_string&
997*404b540aSrobert replace(size_type __pos, size_type __n1, const _CharT* __s,
998*404b540aSrobert size_type __n2)
999*404b540aSrobert {
1000*404b540aSrobert __glibcxx_requires_string_len(__s, __n2);
1001*404b540aSrobert return _M_replace(_M_check(__pos, "__versa_string::replace"),
1002*404b540aSrobert _M_limit(__pos, __n1), __s, __n2);
1003*404b540aSrobert }
1004*404b540aSrobert
1005*404b540aSrobert /**
1006*404b540aSrobert * @brief Replace characters with value of a C string.
1007*404b540aSrobert * @param pos Index of first character to replace.
1008*404b540aSrobert * @param n1 Number of characters to be replaced.
1009*404b540aSrobert * @param s C string to insert.
1010*404b540aSrobert * @return Reference to this string.
1011*404b540aSrobert * @throw std::out_of_range If @a pos > size().
1012*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
1013*404b540aSrobert *
1014*404b540aSrobert * Removes the characters in the range [pos,pos + n1) from this string.
1015*404b540aSrobert * In place, the first @a n characters of @a s are inserted. If @a
1016*404b540aSrobert * pos is beyond end of string, out_of_range is thrown. If the length
1017*404b540aSrobert * of result exceeds max_size(), length_error is thrown. The value of
1018*404b540aSrobert * the string doesn't change if an error is thrown.
1019*404b540aSrobert */
1020*404b540aSrobert __versa_string&
1021*404b540aSrobert replace(size_type __pos, size_type __n1, const _CharT* __s)
1022*404b540aSrobert {
1023*404b540aSrobert __glibcxx_requires_string(__s);
1024*404b540aSrobert return this->replace(__pos, __n1, __s, traits_type::length(__s));
1025*404b540aSrobert }
1026*404b540aSrobert
1027*404b540aSrobert /**
1028*404b540aSrobert * @brief Replace characters with multiple characters.
1029*404b540aSrobert * @param pos Index of first character to replace.
1030*404b540aSrobert * @param n1 Number of characters to be replaced.
1031*404b540aSrobert * @param n2 Number of characters to insert.
1032*404b540aSrobert * @param c Character to insert.
1033*404b540aSrobert * @return Reference to this string.
1034*404b540aSrobert * @throw std::out_of_range If @a pos > size().
1035*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
1036*404b540aSrobert *
1037*404b540aSrobert * Removes the characters in the range [pos,pos + n1) from this string.
1038*404b540aSrobert * In place, @a n2 copies of @a c are inserted. If @a pos is beyond
1039*404b540aSrobert * end of string, out_of_range is thrown. If the length of result
1040*404b540aSrobert * exceeds max_size(), length_error is thrown. The value of the string
1041*404b540aSrobert * doesn't change if an error is thrown.
1042*404b540aSrobert */
1043*404b540aSrobert __versa_string&
1044*404b540aSrobert replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1045*404b540aSrobert { return _M_replace_aux(_M_check(__pos, "__versa_string::replace"),
1046*404b540aSrobert _M_limit(__pos, __n1), __n2, __c); }
1047*404b540aSrobert
1048*404b540aSrobert /**
1049*404b540aSrobert * @brief Replace range of characters with string.
1050*404b540aSrobert * @param i1 Iterator referencing start of range to replace.
1051*404b540aSrobert * @param i2 Iterator referencing end of range to replace.
1052*404b540aSrobert * @param str String value to insert.
1053*404b540aSrobert * @return Reference to this string.
1054*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
1055*404b540aSrobert *
1056*404b540aSrobert * Removes the characters in the range [i1,i2). In place, the value of
1057*404b540aSrobert * @a str is inserted. If the length of result exceeds max_size(),
1058*404b540aSrobert * length_error is thrown. The value of the string doesn't change if
1059*404b540aSrobert * an error is thrown.
1060*404b540aSrobert */
1061*404b540aSrobert __versa_string&
1062*404b540aSrobert replace(iterator __i1, iterator __i2, const __versa_string& __str)
1063*404b540aSrobert { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
1064*404b540aSrobert
1065*404b540aSrobert /**
1066*404b540aSrobert * @brief Replace range of characters with C substring.
1067*404b540aSrobert * @param i1 Iterator referencing start of range to replace.
1068*404b540aSrobert * @param i2 Iterator referencing end of range to replace.
1069*404b540aSrobert * @param s C string value to insert.
1070*404b540aSrobert * @param n Number of characters from s to insert.
1071*404b540aSrobert * @return Reference to this string.
1072*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
1073*404b540aSrobert *
1074*404b540aSrobert * Removes the characters in the range [i1,i2). In place, the first @a
1075*404b540aSrobert * n characters of @a s are inserted. If the length of result exceeds
1076*404b540aSrobert * max_size(), length_error is thrown. The value of the string doesn't
1077*404b540aSrobert * change if an error is thrown.
1078*404b540aSrobert */
1079*404b540aSrobert __versa_string&
1080*404b540aSrobert replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
1081*404b540aSrobert {
1082*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1083*404b540aSrobert && __i2 <= _M_iend());
1084*404b540aSrobert return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
1085*404b540aSrobert }
1086*404b540aSrobert
1087*404b540aSrobert /**
1088*404b540aSrobert * @brief Replace range of characters with C string.
1089*404b540aSrobert * @param i1 Iterator referencing start of range to replace.
1090*404b540aSrobert * @param i2 Iterator referencing end of range to replace.
1091*404b540aSrobert * @param s C string value to insert.
1092*404b540aSrobert * @return Reference to this string.
1093*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
1094*404b540aSrobert *
1095*404b540aSrobert * Removes the characters in the range [i1,i2). In place, the
1096*404b540aSrobert * characters of @a s are inserted. If the length of result exceeds
1097*404b540aSrobert * max_size(), length_error is thrown. The value of the string doesn't
1098*404b540aSrobert * change if an error is thrown.
1099*404b540aSrobert */
1100*404b540aSrobert __versa_string&
1101*404b540aSrobert replace(iterator __i1, iterator __i2, const _CharT* __s)
1102*404b540aSrobert {
1103*404b540aSrobert __glibcxx_requires_string(__s);
1104*404b540aSrobert return this->replace(__i1, __i2, __s, traits_type::length(__s));
1105*404b540aSrobert }
1106*404b540aSrobert
1107*404b540aSrobert /**
1108*404b540aSrobert * @brief Replace range of characters with multiple characters
1109*404b540aSrobert * @param i1 Iterator referencing start of range to replace.
1110*404b540aSrobert * @param i2 Iterator referencing end of range to replace.
1111*404b540aSrobert * @param n Number of characters to insert.
1112*404b540aSrobert * @param c Character to insert.
1113*404b540aSrobert * @return Reference to this string.
1114*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
1115*404b540aSrobert *
1116*404b540aSrobert * Removes the characters in the range [i1,i2). In place, @a n copies
1117*404b540aSrobert * of @a c are inserted. If the length of result exceeds max_size(),
1118*404b540aSrobert * length_error is thrown. The value of the string doesn't change if
1119*404b540aSrobert * an error is thrown.
1120*404b540aSrobert */
1121*404b540aSrobert __versa_string&
1122*404b540aSrobert replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
1123*404b540aSrobert {
1124*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1125*404b540aSrobert && __i2 <= _M_iend());
1126*404b540aSrobert return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
1127*404b540aSrobert }
1128*404b540aSrobert
1129*404b540aSrobert /**
1130*404b540aSrobert * @brief Replace range of characters with range.
1131*404b540aSrobert * @param i1 Iterator referencing start of range to replace.
1132*404b540aSrobert * @param i2 Iterator referencing end of range to replace.
1133*404b540aSrobert * @param k1 Iterator referencing start of range to insert.
1134*404b540aSrobert * @param k2 Iterator referencing end of range to insert.
1135*404b540aSrobert * @return Reference to this string.
1136*404b540aSrobert * @throw std::length_error If new length exceeds @c max_size().
1137*404b540aSrobert *
1138*404b540aSrobert * Removes the characters in the range [i1,i2). In place, characters
1139*404b540aSrobert * in the range [k1,k2) are inserted. If the length of result exceeds
1140*404b540aSrobert * max_size(), length_error is thrown. The value of the string doesn't
1141*404b540aSrobert * change if an error is thrown.
1142*404b540aSrobert */
1143*404b540aSrobert template<class _InputIterator>
1144*404b540aSrobert __versa_string&
1145*404b540aSrobert replace(iterator __i1, iterator __i2,
1146*404b540aSrobert _InputIterator __k1, _InputIterator __k2)
1147*404b540aSrobert {
1148*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1149*404b540aSrobert && __i2 <= _M_iend());
1150*404b540aSrobert __glibcxx_requires_valid_range(__k1, __k2);
1151*404b540aSrobert typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1152*404b540aSrobert return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1153*404b540aSrobert }
1154*404b540aSrobert
1155*404b540aSrobert // Specializations for the common case of pointer and iterator:
1156*404b540aSrobert // useful to avoid the overhead of temporary buffering in _M_replace.
1157*404b540aSrobert __versa_string&
1158*404b540aSrobert replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
1159*404b540aSrobert {
1160*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1161*404b540aSrobert && __i2 <= _M_iend());
1162*404b540aSrobert __glibcxx_requires_valid_range(__k1, __k2);
1163*404b540aSrobert return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1164*404b540aSrobert __k1, __k2 - __k1);
1165*404b540aSrobert }
1166*404b540aSrobert
1167*404b540aSrobert __versa_string&
1168*404b540aSrobert replace(iterator __i1, iterator __i2,
1169*404b540aSrobert const _CharT* __k1, const _CharT* __k2)
1170*404b540aSrobert {
1171*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1172*404b540aSrobert && __i2 <= _M_iend());
1173*404b540aSrobert __glibcxx_requires_valid_range(__k1, __k2);
1174*404b540aSrobert return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1175*404b540aSrobert __k1, __k2 - __k1);
1176*404b540aSrobert }
1177*404b540aSrobert
1178*404b540aSrobert __versa_string&
1179*404b540aSrobert replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
1180*404b540aSrobert {
1181*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1182*404b540aSrobert && __i2 <= _M_iend());
1183*404b540aSrobert __glibcxx_requires_valid_range(__k1, __k2);
1184*404b540aSrobert return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1185*404b540aSrobert __k1.base(), __k2 - __k1);
1186*404b540aSrobert }
1187*404b540aSrobert
1188*404b540aSrobert __versa_string&
1189*404b540aSrobert replace(iterator __i1, iterator __i2,
1190*404b540aSrobert const_iterator __k1, const_iterator __k2)
1191*404b540aSrobert {
1192*404b540aSrobert _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1193*404b540aSrobert && __i2 <= _M_iend());
1194*404b540aSrobert __glibcxx_requires_valid_range(__k1, __k2);
1195*404b540aSrobert return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1196*404b540aSrobert __k1.base(), __k2 - __k1);
1197*404b540aSrobert }
1198*404b540aSrobert
1199*404b540aSrobert private:
1200*404b540aSrobert template<class _Integer>
1201*404b540aSrobert __versa_string&
1202*404b540aSrobert _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
1203*404b540aSrobert _Integer __val, std::__true_type)
1204*404b540aSrobert { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
1205*404b540aSrobert
1206*404b540aSrobert template<class _InputIterator>
1207*404b540aSrobert __versa_string&
1208*404b540aSrobert _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
1209*404b540aSrobert _InputIterator __k2, std::__false_type);
1210*404b540aSrobert
1211*404b540aSrobert __versa_string&
1212*404b540aSrobert _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1213*404b540aSrobert _CharT __c);
1214*404b540aSrobert
1215*404b540aSrobert __versa_string&
1216*404b540aSrobert _M_replace(size_type __pos, size_type __len1, const _CharT* __s,
1217*404b540aSrobert const size_type __len2);
1218*404b540aSrobert
1219*404b540aSrobert __versa_string&
1220*404b540aSrobert _M_append(const _CharT* __s, size_type __n);
1221*404b540aSrobert
1222*404b540aSrobert public:
1223*404b540aSrobert
1224*404b540aSrobert /**
1225*404b540aSrobert * @brief Copy substring into C string.
1226*404b540aSrobert * @param s C string to copy value into.
1227*404b540aSrobert * @param n Number of characters to copy.
1228*404b540aSrobert * @param pos Index of first character to copy.
1229*404b540aSrobert * @return Number of characters actually copied
1230*404b540aSrobert * @throw std::out_of_range If pos > size().
1231*404b540aSrobert *
1232*404b540aSrobert * Copies up to @a n characters starting at @a pos into the C string @a
1233*404b540aSrobert * s. If @a pos is greater than size(), out_of_range is thrown.
1234*404b540aSrobert */
1235*404b540aSrobert size_type
1236*404b540aSrobert copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
1237*404b540aSrobert
1238*404b540aSrobert /**
1239*404b540aSrobert * @brief Swap contents with another string.
1240*404b540aSrobert * @param s String to swap with.
1241*404b540aSrobert *
1242*404b540aSrobert * Exchanges the contents of this string with that of @a s in constant
1243*404b540aSrobert * time.
1244*404b540aSrobert */
1245*404b540aSrobert void
1246*404b540aSrobert swap(__versa_string& __s)
1247*404b540aSrobert { this->_M_swap(__s); }
1248*404b540aSrobert
1249*404b540aSrobert // String operations:
1250*404b540aSrobert /**
1251*404b540aSrobert * @brief Return const pointer to null-terminated contents.
1252*404b540aSrobert *
1253*404b540aSrobert * This is a handle to internal data. Do not modify or dire things may
1254*404b540aSrobert * happen.
1255*404b540aSrobert */
1256*404b540aSrobert const _CharT*
1257*404b540aSrobert c_str() const
1258*404b540aSrobert { return this->_M_data(); }
1259*404b540aSrobert
1260*404b540aSrobert /**
1261*404b540aSrobert * @brief Return const pointer to contents.
1262*404b540aSrobert *
1263*404b540aSrobert * This is a handle to internal data. Do not modify or dire things may
1264*404b540aSrobert * happen.
1265*404b540aSrobert */
1266*404b540aSrobert const _CharT*
1267*404b540aSrobert data() const
1268*404b540aSrobert { return this->_M_data(); }
1269*404b540aSrobert
1270*404b540aSrobert /**
1271*404b540aSrobert * @brief Return copy of allocator used to construct this string.
1272*404b540aSrobert */
1273*404b540aSrobert allocator_type
1274*404b540aSrobert get_allocator() const
1275*404b540aSrobert { return allocator_type(this->_M_get_allocator()); }
1276*404b540aSrobert
1277*404b540aSrobert /**
1278*404b540aSrobert * @brief Find position of a C substring.
1279*404b540aSrobert * @param s C string to locate.
1280*404b540aSrobert * @param pos Index of character to search from.
1281*404b540aSrobert * @param n Number of characters from @a s to search for.
1282*404b540aSrobert * @return Index of start of first occurrence.
1283*404b540aSrobert *
1284*404b540aSrobert * Starting from @a pos, searches forward for the first @a n characters
1285*404b540aSrobert * in @a s within this string. If found, returns the index where it
1286*404b540aSrobert * begins. If not found, returns npos.
1287*404b540aSrobert */
1288*404b540aSrobert size_type
1289*404b540aSrobert find(const _CharT* __s, size_type __pos, size_type __n) const;
1290*404b540aSrobert
1291*404b540aSrobert /**
1292*404b540aSrobert * @brief Find position of a string.
1293*404b540aSrobert * @param str String to locate.
1294*404b540aSrobert * @param pos Index of character to search from (default 0).
1295*404b540aSrobert * @return Index of start of first occurrence.
1296*404b540aSrobert *
1297*404b540aSrobert * Starting from @a pos, searches forward for value of @a str within
1298*404b540aSrobert * this string. If found, returns the index where it begins. If not
1299*404b540aSrobert * found, returns npos.
1300*404b540aSrobert */
1301*404b540aSrobert size_type
1302*404b540aSrobert find(const __versa_string& __str, size_type __pos = 0) const
1303*404b540aSrobert { return this->find(__str.data(), __pos, __str.size()); }
1304*404b540aSrobert
1305*404b540aSrobert /**
1306*404b540aSrobert * @brief Find position of a C string.
1307*404b540aSrobert * @param s C string to locate.
1308*404b540aSrobert * @param pos Index of character to search from (default 0).
1309*404b540aSrobert * @return Index of start of first occurrence.
1310*404b540aSrobert *
1311*404b540aSrobert * Starting from @a pos, searches forward for the value of @a s within
1312*404b540aSrobert * this string. If found, returns the index where it begins. If not
1313*404b540aSrobert * found, returns npos.
1314*404b540aSrobert */
1315*404b540aSrobert size_type
1316*404b540aSrobert find(const _CharT* __s, size_type __pos = 0) const
1317*404b540aSrobert {
1318*404b540aSrobert __glibcxx_requires_string(__s);
1319*404b540aSrobert return this->find(__s, __pos, traits_type::length(__s));
1320*404b540aSrobert }
1321*404b540aSrobert
1322*404b540aSrobert /**
1323*404b540aSrobert * @brief Find position of a character.
1324*404b540aSrobert * @param c Character to locate.
1325*404b540aSrobert * @param pos Index of character to search from (default 0).
1326*404b540aSrobert * @return Index of first occurrence.
1327*404b540aSrobert *
1328*404b540aSrobert * Starting from @a pos, searches forward for @a c within this string.
1329*404b540aSrobert * If found, returns the index where it was found. If not found,
1330*404b540aSrobert * returns npos.
1331*404b540aSrobert */
1332*404b540aSrobert size_type
1333*404b540aSrobert find(_CharT __c, size_type __pos = 0) const;
1334*404b540aSrobert
1335*404b540aSrobert /**
1336*404b540aSrobert * @brief Find last position of a string.
1337*404b540aSrobert * @param str String to locate.
1338*404b540aSrobert * @param pos Index of character to search back from (default end).
1339*404b540aSrobert * @return Index of start of last occurrence.
1340*404b540aSrobert *
1341*404b540aSrobert * Starting from @a pos, searches backward for value of @a str within
1342*404b540aSrobert * this string. If found, returns the index where it begins. If not
1343*404b540aSrobert * found, returns npos.
1344*404b540aSrobert */
1345*404b540aSrobert size_type
1346*404b540aSrobert rfind(const __versa_string& __str, size_type __pos = npos) const
1347*404b540aSrobert { return this->rfind(__str.data(), __pos, __str.size()); }
1348*404b540aSrobert
1349*404b540aSrobert /**
1350*404b540aSrobert * @brief Find last position of a C substring.
1351*404b540aSrobert * @param s C string to locate.
1352*404b540aSrobert * @param pos Index of character to search back from.
1353*404b540aSrobert * @param n Number of characters from s to search for.
1354*404b540aSrobert * @return Index of start of last occurrence.
1355*404b540aSrobert *
1356*404b540aSrobert * Starting from @a pos, searches backward for the first @a n
1357*404b540aSrobert * characters in @a s within this string. If found, returns the index
1358*404b540aSrobert * where it begins. If not found, returns npos.
1359*404b540aSrobert */
1360*404b540aSrobert size_type
1361*404b540aSrobert rfind(const _CharT* __s, size_type __pos, size_type __n) const;
1362*404b540aSrobert
1363*404b540aSrobert /**
1364*404b540aSrobert * @brief Find last position of a C string.
1365*404b540aSrobert * @param s C string to locate.
1366*404b540aSrobert * @param pos Index of character to start search at (default end).
1367*404b540aSrobert * @return Index of start of last occurrence.
1368*404b540aSrobert *
1369*404b540aSrobert * Starting from @a pos, searches backward for the value of @a s within
1370*404b540aSrobert * this string. If found, returns the index where it begins. If not
1371*404b540aSrobert * found, returns npos.
1372*404b540aSrobert */
1373*404b540aSrobert size_type
1374*404b540aSrobert rfind(const _CharT* __s, size_type __pos = npos) const
1375*404b540aSrobert {
1376*404b540aSrobert __glibcxx_requires_string(__s);
1377*404b540aSrobert return this->rfind(__s, __pos, traits_type::length(__s));
1378*404b540aSrobert }
1379*404b540aSrobert
1380*404b540aSrobert /**
1381*404b540aSrobert * @brief Find last position of a character.
1382*404b540aSrobert * @param c Character to locate.
1383*404b540aSrobert * @param pos Index of character to search back from (default end).
1384*404b540aSrobert * @return Index of last occurrence.
1385*404b540aSrobert *
1386*404b540aSrobert * Starting from @a pos, searches backward for @a c within this string.
1387*404b540aSrobert * If found, returns the index where it was found. If not found,
1388*404b540aSrobert * returns npos.
1389*404b540aSrobert */
1390*404b540aSrobert size_type
1391*404b540aSrobert rfind(_CharT __c, size_type __pos = npos) const;
1392*404b540aSrobert
1393*404b540aSrobert /**
1394*404b540aSrobert * @brief Find position of a character of string.
1395*404b540aSrobert * @param str String containing characters to locate.
1396*404b540aSrobert * @param pos Index of character to search from (default 0).
1397*404b540aSrobert * @return Index of first occurrence.
1398*404b540aSrobert *
1399*404b540aSrobert * Starting from @a pos, searches forward for one of the characters of
1400*404b540aSrobert * @a str within this string. If found, returns the index where it was
1401*404b540aSrobert * found. If not found, returns npos.
1402*404b540aSrobert */
1403*404b540aSrobert size_type
1404*404b540aSrobert find_first_of(const __versa_string& __str, size_type __pos = 0) const
1405*404b540aSrobert { return this->find_first_of(__str.data(), __pos, __str.size()); }
1406*404b540aSrobert
1407*404b540aSrobert /**
1408*404b540aSrobert * @brief Find position of a character of C substring.
1409*404b540aSrobert * @param s String containing characters to locate.
1410*404b540aSrobert * @param pos Index of character to search from (default 0).
1411*404b540aSrobert * @param n Number of characters from s to search for.
1412*404b540aSrobert * @return Index of first occurrence.
1413*404b540aSrobert *
1414*404b540aSrobert * Starting from @a pos, searches forward for one of the first @a n
1415*404b540aSrobert * characters of @a s within this string. If found, returns the index
1416*404b540aSrobert * where it was found. If not found, returns npos.
1417*404b540aSrobert */
1418*404b540aSrobert size_type
1419*404b540aSrobert find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
1420*404b540aSrobert
1421*404b540aSrobert /**
1422*404b540aSrobert * @brief Find position of a character of C string.
1423*404b540aSrobert * @param s String containing characters to locate.
1424*404b540aSrobert * @param pos Index of character to search from (default 0).
1425*404b540aSrobert * @return Index of first occurrence.
1426*404b540aSrobert *
1427*404b540aSrobert * Starting from @a pos, searches forward for one of the characters of
1428*404b540aSrobert * @a s within this string. If found, returns the index where it was
1429*404b540aSrobert * found. If not found, returns npos.
1430*404b540aSrobert */
1431*404b540aSrobert size_type
1432*404b540aSrobert find_first_of(const _CharT* __s, size_type __pos = 0) const
1433*404b540aSrobert {
1434*404b540aSrobert __glibcxx_requires_string(__s);
1435*404b540aSrobert return this->find_first_of(__s, __pos, traits_type::length(__s));
1436*404b540aSrobert }
1437*404b540aSrobert
1438*404b540aSrobert /**
1439*404b540aSrobert * @brief Find position of a character.
1440*404b540aSrobert * @param c Character to locate.
1441*404b540aSrobert * @param pos Index of character to search from (default 0).
1442*404b540aSrobert * @return Index of first occurrence.
1443*404b540aSrobert *
1444*404b540aSrobert * Starting from @a pos, searches forward for the character @a c within
1445*404b540aSrobert * this string. If found, returns the index where it was found. If
1446*404b540aSrobert * not found, returns npos.
1447*404b540aSrobert *
1448*404b540aSrobert * Note: equivalent to find(c, pos).
1449*404b540aSrobert */
1450*404b540aSrobert size_type
1451*404b540aSrobert find_first_of(_CharT __c, size_type __pos = 0) const
1452*404b540aSrobert { return this->find(__c, __pos); }
1453*404b540aSrobert
1454*404b540aSrobert /**
1455*404b540aSrobert * @brief Find last position of a character of string.
1456*404b540aSrobert * @param str String containing characters to locate.
1457*404b540aSrobert * @param pos Index of character to search back from (default end).
1458*404b540aSrobert * @return Index of last occurrence.
1459*404b540aSrobert *
1460*404b540aSrobert * Starting from @a pos, searches backward for one of the characters of
1461*404b540aSrobert * @a str within this string. If found, returns the index where it was
1462*404b540aSrobert * found. If not found, returns npos.
1463*404b540aSrobert */
1464*404b540aSrobert size_type
1465*404b540aSrobert find_last_of(const __versa_string& __str, size_type __pos = npos) const
1466*404b540aSrobert { return this->find_last_of(__str.data(), __pos, __str.size()); }
1467*404b540aSrobert
1468*404b540aSrobert /**
1469*404b540aSrobert * @brief Find last position of a character of C substring.
1470*404b540aSrobert * @param s C string containing characters to locate.
1471*404b540aSrobert * @param pos Index of character to search back from (default end).
1472*404b540aSrobert * @param n Number of characters from s to search for.
1473*404b540aSrobert * @return Index of last occurrence.
1474*404b540aSrobert *
1475*404b540aSrobert * Starting from @a pos, searches backward for one of the first @a n
1476*404b540aSrobert * characters of @a s within this string. If found, returns the index
1477*404b540aSrobert * where it was found. If not found, returns npos.
1478*404b540aSrobert */
1479*404b540aSrobert size_type
1480*404b540aSrobert find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
1481*404b540aSrobert
1482*404b540aSrobert /**
1483*404b540aSrobert * @brief Find last position of a character of C string.
1484*404b540aSrobert * @param s C string containing characters to locate.
1485*404b540aSrobert * @param pos Index of character to search back from (default end).
1486*404b540aSrobert * @return Index of last occurrence.
1487*404b540aSrobert *
1488*404b540aSrobert * Starting from @a pos, searches backward for one of the characters of
1489*404b540aSrobert * @a s within this string. If found, returns the index where it was
1490*404b540aSrobert * found. If not found, returns npos.
1491*404b540aSrobert */
1492*404b540aSrobert size_type
1493*404b540aSrobert find_last_of(const _CharT* __s, size_type __pos = npos) const
1494*404b540aSrobert {
1495*404b540aSrobert __glibcxx_requires_string(__s);
1496*404b540aSrobert return this->find_last_of(__s, __pos, traits_type::length(__s));
1497*404b540aSrobert }
1498*404b540aSrobert
1499*404b540aSrobert /**
1500*404b540aSrobert * @brief Find last position of a character.
1501*404b540aSrobert * @param c Character to locate.
1502*404b540aSrobert * @param pos Index of character to search back from (default 0).
1503*404b540aSrobert * @return Index of last occurrence.
1504*404b540aSrobert *
1505*404b540aSrobert * Starting from @a pos, searches backward for @a c within this string.
1506*404b540aSrobert * If found, returns the index where it was found. If not found,
1507*404b540aSrobert * returns npos.
1508*404b540aSrobert *
1509*404b540aSrobert * Note: equivalent to rfind(c, pos).
1510*404b540aSrobert */
1511*404b540aSrobert size_type
1512*404b540aSrobert find_last_of(_CharT __c, size_type __pos = npos) const
1513*404b540aSrobert { return this->rfind(__c, __pos); }
1514*404b540aSrobert
1515*404b540aSrobert /**
1516*404b540aSrobert * @brief Find position of a character not in string.
1517*404b540aSrobert * @param str String containing characters to avoid.
1518*404b540aSrobert * @param pos Index of character to search from (default 0).
1519*404b540aSrobert * @return Index of first occurrence.
1520*404b540aSrobert *
1521*404b540aSrobert * Starting from @a pos, searches forward for a character not contained
1522*404b540aSrobert * in @a str within this string. If found, returns the index where it
1523*404b540aSrobert * was found. If not found, returns npos.
1524*404b540aSrobert */
1525*404b540aSrobert size_type
1526*404b540aSrobert find_first_not_of(const __versa_string& __str, size_type __pos = 0) const
1527*404b540aSrobert { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
1528*404b540aSrobert
1529*404b540aSrobert /**
1530*404b540aSrobert * @brief Find position of a character not in C substring.
1531*404b540aSrobert * @param s C string containing characters to avoid.
1532*404b540aSrobert * @param pos Index of character to search from (default 0).
1533*404b540aSrobert * @param n Number of characters from s to consider.
1534*404b540aSrobert * @return Index of first occurrence.
1535*404b540aSrobert *
1536*404b540aSrobert * Starting from @a pos, searches forward for a character not contained
1537*404b540aSrobert * in the first @a n characters of @a s within this string. If found,
1538*404b540aSrobert * returns the index where it was found. If not found, returns npos.
1539*404b540aSrobert */
1540*404b540aSrobert size_type
1541*404b540aSrobert find_first_not_of(const _CharT* __s, size_type __pos,
1542*404b540aSrobert size_type __n) const;
1543*404b540aSrobert
1544*404b540aSrobert /**
1545*404b540aSrobert * @brief Find position of a character not in C string.
1546*404b540aSrobert * @param s C string containing characters to avoid.
1547*404b540aSrobert * @param pos Index of character to search from (default 0).
1548*404b540aSrobert * @return Index of first occurrence.
1549*404b540aSrobert *
1550*404b540aSrobert * Starting from @a pos, searches forward for a character not contained
1551*404b540aSrobert * in @a s within this string. If found, returns the index where it
1552*404b540aSrobert * was found. If not found, returns npos.
1553*404b540aSrobert */
1554*404b540aSrobert size_type
1555*404b540aSrobert find_first_not_of(const _CharT* __s, size_type __pos = 0) const
1556*404b540aSrobert {
1557*404b540aSrobert __glibcxx_requires_string(__s);
1558*404b540aSrobert return this->find_first_not_of(__s, __pos, traits_type::length(__s));
1559*404b540aSrobert }
1560*404b540aSrobert
1561*404b540aSrobert /**
1562*404b540aSrobert * @brief Find position of a different character.
1563*404b540aSrobert * @param c Character to avoid.
1564*404b540aSrobert * @param pos Index of character to search from (default 0).
1565*404b540aSrobert * @return Index of first occurrence.
1566*404b540aSrobert *
1567*404b540aSrobert * Starting from @a pos, searches forward for a character other than @a c
1568*404b540aSrobert * within this string. If found, returns the index where it was found.
1569*404b540aSrobert * If not found, returns npos.
1570*404b540aSrobert */
1571*404b540aSrobert size_type
1572*404b540aSrobert find_first_not_of(_CharT __c, size_type __pos = 0) const;
1573*404b540aSrobert
1574*404b540aSrobert /**
1575*404b540aSrobert * @brief Find last position of a character not in string.
1576*404b540aSrobert * @param str String containing characters to avoid.
1577*404b540aSrobert * @param pos Index of character to search from (default 0).
1578*404b540aSrobert * @return Index of first occurrence.
1579*404b540aSrobert *
1580*404b540aSrobert * Starting from @a pos, searches backward for a character not
1581*404b540aSrobert * contained in @a str within this string. If found, returns the index
1582*404b540aSrobert * where it was found. If not found, returns npos.
1583*404b540aSrobert */
1584*404b540aSrobert size_type
1585*404b540aSrobert find_last_not_of(const __versa_string& __str,
1586*404b540aSrobert size_type __pos = npos) const
1587*404b540aSrobert { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
1588*404b540aSrobert
1589*404b540aSrobert /**
1590*404b540aSrobert * @brief Find last position of a character not in C substring.
1591*404b540aSrobert * @param s C string containing characters to avoid.
1592*404b540aSrobert * @param pos Index of character to search from (default 0).
1593*404b540aSrobert * @param n Number of characters from s to consider.
1594*404b540aSrobert * @return Index of first occurrence.
1595*404b540aSrobert *
1596*404b540aSrobert * Starting from @a pos, searches backward for a character not
1597*404b540aSrobert * contained in the first @a n characters of @a s within this string.
1598*404b540aSrobert * If found, returns the index where it was found. If not found,
1599*404b540aSrobert * returns npos.
1600*404b540aSrobert */
1601*404b540aSrobert size_type
1602*404b540aSrobert find_last_not_of(const _CharT* __s, size_type __pos,
1603*404b540aSrobert size_type __n) const;
1604*404b540aSrobert /**
1605*404b540aSrobert * @brief Find position of a character not in C string.
1606*404b540aSrobert * @param s C string containing characters to avoid.
1607*404b540aSrobert * @param pos Index of character to search from (default 0).
1608*404b540aSrobert * @return Index of first occurrence.
1609*404b540aSrobert *
1610*404b540aSrobert * Starting from @a pos, searches backward for a character not
1611*404b540aSrobert * contained in @a s within this string. If found, returns the index
1612*404b540aSrobert * where it was found. If not found, returns npos.
1613*404b540aSrobert */
1614*404b540aSrobert size_type
1615*404b540aSrobert find_last_not_of(const _CharT* __s, size_type __pos = npos) const
1616*404b540aSrobert {
1617*404b540aSrobert __glibcxx_requires_string(__s);
1618*404b540aSrobert return this->find_last_not_of(__s, __pos, traits_type::length(__s));
1619*404b540aSrobert }
1620*404b540aSrobert
1621*404b540aSrobert /**
1622*404b540aSrobert * @brief Find last position of a different character.
1623*404b540aSrobert * @param c Character to avoid.
1624*404b540aSrobert * @param pos Index of character to search from (default 0).
1625*404b540aSrobert * @return Index of first occurrence.
1626*404b540aSrobert *
1627*404b540aSrobert * Starting from @a pos, searches backward for a character other than
1628*404b540aSrobert * @a c within this string. If found, returns the index where it was
1629*404b540aSrobert * found. If not found, returns npos.
1630*404b540aSrobert */
1631*404b540aSrobert size_type
1632*404b540aSrobert find_last_not_of(_CharT __c, size_type __pos = npos) const;
1633*404b540aSrobert
1634*404b540aSrobert /**
1635*404b540aSrobert * @brief Get a substring.
1636*404b540aSrobert * @param pos Index of first character (default 0).
1637*404b540aSrobert * @param n Number of characters in substring (default remainder).
1638*404b540aSrobert * @return The new string.
1639*404b540aSrobert * @throw std::out_of_range If pos > size().
1640*404b540aSrobert *
1641*404b540aSrobert * Construct and return a new string using the @a n characters starting
1642*404b540aSrobert * at @a pos. If the string is too short, use the remainder of the
1643*404b540aSrobert * characters. If @a pos is beyond the end of the string, out_of_range
1644*404b540aSrobert * is thrown.
1645*404b540aSrobert */
1646*404b540aSrobert __versa_string
1647*404b540aSrobert substr(size_type __pos = 0, size_type __n = npos) const
1648*404b540aSrobert {
1649*404b540aSrobert return __versa_string(*this, _M_check(__pos, "__versa_string::substr"),
1650*404b540aSrobert __n);
1651*404b540aSrobert }
1652*404b540aSrobert
1653*404b540aSrobert /**
1654*404b540aSrobert * @brief Compare to a string.
1655*404b540aSrobert * @param str String to compare against.
1656*404b540aSrobert * @return Integer < 0, 0, or > 0.
1657*404b540aSrobert *
1658*404b540aSrobert * Returns an integer < 0 if this string is ordered before @a str, 0 if
1659*404b540aSrobert * their values are equivalent, or > 0 if this string is ordered after
1660*404b540aSrobert * @a str. Determines the effective length rlen of the strings to
1661*404b540aSrobert * compare as the smallest of size() and str.size(). The function
1662*404b540aSrobert * then compares the two strings by calling traits::compare(data(),
1663*404b540aSrobert * str.data(),rlen). If the result of the comparison is nonzero returns
1664*404b540aSrobert * it, otherwise the shorter one is ordered first.
1665*404b540aSrobert */
1666*404b540aSrobert int
1667*404b540aSrobert compare(const __versa_string& __str) const
1668*404b540aSrobert {
1669*404b540aSrobert if (this->_M_compare(__str))
1670*404b540aSrobert return 0;
1671*404b540aSrobert
1672*404b540aSrobert const size_type __size = this->size();
1673*404b540aSrobert const size_type __osize = __str.size();
1674*404b540aSrobert const size_type __len = std::min(__size, __osize);
1675*404b540aSrobert
1676*404b540aSrobert int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
1677*404b540aSrobert if (!__r)
1678*404b540aSrobert __r = __size - __osize;
1679*404b540aSrobert return __r;
1680*404b540aSrobert }
1681*404b540aSrobert
1682*404b540aSrobert /**
1683*404b540aSrobert * @brief Compare substring to a string.
1684*404b540aSrobert * @param pos Index of first character of substring.
1685*404b540aSrobert * @param n Number of characters in substring.
1686*404b540aSrobert * @param str String to compare against.
1687*404b540aSrobert * @return Integer < 0, 0, or > 0.
1688*404b540aSrobert *
1689*404b540aSrobert * Form the substring of this string from the @a n characters starting
1690*404b540aSrobert * at @a pos. Returns an integer < 0 if the substring is ordered
1691*404b540aSrobert * before @a str, 0 if their values are equivalent, or > 0 if the
1692*404b540aSrobert * substring is ordered after @a str. Determines the effective length
1693*404b540aSrobert * rlen of the strings to compare as the smallest of the length of the
1694*404b540aSrobert * substring and @a str.size(). The function then compares the two
1695*404b540aSrobert * strings by calling traits::compare(substring.data(),str.data(),rlen).
1696*404b540aSrobert * If the result of the comparison is nonzero returns it, otherwise the
1697*404b540aSrobert * shorter one is ordered first.
1698*404b540aSrobert */
1699*404b540aSrobert int
1700*404b540aSrobert compare(size_type __pos, size_type __n,
1701*404b540aSrobert const __versa_string& __str) const;
1702*404b540aSrobert
1703*404b540aSrobert /**
1704*404b540aSrobert * @brief Compare substring to a substring.
1705*404b540aSrobert * @param pos1 Index of first character of substring.
1706*404b540aSrobert * @param n1 Number of characters in substring.
1707*404b540aSrobert * @param str String to compare against.
1708*404b540aSrobert * @param pos2 Index of first character of substring of str.
1709*404b540aSrobert * @param n2 Number of characters in substring of str.
1710*404b540aSrobert * @return Integer < 0, 0, or > 0.
1711*404b540aSrobert *
1712*404b540aSrobert * Form the substring of this string from the @a n1 characters starting
1713*404b540aSrobert * at @a pos1. Form the substring of @a str from the @a n2 characters
1714*404b540aSrobert * starting at @a pos2. Returns an integer < 0 if this substring is
1715*404b540aSrobert * ordered before the substring of @a str, 0 if their values are
1716*404b540aSrobert * equivalent, or > 0 if this substring is ordered after the substring
1717*404b540aSrobert * of @a str. Determines the effective length rlen of the strings
1718*404b540aSrobert * to compare as the smallest of the lengths of the substrings. The
1719*404b540aSrobert * function then compares the two strings by calling
1720*404b540aSrobert * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen).
1721*404b540aSrobert * If the result of the comparison is nonzero returns it, otherwise the
1722*404b540aSrobert * shorter one is ordered first.
1723*404b540aSrobert */
1724*404b540aSrobert int
1725*404b540aSrobert compare(size_type __pos1, size_type __n1, const __versa_string& __str,
1726*404b540aSrobert size_type __pos2, size_type __n2) const;
1727*404b540aSrobert
1728*404b540aSrobert /**
1729*404b540aSrobert * @brief Compare to a C string.
1730*404b540aSrobert * @param s C string to compare against.
1731*404b540aSrobert * @return Integer < 0, 0, or > 0.
1732*404b540aSrobert *
1733*404b540aSrobert * Returns an integer < 0 if this string is ordered before @a s, 0 if
1734*404b540aSrobert * their values are equivalent, or > 0 if this string is ordered after
1735*404b540aSrobert * @a s. Determines the effective length rlen of the strings to
1736*404b540aSrobert * compare as the smallest of size() and the length of a string
1737*404b540aSrobert * constructed from @a s. The function then compares the two strings
1738*404b540aSrobert * by calling traits::compare(data(),s,rlen). If the result of the
1739*404b540aSrobert * comparison is nonzero returns it, otherwise the shorter one is
1740*404b540aSrobert * ordered first.
1741*404b540aSrobert */
1742*404b540aSrobert int
1743*404b540aSrobert compare(const _CharT* __s) const;
1744*404b540aSrobert
1745*404b540aSrobert // _GLIBCXX_RESOLVE_LIB_DEFECTS
1746*404b540aSrobert // 5 String::compare specification questionable
1747*404b540aSrobert /**
1748*404b540aSrobert * @brief Compare substring to a C string.
1749*404b540aSrobert * @param pos Index of first character of substring.
1750*404b540aSrobert * @param n1 Number of characters in substring.
1751*404b540aSrobert * @param s C string to compare against.
1752*404b540aSrobert * @return Integer < 0, 0, or > 0.
1753*404b540aSrobert *
1754*404b540aSrobert * Form the substring of this string from the @a n1 characters starting
1755*404b540aSrobert * at @a pos. Returns an integer < 0 if the substring is ordered
1756*404b540aSrobert * before @a s, 0 if their values are equivalent, or > 0 if the
1757*404b540aSrobert * substring is ordered after @a s. Determines the effective length
1758*404b540aSrobert * rlen of the strings to compare as the smallest of the length of the
1759*404b540aSrobert * substring and the length of a string constructed from @a s. The
1760*404b540aSrobert * function then compares the two string by calling
1761*404b540aSrobert * traits::compare(substring.data(),s,rlen). If the result of the
1762*404b540aSrobert * comparison is nonzero returns it, otherwise the shorter one is
1763*404b540aSrobert * ordered first.
1764*404b540aSrobert */
1765*404b540aSrobert int
1766*404b540aSrobert compare(size_type __pos, size_type __n1, const _CharT* __s) const;
1767*404b540aSrobert
1768*404b540aSrobert /**
1769*404b540aSrobert * @brief Compare substring against a character array.
1770*404b540aSrobert * @param pos1 Index of first character of substring.
1771*404b540aSrobert * @param n1 Number of characters in substring.
1772*404b540aSrobert * @param s character array to compare against.
1773*404b540aSrobert * @param n2 Number of characters of s.
1774*404b540aSrobert * @return Integer < 0, 0, or > 0.
1775*404b540aSrobert *
1776*404b540aSrobert * Form the substring of this string from the @a n1 characters starting
1777*404b540aSrobert * at @a pos1. Form a string from the first @a n2 characters of @a s.
1778*404b540aSrobert * Returns an integer < 0 if this substring is ordered before the string
1779*404b540aSrobert * from @a s, 0 if their values are equivalent, or > 0 if this substring
1780*404b540aSrobert * is ordered after the string from @a s. Determines the effective
1781*404b540aSrobert * length rlen of the strings to compare as the smallest of the length
1782*404b540aSrobert * of the substring and @a n2. The function then compares the two
1783*404b540aSrobert * strings by calling traits::compare(substring.data(),s,rlen). If the
1784*404b540aSrobert * result of the comparison is nonzero returns it, otherwise the shorter
1785*404b540aSrobert * one is ordered first.
1786*404b540aSrobert *
1787*404b540aSrobert * NB: s must have at least n2 characters, '\0' has no special
1788*404b540aSrobert * meaning.
1789*404b540aSrobert */
1790*404b540aSrobert int
1791*404b540aSrobert compare(size_type __pos, size_type __n1, const _CharT* __s,
1792*404b540aSrobert size_type __n2) const;
1793*404b540aSrobert };
1794*404b540aSrobert
1795*404b540aSrobert // operator+
1796*404b540aSrobert /**
1797*404b540aSrobert * @brief Concatenate two strings.
1798*404b540aSrobert * @param lhs First string.
1799*404b540aSrobert * @param rhs Last string.
1800*404b540aSrobert * @return New string with value of @a lhs followed by @a rhs.
1801*404b540aSrobert */
1802*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1803*404b540aSrobert template <typename, typename, typename> class _Base>
1804*404b540aSrobert __versa_string<_CharT, _Traits, _Alloc, _Base>
1805*404b540aSrobert operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1806*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
1807*404b540aSrobert
1808*404b540aSrobert /**
1809*404b540aSrobert * @brief Concatenate C string and string.
1810*404b540aSrobert * @param lhs First string.
1811*404b540aSrobert * @param rhs Last string.
1812*404b540aSrobert * @return New string with value of @a lhs followed by @a rhs.
1813*404b540aSrobert */
1814*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1815*404b540aSrobert template <typename, typename, typename> class _Base>
1816*404b540aSrobert __versa_string<_CharT, _Traits, _Alloc, _Base>
1817*404b540aSrobert operator+(const _CharT* __lhs,
1818*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
1819*404b540aSrobert
1820*404b540aSrobert /**
1821*404b540aSrobert * @brief Concatenate character and string.
1822*404b540aSrobert * @param lhs First string.
1823*404b540aSrobert * @param rhs Last string.
1824*404b540aSrobert * @return New string with @a lhs followed by @a rhs.
1825*404b540aSrobert */
1826*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1827*404b540aSrobert template <typename, typename, typename> class _Base>
1828*404b540aSrobert __versa_string<_CharT, _Traits, _Alloc, _Base>
1829*404b540aSrobert operator+(_CharT __lhs,
1830*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
1831*404b540aSrobert
1832*404b540aSrobert /**
1833*404b540aSrobert * @brief Concatenate string and C string.
1834*404b540aSrobert * @param lhs First string.
1835*404b540aSrobert * @param rhs Last string.
1836*404b540aSrobert * @return New string with @a lhs followed by @a rhs.
1837*404b540aSrobert */
1838*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1839*404b540aSrobert template <typename, typename, typename> class _Base>
1840*404b540aSrobert __versa_string<_CharT, _Traits, _Alloc, _Base>
1841*404b540aSrobert operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1842*404b540aSrobert const _CharT* __rhs);
1843*404b540aSrobert
1844*404b540aSrobert /**
1845*404b540aSrobert * @brief Concatenate string and character.
1846*404b540aSrobert * @param lhs First string.
1847*404b540aSrobert * @param rhs Last string.
1848*404b540aSrobert * @return New string with @a lhs followed by @a rhs.
1849*404b540aSrobert */
1850*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1851*404b540aSrobert template <typename, typename, typename> class _Base>
1852*404b540aSrobert __versa_string<_CharT, _Traits, _Alloc, _Base>
1853*404b540aSrobert operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1854*404b540aSrobert _CharT __rhs);
1855*404b540aSrobert
1856*404b540aSrobert // operator ==
1857*404b540aSrobert /**
1858*404b540aSrobert * @brief Test equivalence of two strings.
1859*404b540aSrobert * @param lhs First string.
1860*404b540aSrobert * @param rhs Second string.
1861*404b540aSrobert * @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
1862*404b540aSrobert */
1863*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1864*404b540aSrobert template <typename, typename, typename> class _Base>
1865*404b540aSrobert inline bool
1866*404b540aSrobert operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1867*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1868*404b540aSrobert { return __lhs.compare(__rhs) == 0; }
1869*404b540aSrobert
1870*404b540aSrobert /**
1871*404b540aSrobert * @brief Test equivalence of C string and string.
1872*404b540aSrobert * @param lhs C string.
1873*404b540aSrobert * @param rhs String.
1874*404b540aSrobert * @return True if @a rhs.compare(@a lhs) == 0. False otherwise.
1875*404b540aSrobert */
1876*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1877*404b540aSrobert template <typename, typename, typename> class _Base>
1878*404b540aSrobert inline bool
1879*404b540aSrobert operator==(const _CharT* __lhs,
1880*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1881*404b540aSrobert { return __rhs.compare(__lhs) == 0; }
1882*404b540aSrobert
1883*404b540aSrobert /**
1884*404b540aSrobert * @brief Test equivalence of string and C string.
1885*404b540aSrobert * @param lhs String.
1886*404b540aSrobert * @param rhs C string.
1887*404b540aSrobert * @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
1888*404b540aSrobert */
1889*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1890*404b540aSrobert template <typename, typename, typename> class _Base>
1891*404b540aSrobert inline bool
1892*404b540aSrobert operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1893*404b540aSrobert const _CharT* __rhs)
1894*404b540aSrobert { return __lhs.compare(__rhs) == 0; }
1895*404b540aSrobert
1896*404b540aSrobert // operator !=
1897*404b540aSrobert /**
1898*404b540aSrobert * @brief Test difference of two strings.
1899*404b540aSrobert * @param lhs First string.
1900*404b540aSrobert * @param rhs Second string.
1901*404b540aSrobert * @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
1902*404b540aSrobert */
1903*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1904*404b540aSrobert template <typename, typename, typename> class _Base>
1905*404b540aSrobert inline bool
1906*404b540aSrobert operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1907*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1908*404b540aSrobert { return __rhs.compare(__lhs) != 0; }
1909*404b540aSrobert
1910*404b540aSrobert /**
1911*404b540aSrobert * @brief Test difference of C string and string.
1912*404b540aSrobert * @param lhs C string.
1913*404b540aSrobert * @param rhs String.
1914*404b540aSrobert * @return True if @a rhs.compare(@a lhs) != 0. False otherwise.
1915*404b540aSrobert */
1916*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1917*404b540aSrobert template <typename, typename, typename> class _Base>
1918*404b540aSrobert inline bool
1919*404b540aSrobert operator!=(const _CharT* __lhs,
1920*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1921*404b540aSrobert { return __rhs.compare(__lhs) != 0; }
1922*404b540aSrobert
1923*404b540aSrobert /**
1924*404b540aSrobert * @brief Test difference of string and C string.
1925*404b540aSrobert * @param lhs String.
1926*404b540aSrobert * @param rhs C string.
1927*404b540aSrobert * @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
1928*404b540aSrobert */
1929*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1930*404b540aSrobert template <typename, typename, typename> class _Base>
1931*404b540aSrobert inline bool
1932*404b540aSrobert operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1933*404b540aSrobert const _CharT* __rhs)
1934*404b540aSrobert { return __lhs.compare(__rhs) != 0; }
1935*404b540aSrobert
1936*404b540aSrobert // operator <
1937*404b540aSrobert /**
1938*404b540aSrobert * @brief Test if string precedes string.
1939*404b540aSrobert * @param lhs First string.
1940*404b540aSrobert * @param rhs Second string.
1941*404b540aSrobert * @return True if @a lhs precedes @a rhs. False otherwise.
1942*404b540aSrobert */
1943*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1944*404b540aSrobert template <typename, typename, typename> class _Base>
1945*404b540aSrobert inline bool
1946*404b540aSrobert operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1947*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1948*404b540aSrobert { return __lhs.compare(__rhs) < 0; }
1949*404b540aSrobert
1950*404b540aSrobert /**
1951*404b540aSrobert * @brief Test if string precedes C string.
1952*404b540aSrobert * @param lhs String.
1953*404b540aSrobert * @param rhs C string.
1954*404b540aSrobert * @return True if @a lhs precedes @a rhs. False otherwise.
1955*404b540aSrobert */
1956*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1957*404b540aSrobert template <typename, typename, typename> class _Base>
1958*404b540aSrobert inline bool
1959*404b540aSrobert operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1960*404b540aSrobert const _CharT* __rhs)
1961*404b540aSrobert { return __lhs.compare(__rhs) < 0; }
1962*404b540aSrobert
1963*404b540aSrobert /**
1964*404b540aSrobert * @brief Test if C string precedes string.
1965*404b540aSrobert * @param lhs C string.
1966*404b540aSrobert * @param rhs String.
1967*404b540aSrobert * @return True if @a lhs precedes @a rhs. False otherwise.
1968*404b540aSrobert */
1969*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1970*404b540aSrobert template <typename, typename, typename> class _Base>
1971*404b540aSrobert inline bool
1972*404b540aSrobert operator<(const _CharT* __lhs,
1973*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1974*404b540aSrobert { return __rhs.compare(__lhs) > 0; }
1975*404b540aSrobert
1976*404b540aSrobert // operator >
1977*404b540aSrobert /**
1978*404b540aSrobert * @brief Test if string follows string.
1979*404b540aSrobert * @param lhs First string.
1980*404b540aSrobert * @param rhs Second string.
1981*404b540aSrobert * @return True if @a lhs follows @a rhs. False otherwise.
1982*404b540aSrobert */
1983*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1984*404b540aSrobert template <typename, typename, typename> class _Base>
1985*404b540aSrobert inline bool
1986*404b540aSrobert operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
1987*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
1988*404b540aSrobert { return __lhs.compare(__rhs) > 0; }
1989*404b540aSrobert
1990*404b540aSrobert /**
1991*404b540aSrobert * @brief Test if string follows C string.
1992*404b540aSrobert * @param lhs String.
1993*404b540aSrobert * @param rhs C string.
1994*404b540aSrobert * @return True if @a lhs follows @a rhs. False otherwise.
1995*404b540aSrobert */
1996*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
1997*404b540aSrobert template <typename, typename, typename> class _Base>
1998*404b540aSrobert inline bool
1999*404b540aSrobert operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2000*404b540aSrobert const _CharT* __rhs)
2001*404b540aSrobert { return __lhs.compare(__rhs) > 0; }
2002*404b540aSrobert
2003*404b540aSrobert /**
2004*404b540aSrobert * @brief Test if C string follows string.
2005*404b540aSrobert * @param lhs C string.
2006*404b540aSrobert * @param rhs String.
2007*404b540aSrobert * @return True if @a lhs follows @a rhs. False otherwise.
2008*404b540aSrobert */
2009*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2010*404b540aSrobert template <typename, typename, typename> class _Base>
2011*404b540aSrobert inline bool
2012*404b540aSrobert operator>(const _CharT* __lhs,
2013*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2014*404b540aSrobert { return __rhs.compare(__lhs) < 0; }
2015*404b540aSrobert
2016*404b540aSrobert // operator <=
2017*404b540aSrobert /**
2018*404b540aSrobert * @brief Test if string doesn't follow string.
2019*404b540aSrobert * @param lhs First string.
2020*404b540aSrobert * @param rhs Second string.
2021*404b540aSrobert * @return True if @a lhs doesn't follow @a rhs. False otherwise.
2022*404b540aSrobert */
2023*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2024*404b540aSrobert template <typename, typename, typename> class _Base>
2025*404b540aSrobert inline bool
2026*404b540aSrobert operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2027*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2028*404b540aSrobert { return __lhs.compare(__rhs) <= 0; }
2029*404b540aSrobert
2030*404b540aSrobert /**
2031*404b540aSrobert * @brief Test if string doesn't follow C string.
2032*404b540aSrobert * @param lhs String.
2033*404b540aSrobert * @param rhs C string.
2034*404b540aSrobert * @return True if @a lhs doesn't follow @a rhs. False otherwise.
2035*404b540aSrobert */
2036*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2037*404b540aSrobert template <typename, typename, typename> class _Base>
2038*404b540aSrobert inline bool
2039*404b540aSrobert operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2040*404b540aSrobert const _CharT* __rhs)
2041*404b540aSrobert { return __lhs.compare(__rhs) <= 0; }
2042*404b540aSrobert
2043*404b540aSrobert /**
2044*404b540aSrobert * @brief Test if C string doesn't follow string.
2045*404b540aSrobert * @param lhs C string.
2046*404b540aSrobert * @param rhs String.
2047*404b540aSrobert * @return True if @a lhs doesn't follow @a rhs. False otherwise.
2048*404b540aSrobert */
2049*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2050*404b540aSrobert template <typename, typename, typename> class _Base>
2051*404b540aSrobert inline bool
2052*404b540aSrobert operator<=(const _CharT* __lhs,
2053*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2054*404b540aSrobert { return __rhs.compare(__lhs) >= 0; }
2055*404b540aSrobert
2056*404b540aSrobert // operator >=
2057*404b540aSrobert /**
2058*404b540aSrobert * @brief Test if string doesn't precede string.
2059*404b540aSrobert * @param lhs First string.
2060*404b540aSrobert * @param rhs Second string.
2061*404b540aSrobert * @return True if @a lhs doesn't precede @a rhs. False otherwise.
2062*404b540aSrobert */
2063*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2064*404b540aSrobert template <typename, typename, typename> class _Base>
2065*404b540aSrobert inline bool
2066*404b540aSrobert operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2067*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2068*404b540aSrobert { return __lhs.compare(__rhs) >= 0; }
2069*404b540aSrobert
2070*404b540aSrobert /**
2071*404b540aSrobert * @brief Test if string doesn't precede C string.
2072*404b540aSrobert * @param lhs String.
2073*404b540aSrobert * @param rhs C string.
2074*404b540aSrobert * @return True if @a lhs doesn't precede @a rhs. False otherwise.
2075*404b540aSrobert */
2076*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2077*404b540aSrobert template <typename, typename, typename> class _Base>
2078*404b540aSrobert inline bool
2079*404b540aSrobert operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2080*404b540aSrobert const _CharT* __rhs)
2081*404b540aSrobert { return __lhs.compare(__rhs) >= 0; }
2082*404b540aSrobert
2083*404b540aSrobert /**
2084*404b540aSrobert * @brief Test if C string doesn't precede string.
2085*404b540aSrobert * @param lhs C string.
2086*404b540aSrobert * @param rhs String.
2087*404b540aSrobert * @return True if @a lhs doesn't precede @a rhs. False otherwise.
2088*404b540aSrobert */
2089*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2090*404b540aSrobert template <typename, typename, typename> class _Base>
2091*404b540aSrobert inline bool
2092*404b540aSrobert operator>=(const _CharT* __lhs,
2093*404b540aSrobert const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2094*404b540aSrobert { return __rhs.compare(__lhs) <= 0; }
2095*404b540aSrobert
2096*404b540aSrobert /**
2097*404b540aSrobert * @brief Swap contents of two strings.
2098*404b540aSrobert * @param lhs First string.
2099*404b540aSrobert * @param rhs Second string.
2100*404b540aSrobert *
2101*404b540aSrobert * Exchanges the contents of @a lhs and @a rhs in constant time.
2102*404b540aSrobert */
2103*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2104*404b540aSrobert template <typename, typename, typename> class _Base>
2105*404b540aSrobert inline void
swap(__versa_string<_CharT,_Traits,_Alloc,_Base> & __lhs,__versa_string<_CharT,_Traits,_Alloc,_Base> & __rhs)2106*404b540aSrobert swap(__versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2107*404b540aSrobert __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
2108*404b540aSrobert { __lhs.swap(__rhs); }
2109*404b540aSrobert
2110*404b540aSrobert _GLIBCXX_END_NAMESPACE
2111*404b540aSrobert
2112*404b540aSrobert _GLIBCXX_BEGIN_NAMESPACE(std)
2113*404b540aSrobert
2114*404b540aSrobert /**
2115*404b540aSrobert * @brief Read stream into a string.
2116*404b540aSrobert * @param is Input stream.
2117*404b540aSrobert * @param str Buffer to store into.
2118*404b540aSrobert * @return Reference to the input stream.
2119*404b540aSrobert *
2120*404b540aSrobert * Stores characters from @a is into @a str until whitespace is found, the
2121*404b540aSrobert * end of the stream is encountered, or str.max_size() is reached. If
2122*404b540aSrobert * is.width() is non-zero, that is the limit on the number of characters
2123*404b540aSrobert * stored into @a str. Any previous contents of @a str are erased.
2124*404b540aSrobert */
2125*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2126*404b540aSrobert template <typename, typename, typename> class _Base>
2127*404b540aSrobert basic_istream<_CharT, _Traits>&
2128*404b540aSrobert operator>>(basic_istream<_CharT, _Traits>& __is,
2129*404b540aSrobert __gnu_cxx::__versa_string<_CharT, _Traits,
2130*404b540aSrobert _Alloc, _Base>& __str);
2131*404b540aSrobert
2132*404b540aSrobert /**
2133*404b540aSrobert * @brief Write string to a stream.
2134*404b540aSrobert * @param os Output stream.
2135*404b540aSrobert * @param str String to write out.
2136*404b540aSrobert * @return Reference to the output stream.
2137*404b540aSrobert *
2138*404b540aSrobert * Output characters of @a str into os following the same rules as for
2139*404b540aSrobert * writing a C string.
2140*404b540aSrobert */
2141*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2142*404b540aSrobert template <typename, typename, typename> class _Base>
2143*404b540aSrobert inline basic_ostream<_CharT, _Traits>&
2144*404b540aSrobert operator<<(basic_ostream<_CharT, _Traits>& __os,
2145*404b540aSrobert const __gnu_cxx::__versa_string<_CharT, _Traits,
2146*404b540aSrobert _Alloc, _Base>& __str)
2147*404b540aSrobert {
2148*404b540aSrobert // _GLIBCXX_RESOLVE_LIB_DEFECTS
2149*404b540aSrobert // 586. string inserter not a formatted function
2150*404b540aSrobert return __ostream_insert(__os, __str.data(), __str.size());
2151*404b540aSrobert }
2152*404b540aSrobert
2153*404b540aSrobert /**
2154*404b540aSrobert * @brief Read a line from stream into a string.
2155*404b540aSrobert * @param is Input stream.
2156*404b540aSrobert * @param str Buffer to store into.
2157*404b540aSrobert * @param delim Character marking end of line.
2158*404b540aSrobert * @return Reference to the input stream.
2159*404b540aSrobert *
2160*404b540aSrobert * Stores characters from @a is into @a str until @a delim is found, the
2161*404b540aSrobert * end of the stream is encountered, or str.max_size() is reached. If
2162*404b540aSrobert * is.width() is non-zero, that is the limit on the number of characters
2163*404b540aSrobert * stored into @a str. Any previous contents of @a str are erased. If @a
2164*404b540aSrobert * delim was encountered, it is extracted but not stored into @a str.
2165*404b540aSrobert */
2166*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2167*404b540aSrobert template <typename, typename, typename> class _Base>
2168*404b540aSrobert basic_istream<_CharT, _Traits>&
2169*404b540aSrobert getline(basic_istream<_CharT, _Traits>& __is,
2170*404b540aSrobert __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str,
2171*404b540aSrobert _CharT __delim);
2172*404b540aSrobert
2173*404b540aSrobert /**
2174*404b540aSrobert * @brief Read a line from stream into a string.
2175*404b540aSrobert * @param is Input stream.
2176*404b540aSrobert * @param str Buffer to store into.
2177*404b540aSrobert * @return Reference to the input stream.
2178*404b540aSrobert *
2179*404b540aSrobert * Stores characters from is into @a str until '\n' is found, the end of
2180*404b540aSrobert * the stream is encountered, or str.max_size() is reached. If is.width()
2181*404b540aSrobert * is non-zero, that is the limit on the number of characters stored into
2182*404b540aSrobert * @a str. Any previous contents of @a str are erased. If end of line was
2183*404b540aSrobert * encountered, it is extracted but not stored into @a str.
2184*404b540aSrobert */
2185*404b540aSrobert template<typename _CharT, typename _Traits, typename _Alloc,
2186*404b540aSrobert template <typename, typename, typename> class _Base>
2187*404b540aSrobert inline basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT,_Traits> & __is,__gnu_cxx::__versa_string<_CharT,_Traits,_Alloc,_Base> & __str)2188*404b540aSrobert getline(basic_istream<_CharT, _Traits>& __is,
2189*404b540aSrobert __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str)
2190*404b540aSrobert { return getline(__is, __str, __is.widen('\n')); }
2191*404b540aSrobert
2192*404b540aSrobert _GLIBCXX_END_NAMESPACE
2193*404b540aSrobert
2194*404b540aSrobert #ifndef _GLIBCXX_EXPORT_TEMPLATE
2195*404b540aSrobert # include "vstring.tcc"
2196*404b540aSrobert #endif
2197*404b540aSrobert
2198*404b540aSrobert #endif /* _VSTRING_H */
2199