1 |
eulisse |
1.1 |
diff -Nur gccxml-060p2/share/gccxml-0.6/GCC/3.4/gccxml_builtins.h gccxml-060p3/share/gccxml-0.6/GCC/3.4/gccxml_builtins.h
|
2 |
|
|
--- gccxml-060p2/share/gccxml-0.6/GCC/3.4/gccxml_builtins.h 1970-01-01 01:00:00.000000000 +0100
|
3 |
|
|
+++ gccxml-060p3/share/gccxml-0.6/GCC/3.4/gccxml_builtins.h 2005-11-18 09:52:42.000000000 +0100
|
4 |
|
|
@@ -0,0 +1,91 @@
|
5 |
|
|
+#define __builtin_apply(x,y,z) ((void*)0)
|
6 |
|
|
+#define __builtin_nan(x) ((double)0.0)
|
7 |
|
|
+#define __builtin_nanf(x) ((float)0.0)
|
8 |
|
|
+#define __builtin_nanl(x) ((long double)0.0)
|
9 |
|
|
+#define __builtin_huge_val(x) ((double)0.0)
|
10 |
|
|
+#define __builtin_huge_valf(x) ((float)0.0)
|
11 |
|
|
+#define __builtin_huge_vall(x) ((long double)0.0)
|
12 |
|
|
+#define __builtin_apply_args(x) ((void*)0)
|
13 |
|
|
+#define __builtin_types_compatible_p(x,y) 0
|
14 |
|
|
+#define __builtin_choose_expr(x,y,z) int
|
15 |
|
|
+#define __builtin_constant_p(x) 0
|
16 |
|
|
+void __builtin_return (void *RESULT);
|
17 |
|
|
+void * __builtin_return_address (unsigned int LEVEL);
|
18 |
|
|
+void * __builtin_frame_address (unsigned int LEVEL);
|
19 |
|
|
+long __builtin_expect (long EXP, long C);
|
20 |
|
|
+void __builtin_prefetch (const void *ADDR, ...);
|
21 |
|
|
+double __builtin_inf (void);
|
22 |
|
|
+float __builtin_inff (void);
|
23 |
|
|
+long double __builtin_infl (void);
|
24 |
|
|
+double __builtin_nans (const char *str);
|
25 |
|
|
+float __builtin_nansf (const char *str);
|
26 |
|
|
+long double __builtin_nansl (const char *str);
|
27 |
|
|
+double __builtin_acos(double);
|
28 |
|
|
+float __builtin_acosf(float);
|
29 |
|
|
+long double __builtin_acosl(long double);
|
30 |
|
|
+double __builtin_asin(double);
|
31 |
|
|
+float __builtin_asinf(float);
|
32 |
|
|
+long double __builtin_asinl(long double);
|
33 |
|
|
+double __builtin_atan(double);
|
34 |
|
|
+double __builtin_atan2(double, double);
|
35 |
|
|
+float __builtin_atan2f(float, float);
|
36 |
|
|
+long double __builtin_atan2l(long double, long double);
|
37 |
|
|
+float __builtin_atanf(float);
|
38 |
|
|
+long double __builtin_atanl(long double);
|
39 |
|
|
+double __builtin_ceil(double);
|
40 |
|
|
+float __builtin_ceilf(float);
|
41 |
|
|
+long double __builtin_ceill(long double);
|
42 |
|
|
+double __builtin_cos(double);
|
43 |
|
|
+float __builtin_cosf(float);
|
44 |
|
|
+double __builtin_cosh(double);
|
45 |
|
|
+float __builtin_coshf(float);
|
46 |
|
|
+long double __builtin_coshl(long double);
|
47 |
|
|
+long double __builtin_cosl(long double);
|
48 |
|
|
+double __builtin_exp(double);
|
49 |
|
|
+float __builtin_expf(float);
|
50 |
|
|
+long double __builtin_expl(long double);
|
51 |
|
|
+double __builtin_fabs(double);
|
52 |
|
|
+float __builtin_fabsf(float);
|
53 |
|
|
+long double __builtin_fabsl(long double);
|
54 |
|
|
+double __builtin_floor(double);
|
55 |
|
|
+float __builtin_floorf(float);
|
56 |
|
|
+long double __builtin_floorl(long double);
|
57 |
|
|
+float __builtin_fmodf(float, float);
|
58 |
|
|
+long double __builtin_fmodl(long double, long double);
|
59 |
|
|
+double __builtin_frexp(double, int*);
|
60 |
|
|
+float __builtin_frexpf(float, int*);
|
61 |
|
|
+long double __builtin_frexpl(long double, int*);
|
62 |
|
|
+double __builtin_ldexp(double, int);
|
63 |
|
|
+float __builtin_ldexpf(float, int);
|
64 |
|
|
+long double __builtin_ldexpl(long double, int);
|
65 |
|
|
+double __builtin_log(double);
|
66 |
|
|
+double __builtin_log10(double);
|
67 |
|
|
+float __builtin_log10f(float);
|
68 |
|
|
+long double __builtin_log10l(long double);
|
69 |
|
|
+float __builtin_logf(float);
|
70 |
|
|
+long double __builtin_logl(long double);
|
71 |
|
|
+float __builtin_modff(float, float*);
|
72 |
|
|
+long double __builtin_modfl(long double, long double*);
|
73 |
|
|
+float __builtin_powf(float, float);
|
74 |
|
|
+long double __builtin_powl(long double, long double);
|
75 |
|
|
+double __builtin_sin(double);
|
76 |
|
|
+float __builtin_sinf(float);
|
77 |
|
|
+double __builtin_sinh(double);
|
78 |
|
|
+float __builtin_sinhf(float);
|
79 |
|
|
+long double __builtin_sinhl(long double);
|
80 |
|
|
+long double __builtin_sinl(long double);
|
81 |
|
|
+double __builtin_sqrt(double);
|
82 |
|
|
+float __builtin_sqrtf(float);
|
83 |
|
|
+long double __builtin_sqrtl(long double);
|
84 |
|
|
+double __builtin_tan(double);
|
85 |
|
|
+float __builtin_tanf(float);
|
86 |
|
|
+double __builtin_tanh(double);
|
87 |
|
|
+float __builtin_tanhf(float);
|
88 |
|
|
+long double __builtin_tanhl(long double);
|
89 |
|
|
+long double __builtin_tanl(long double);
|
90 |
|
|
+int __builtin_ctz(int);
|
91 |
|
|
+int __builtin_ctzl(long);
|
92 |
|
|
+int __builtin_ctzll(long long);
|
93 |
|
|
+int __builtin_popcount(int);
|
94 |
|
|
+int __builtin_popcountl(long);
|
95 |
|
|
+int __builtin_popcountll(long long);
|
96 |
|
|
diff -Nur gccxml-060p2/share/gccxml-0.6/GCC/4.0/string gccxml-060p3/share/gccxml-0.6/GCC/4.0/string
|
97 |
|
|
--- gccxml-060p2/share/gccxml-0.6/GCC/4.0/string 1970-01-01 01:00:00.000000000 +0100
|
98 |
|
|
+++ gccxml-060p3/share/gccxml-0.6/GCC/4.0/string 2005-07-21 18:22:45.000000000 +0200
|
99 |
|
|
@@ -0,0 +1,2481 @@
|
100 |
|
|
+// Components for manipulating sequences of characters -*- C++ -*-
|
101 |
|
|
+
|
102 |
|
|
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
|
103 |
|
|
+// Free Software Foundation, Inc.
|
104 |
|
|
+//
|
105 |
|
|
+// This file is part of the GNU ISO C++ Library. This library is free
|
106 |
|
|
+// software; you can redistribute it and/or modify it under the
|
107 |
|
|
+// terms of the GNU General Public License as published by the
|
108 |
|
|
+// Free Software Foundation; either version 2, or (at your option)
|
109 |
|
|
+// any later version.
|
110 |
|
|
+
|
111 |
|
|
+// This library is distributed in the hope that it will be useful,
|
112 |
|
|
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
113 |
|
|
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
114 |
|
|
+// GNU General Public License for more details.
|
115 |
|
|
+
|
116 |
|
|
+// You should have received a copy of the GNU General Public License along
|
117 |
|
|
+// with this library; see the file COPYING. If not, write to the Free
|
118 |
|
|
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
119 |
|
|
+// USA.
|
120 |
|
|
+
|
121 |
|
|
+// As a special exception, you may use this file as part of a free software
|
122 |
|
|
+// library without restriction. Specifically, if other files instantiate
|
123 |
|
|
+// templates or use macros or inline functions from this file, or you compile
|
124 |
|
|
+// this file and link it with other files to produce an executable, this
|
125 |
|
|
+// file does not by itself cause the resulting executable to be covered by
|
126 |
|
|
+// the GNU General Public License. This exception does not however
|
127 |
|
|
+// invalidate any other reasons why the executable file might be covered by
|
128 |
|
|
+// the GNU General Public License.
|
129 |
|
|
+
|
130 |
|
|
+//
|
131 |
|
|
+// ISO C++ 14882: 21 Strings library
|
132 |
|
|
+//
|
133 |
|
|
+
|
134 |
|
|
+/** @file string
|
135 |
|
|
+ * This is a Standard C++ Library header.
|
136 |
|
|
+ */
|
137 |
|
|
+
|
138 |
|
|
+#ifndef _GLIBCXX_STRING
|
139 |
|
|
+#define _GLIBCXX_STRING 1
|
140 |
|
|
+
|
141 |
|
|
+#pragma GCC system_header
|
142 |
|
|
+
|
143 |
|
|
+#include <bits/c++config.h>
|
144 |
|
|
+#include <bits/stringfwd.h>
|
145 |
|
|
+#include <bits/char_traits.h>
|
146 |
|
|
+#include <memory> // For allocator.
|
147 |
|
|
+#include <bits/cpp_type_traits.h>
|
148 |
|
|
+#include <iosfwd> // For operators >>, <<, and getline decls.
|
149 |
|
|
+#include <bits/stl_iterator.h>
|
150 |
|
|
+#include <bits/stl_function.h> // For less
|
151 |
|
|
+
|
152 |
|
|
+//#include <bits/basic_string.h>
|
153 |
|
|
+
|
154 |
|
|
+// Components for manipulating sequences of characters -*- C++ -*-
|
155 |
|
|
+
|
156 |
|
|
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
157 |
|
|
+// Free Software Foundation, Inc.
|
158 |
|
|
+//
|
159 |
|
|
+// This file is part of the GNU ISO C++ Library. This library is free
|
160 |
|
|
+// software; you can redistribute it and/or modify it under the
|
161 |
|
|
+// terms of the GNU General Public License as published by the
|
162 |
|
|
+// Free Software Foundation; either version 2, or (at your option)
|
163 |
|
|
+// any later version.
|
164 |
|
|
+
|
165 |
|
|
+// This library is distributed in the hope that it will be useful,
|
166 |
|
|
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
167 |
|
|
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
168 |
|
|
+// GNU General Public License for more details.
|
169 |
|
|
+
|
170 |
|
|
+// You should have received a copy of the GNU General Public License along
|
171 |
|
|
+// with this library; see the file COPYING. If not, write to the Free
|
172 |
|
|
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
173 |
|
|
+// USA.
|
174 |
|
|
+
|
175 |
|
|
+// As a special exception, you may use this file as part of a free software
|
176 |
|
|
+// library without restriction. Specifically, if other files instantiate
|
177 |
|
|
+// templates or use macros or inline functions from this file, or you compile
|
178 |
|
|
+// this file and link it with other files to produce an executable, this
|
179 |
|
|
+// file does not by itself cause the resulting executable to be covered by
|
180 |
|
|
+// the GNU General Public License. This exception does not however
|
181 |
|
|
+// invalidate any other reasons why the executable file might be covered by
|
182 |
|
|
+// the GNU General Public License.
|
183 |
|
|
+
|
184 |
|
|
+//
|
185 |
|
|
+// ISO C++ 14882: 21 Strings library
|
186 |
|
|
+//
|
187 |
|
|
+
|
188 |
|
|
+/** @file basic_string.h
|
189 |
|
|
+ * This is an internal header file, included by other library headers.
|
190 |
|
|
+ * You should not attempt to use it directly.
|
191 |
|
|
+ */
|
192 |
|
|
+
|
193 |
|
|
+#ifndef _BASIC_STRING_H
|
194 |
|
|
+#define _BASIC_STRING_H 1
|
195 |
|
|
+
|
196 |
|
|
+#pragma GCC system_header
|
197 |
|
|
+
|
198 |
|
|
+#include <bits/atomicity.h>
|
199 |
|
|
+#include <debug/debug.h>
|
200 |
|
|
+
|
201 |
|
|
+namespace std
|
202 |
|
|
+{
|
203 |
|
|
+ /**
|
204 |
|
|
+ * @class basic_string basic_string.h <string>
|
205 |
|
|
+ * @brief Managing sequences of characters and character-like objects.
|
206 |
|
|
+ *
|
207 |
|
|
+ * @ingroup Containers
|
208 |
|
|
+ * @ingroup Sequences
|
209 |
|
|
+ *
|
210 |
|
|
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
|
211 |
|
|
+ * <a href="tables.html#66">reversible container</a>, and a
|
212 |
|
|
+ * <a href="tables.html#67">sequence</a>. Of the
|
213 |
|
|
+ * <a href="tables.html#68">optional sequence requirements</a>, only
|
214 |
|
|
+ * @c push_back, @c at, and array access are supported.
|
215 |
|
|
+ *
|
216 |
|
|
+ * @doctodo
|
217 |
|
|
+ *
|
218 |
|
|
+ *
|
219 |
|
|
+ * @if maint
|
220 |
|
|
+ * Documentation? What's that?
|
221 |
|
|
+ * Nathan Myers <ncm@cantrip.org>.
|
222 |
|
|
+ *
|
223 |
|
|
+ * A string looks like this:
|
224 |
|
|
+ *
|
225 |
|
|
+ * @code
|
226 |
|
|
+ * [_Rep]
|
227 |
|
|
+ * _M_length
|
228 |
|
|
+ * [basic_string<char_type>] _M_capacity
|
229 |
|
|
+ * _M_dataplus _M_refcount
|
230 |
|
|
+ * _M_p ----------------> unnamed array of char_type
|
231 |
|
|
+ * @endcode
|
232 |
|
|
+ *
|
233 |
|
|
+ * Where the _M_p points to the first character in the string, and
|
234 |
|
|
+ * you cast it to a pointer-to-_Rep and subtract 1 to get a
|
235 |
|
|
+ * pointer to the header.
|
236 |
|
|
+ *
|
237 |
|
|
+ * This approach has the enormous advantage that a string object
|
238 |
|
|
+ * requires only one allocation. All the ugliness is confined
|
239 |
|
|
+ * within a single pair of inline functions, which each compile to
|
240 |
|
|
+ * a single "add" instruction: _Rep::_M_data(), and
|
241 |
|
|
+ * string::_M_rep(); and the allocation function which gets a
|
242 |
|
|
+ * block of raw bytes and with room enough and constructs a _Rep
|
243 |
|
|
+ * object at the front.
|
244 |
|
|
+ *
|
245 |
|
|
+ * The reason you want _M_data pointing to the character array and
|
246 |
|
|
+ * not the _Rep is so that the debugger can see the string
|
247 |
|
|
+ * contents. (Probably we should add a non-inline member to get
|
248 |
|
|
+ * the _Rep for the debugger to use, so users can check the actual
|
249 |
|
|
+ * string length.)
|
250 |
|
|
+ *
|
251 |
|
|
+ * Note that the _Rep object is a POD so that you can have a
|
252 |
|
|
+ * static "empty string" _Rep object already "constructed" before
|
253 |
|
|
+ * static constructors have run. The reference-count encoding is
|
254 |
|
|
+ * chosen so that a 0 indicates one reference, so you never try to
|
255 |
|
|
+ * destroy the empty-string _Rep object.
|
256 |
|
|
+ *
|
257 |
|
|
+ * All but the last paragraph is considered pretty conventional
|
258 |
|
|
+ * for a C++ string implementation.
|
259 |
|
|
+ * @endif
|
260 |
|
|
+ */
|
261 |
|
|
+ // 21.3 Template class basic_string
|
262 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
263 |
|
|
+ class basic_string
|
264 |
|
|
+ {
|
265 |
|
|
+ // Types:
|
266 |
|
|
+ public:
|
267 |
|
|
+ typedef _Traits traits_type;
|
268 |
|
|
+ typedef typename _Traits::char_type value_type;
|
269 |
|
|
+ typedef _Alloc allocator_type;
|
270 |
|
|
+ typedef typename _Alloc::size_type size_type;
|
271 |
|
|
+ typedef typename _Alloc::difference_type difference_type;
|
272 |
|
|
+ typedef typename _Alloc::reference reference;
|
273 |
|
|
+ typedef typename _Alloc::const_reference const_reference;
|
274 |
|
|
+ typedef typename _Alloc::pointer pointer;
|
275 |
|
|
+ typedef typename _Alloc::const_pointer const_pointer;
|
276 |
|
|
+ typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
|
277 |
|
|
+ typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
|
278 |
|
|
+ const_iterator;
|
279 |
|
|
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
280 |
|
|
+ typedef std::reverse_iterator<iterator> reverse_iterator;
|
281 |
|
|
+
|
282 |
|
|
+ private:
|
283 |
|
|
+ // _Rep: string representation
|
284 |
|
|
+ // Invariants:
|
285 |
|
|
+ // 1. String really contains _M_length + 1 characters: due to 21.3.4
|
286 |
|
|
+ // must be kept null-terminated.
|
287 |
|
|
+ // 2. _M_capacity >= _M_length
|
288 |
|
|
+ // Allocated memory is always (_M_capacity + 1) * sizeof(_CharT).
|
289 |
|
|
+ // 3. _M_refcount has three states:
|
290 |
|
|
+ // -1: leaked, one reference, no ref-copies allowed, non-const.
|
291 |
|
|
+ // 0: one reference, non-const.
|
292 |
|
|
+ // n>0: n + 1 references, operations require a lock, const.
|
293 |
|
|
+ // 4. All fields==0 is an empty string, given the extra storage
|
294 |
|
|
+ // beyond-the-end for a null terminator; thus, the shared
|
295 |
|
|
+ // empty string representation needs no constructor.
|
296 |
|
|
+
|
297 |
|
|
+ struct _Rep_base
|
298 |
|
|
+ {
|
299 |
|
|
+ size_type _M_length;
|
300 |
|
|
+ size_type _M_capacity;
|
301 |
|
|
+ _Atomic_word _M_refcount;
|
302 |
|
|
+ };
|
303 |
|
|
+
|
304 |
|
|
+ struct _Rep : _Rep_base
|
305 |
|
|
+ {
|
306 |
|
|
+ // Types:
|
307 |
|
|
+ typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
|
308 |
|
|
+
|
309 |
|
|
+ // (Public) Data members:
|
310 |
|
|
+
|
311 |
|
|
+ // The maximum number of individual char_type elements of an
|
312 |
|
|
+ // individual string is determined by _S_max_size. This is the
|
313 |
|
|
+ // value that will be returned by max_size(). (Whereas npos
|
314 |
|
|
+ // is the maximum number of bytes the allocator can allocate.)
|
315 |
|
|
+ // If one was to divvy up the theoretical largest size string,
|
316 |
|
|
+ // with a terminating character and m _CharT elements, it'd
|
317 |
|
|
+ // look like this:
|
318 |
|
|
+ // npos = sizeof(_Rep) + (m * sizeof(_CharT)) + sizeof(_CharT)
|
319 |
|
|
+ // Solving for m:
|
320 |
|
|
+ // m = ((npos - sizeof(_Rep))/sizeof(CharT)) - 1
|
321 |
|
|
+ // In addition, this implementation quarters this amount.
|
322 |
|
|
+ static const size_type _S_max_size;
|
323 |
|
|
+ static const _CharT _S_terminal;
|
324 |
|
|
+
|
325 |
|
|
+ // The following storage is init'd to 0 by the linker, resulting
|
326 |
|
|
+ // (carefully) in an empty string with one reference.
|
327 |
|
|
+ static size_type _S_empty_rep_storage[];
|
328 |
|
|
+
|
329 |
|
|
+ static _Rep&
|
330 |
|
|
+ _S_empty_rep()
|
331 |
|
|
+ { return *reinterpret_cast<_Rep*>(&_S_empty_rep_storage); }
|
332 |
|
|
+
|
333 |
|
|
+ bool
|
334 |
|
|
+ _M_is_leaked() const
|
335 |
|
|
+ { return this->_M_refcount < 0; }
|
336 |
|
|
+
|
337 |
|
|
+ bool
|
338 |
|
|
+ _M_is_shared() const
|
339 |
|
|
+ { return this->_M_refcount > 0; }
|
340 |
|
|
+
|
341 |
|
|
+ void
|
342 |
|
|
+ _M_set_leaked()
|
343 |
|
|
+ { this->_M_refcount = -1; }
|
344 |
|
|
+
|
345 |
|
|
+ void
|
346 |
|
|
+ _M_set_sharable()
|
347 |
|
|
+ { this->_M_refcount = 0; }
|
348 |
|
|
+
|
349 |
|
|
+ void
|
350 |
|
|
+ _M_set_length_and_sharable(size_type __n)
|
351 |
|
|
+ {
|
352 |
|
|
+ this->_M_set_sharable(); // One reference.
|
353 |
|
|
+ this->_M_length = __n;
|
354 |
|
|
+ this->_M_refdata()[__n] = _S_terminal; // grrr. (per 21.3.4)
|
355 |
|
|
+ // You cannot leave those LWG people alone for a second.
|
356 |
|
|
+ }
|
357 |
|
|
+
|
358 |
|
|
+ _CharT*
|
359 |
|
|
+ _M_refdata() throw()
|
360 |
|
|
+ { return reinterpret_cast<_CharT*>(this + 1); }
|
361 |
|
|
+
|
362 |
|
|
+ _CharT*
|
363 |
|
|
+ _M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2)
|
364 |
|
|
+ {
|
365 |
|
|
+ return (!_M_is_leaked() && __alloc1 == __alloc2)
|
366 |
|
|
+ ? _M_refcopy() : _M_clone(__alloc1);
|
367 |
|
|
+ }
|
368 |
|
|
+
|
369 |
|
|
+ // Create & Destroy
|
370 |
|
|
+ static _Rep*
|
371 |
|
|
+ _S_create(size_type, size_type, const _Alloc&);
|
372 |
|
|
+
|
373 |
|
|
+ void
|
374 |
|
|
+ _M_dispose(const _Alloc& __a)
|
375 |
|
|
+ {
|
376 |
|
|
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
|
377 |
|
|
+ if (__builtin_expect(this != &_S_empty_rep(), false))
|
378 |
|
|
+#endif
|
379 |
|
|
+ if (__gnu_cxx::__exchange_and_add(&this->_M_refcount, -1) <= 0)
|
380 |
|
|
+ _M_destroy(__a);
|
381 |
|
|
+ } // XXX MT
|
382 |
|
|
+
|
383 |
|
|
+ void
|
384 |
|
|
+ _M_destroy(const _Alloc&) throw();
|
385 |
|
|
+
|
386 |
|
|
+ _CharT*
|
387 |
|
|
+ _M_refcopy() throw()
|
388 |
|
|
+ {
|
389 |
|
|
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
|
390 |
|
|
+ if (__builtin_expect(this != &_S_empty_rep(), false))
|
391 |
|
|
+#endif
|
392 |
|
|
+ __gnu_cxx::__atomic_add(&this->_M_refcount, 1);
|
393 |
|
|
+ return _M_refdata();
|
394 |
|
|
+ } // XXX MT
|
395 |
|
|
+
|
396 |
|
|
+ _CharT*
|
397 |
|
|
+ _M_clone(const _Alloc&, size_type __res = 0);
|
398 |
|
|
+ };
|
399 |
|
|
+
|
400 |
|
|
+ // Use empty-base optimization: http://www.cantrip.org/emptyopt.html
|
401 |
|
|
+ struct _Alloc_hider : _Alloc
|
402 |
|
|
+ {
|
403 |
|
|
+ _Alloc_hider(_CharT* __dat, const _Alloc& __a)
|
404 |
|
|
+ : _Alloc(__a), _M_p(__dat) { }
|
405 |
|
|
+
|
406 |
|
|
+ _CharT* _M_p; // The actual data.
|
407 |
|
|
+ };
|
408 |
|
|
+
|
409 |
|
|
+ public:
|
410 |
|
|
+ // Data Members (public):
|
411 |
|
|
+ // NB: This is an unsigned type, and thus represents the maximum
|
412 |
|
|
+ // size that the allocator can hold.
|
413 |
|
|
+ /// Value returned by various member functions when they fail.
|
414 |
|
|
+ static const size_type npos = static_cast<size_type>(-1);
|
415 |
|
|
+
|
416 |
|
|
+ private:
|
417 |
|
|
+ // Data Members (private):
|
418 |
|
|
+ mutable _Alloc_hider _M_dataplus;
|
419 |
|
|
+
|
420 |
|
|
+ _CharT*
|
421 |
|
|
+ _M_data() const
|
422 |
|
|
+ { return _M_dataplus._M_p; }
|
423 |
|
|
+
|
424 |
|
|
+ _CharT*
|
425 |
|
|
+ _M_data(_CharT* __p)
|
426 |
|
|
+ { return (_M_dataplus._M_p = __p); }
|
427 |
|
|
+
|
428 |
|
|
+ _Rep*
|
429 |
|
|
+ _M_rep() const
|
430 |
|
|
+ { return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); }
|
431 |
|
|
+
|
432 |
|
|
+ // For the internal use we have functions similar to `begin'/`end'
|
433 |
|
|
+ // but they do not call _M_leak.
|
434 |
|
|
+ iterator
|
435 |
|
|
+ _M_ibegin() const
|
436 |
|
|
+ { return iterator(_M_data()); }
|
437 |
|
|
+
|
438 |
|
|
+ iterator
|
439 |
|
|
+ _M_iend() const
|
440 |
|
|
+ { return iterator(_M_data() + this->size()); }
|
441 |
|
|
+
|
442 |
|
|
+ void
|
443 |
|
|
+ _M_leak() // for use in begin() & non-const op[]
|
444 |
|
|
+ {
|
445 |
|
|
+ if (!_M_rep()->_M_is_leaked())
|
446 |
|
|
+ _M_leak_hard();
|
447 |
|
|
+ }
|
448 |
|
|
+
|
449 |
|
|
+ size_type
|
450 |
|
|
+ _M_check(size_type __pos, const char* __s) const
|
451 |
|
|
+ {
|
452 |
|
|
+ if (__pos > this->size())
|
453 |
|
|
+ __throw_out_of_range(__N(__s));
|
454 |
|
|
+ return __pos;
|
455 |
|
|
+ }
|
456 |
|
|
+
|
457 |
|
|
+ void
|
458 |
|
|
+ _M_check_length(size_type __n1, size_type __n2, const char* __s) const
|
459 |
|
|
+ {
|
460 |
|
|
+ if (this->max_size() - (this->size() - __n1) < __n2)
|
461 |
|
|
+ __throw_length_error(__N(__s));
|
462 |
|
|
+ }
|
463 |
|
|
+
|
464 |
|
|
+ // NB: _M_limit doesn't check for a bad __pos value.
|
465 |
|
|
+ size_type
|
466 |
|
|
+ _M_limit(size_type __pos, size_type __off) const
|
467 |
|
|
+ {
|
468 |
|
|
+ const bool __testoff = __off < this->size() - __pos;
|
469 |
|
|
+ return __testoff ? __off : this->size() - __pos;
|
470 |
|
|
+ }
|
471 |
|
|
+
|
472 |
|
|
+ // True if _Rep and source do not overlap.
|
473 |
|
|
+ bool
|
474 |
|
|
+ _M_disjunct(const _CharT* __s) const
|
475 |
|
|
+ {
|
476 |
|
|
+ return less<const _CharT*>()(__s, _M_data()) || less<const _CharT*>()(_M_data() + this->size(), __s);
|
477 |
|
|
+ }
|
478 |
|
|
+
|
479 |
|
|
+ // When __n = 1 way faster than the general multichar
|
480 |
|
|
+ // traits_type::copy/move/assign.
|
481 |
|
|
+ static void
|
482 |
|
|
+ _M_copy(_CharT* __d, const _CharT* __s, size_type __n)
|
483 |
|
|
+ {
|
484 |
|
|
+ if (__n == 1)
|
485 |
|
|
+ traits_type::assign(*__d, *__s);
|
486 |
|
|
+ else
|
487 |
|
|
+ traits_type::copy(__d, __s, __n);
|
488 |
|
|
+ }
|
489 |
|
|
+
|
490 |
|
|
+ static void
|
491 |
|
|
+ _M_move(_CharT* __d, const _CharT* __s, size_type __n)
|
492 |
|
|
+ {
|
493 |
|
|
+ if (__n == 1)
|
494 |
|
|
+ traits_type::assign(*__d, *__s);
|
495 |
|
|
+ else
|
496 |
|
|
+ traits_type::move(__d, __s, __n);
|
497 |
|
|
+ }
|
498 |
|
|
+
|
499 |
|
|
+ static void
|
500 |
|
|
+ _M_assign(_CharT* __d, size_type __n, _CharT __c)
|
501 |
|
|
+ {
|
502 |
|
|
+ if (__n == 1)
|
503 |
|
|
+ traits_type::assign(*__d, __c);
|
504 |
|
|
+ else
|
505 |
|
|
+ traits_type::assign(__d, __n, __c);
|
506 |
|
|
+ }
|
507 |
|
|
+
|
508 |
|
|
+ // _S_copy_chars is a separate template to permit specialization
|
509 |
|
|
+ // to optimize for the common case of pointers as iterators.
|
510 |
|
|
+ template<class _Iterator>
|
511 |
|
|
+ static void
|
512 |
|
|
+ _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
|
513 |
|
|
+ {
|
514 |
|
|
+ for (; __k1 != __k2; ++__k1, ++__p)
|
515 |
|
|
+ traits_type::assign(*__p, *__k1); // These types are off.
|
516 |
|
|
+ }
|
517 |
|
|
+
|
518 |
|
|
+ static void
|
519 |
|
|
+ _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
|
520 |
|
|
+ { _S_copy_chars(__p, __k1.base(), __k2.base()); }
|
521 |
|
|
+
|
522 |
|
|
+ static void
|
523 |
|
|
+ _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
|
524 |
|
|
+ { _S_copy_chars(__p, __k1.base(), __k2.base()); }
|
525 |
|
|
+
|
526 |
|
|
+ static void
|
527 |
|
|
+ _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
|
528 |
|
|
+ { _M_copy(__p, __k1, __k2 - __k1); }
|
529 |
|
|
+
|
530 |
|
|
+ static void
|
531 |
|
|
+ _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
|
532 |
|
|
+ { _M_copy(__p, __k1, __k2 - __k1); }
|
533 |
|
|
+
|
534 |
|
|
+ void
|
535 |
|
|
+ _M_mutate(size_type __pos, size_type __len1, size_type __len2);
|
536 |
|
|
+
|
537 |
|
|
+ void
|
538 |
|
|
+ _M_leak_hard();
|
539 |
|
|
+
|
540 |
|
|
+ static _Rep&
|
541 |
|
|
+ _S_empty_rep()
|
542 |
|
|
+ { return _Rep::_S_empty_rep(); }
|
543 |
|
|
+
|
544 |
|
|
+ public:
|
545 |
|
|
+ // Construct/copy/destroy:
|
546 |
|
|
+ // NB: We overload ctors in some cases instead of using default
|
547 |
|
|
+ // arguments, per 17.4.4.4 para. 2 item 2.
|
548 |
|
|
+
|
549 |
|
|
+ /**
|
550 |
|
|
+ * @brief Default constructor creates an empty string.
|
551 |
|
|
+ */
|
552 |
|
|
+ inline
|
553 |
|
|
+ basic_string();
|
554 |
|
|
+
|
555 |
|
|
+ /**
|
556 |
|
|
+ * @brief Construct an empty string using allocator a.
|
557 |
|
|
+ */
|
558 |
|
|
+ explicit
|
559 |
|
|
+ basic_string(const _Alloc& __a);
|
560 |
|
|
+
|
561 |
|
|
+ // NB: per LWG issue 42, semantics different from IS:
|
562 |
|
|
+ /**
|
563 |
|
|
+ * @brief Construct string with copy of value of @a str.
|
564 |
|
|
+ * @param str Source string.
|
565 |
|
|
+ */
|
566 |
|
|
+ basic_string(const basic_string& __str);
|
567 |
|
|
+ /**
|
568 |
|
|
+ * @brief Construct string as copy of a substring.
|
569 |
|
|
+ * @param str Source string.
|
570 |
|
|
+ * @param pos Index of first character to copy from.
|
571 |
|
|
+ * @param n Number of characters to copy (default remainder).
|
572 |
|
|
+ */
|
573 |
|
|
+ basic_string(const basic_string& __str, size_type __pos,
|
574 |
|
|
+ size_type __n = npos);
|
575 |
|
|
+ /**
|
576 |
|
|
+ * @brief Construct string as copy of a substring.
|
577 |
|
|
+ * @param str Source string.
|
578 |
|
|
+ * @param pos Index of first character to copy from.
|
579 |
|
|
+ * @param n Number of characters to copy.
|
580 |
|
|
+ * @param a Allocator to use.
|
581 |
|
|
+ */
|
582 |
|
|
+ basic_string(const basic_string& __str, size_type __pos,
|
583 |
|
|
+ size_type __n, const _Alloc& __a);
|
584 |
|
|
+
|
585 |
|
|
+ /**
|
586 |
|
|
+ * @brief Construct string initialized by a character array.
|
587 |
|
|
+ * @param s Source character array.
|
588 |
|
|
+ * @param n Number of characters to copy.
|
589 |
|
|
+ * @param a Allocator to use (default is default allocator).
|
590 |
|
|
+ *
|
591 |
|
|
+ * NB: s must have at least n characters, '\0' has no special
|
592 |
|
|
+ * meaning.
|
593 |
|
|
+ */
|
594 |
|
|
+ basic_string(const _CharT* __s, size_type __n,
|
595 |
|
|
+ const _Alloc& __a = _Alloc());
|
596 |
|
|
+ /**
|
597 |
|
|
+ * @brief Construct string as copy of a C string.
|
598 |
|
|
+ * @param s Source C string.
|
599 |
|
|
+ * @param a Allocator to use (default is default allocator).
|
600 |
|
|
+ */
|
601 |
|
|
+ basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
|
602 |
|
|
+ /**
|
603 |
|
|
+ * @brief Construct string as multiple characters.
|
604 |
|
|
+ * @param n Number of characters.
|
605 |
|
|
+ * @param c Character to use.
|
606 |
|
|
+ * @param a Allocator to use (default is default allocator).
|
607 |
|
|
+ */
|
608 |
|
|
+ basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc());
|
609 |
|
|
+
|
610 |
|
|
+ /**
|
611 |
|
|
+ * @brief Construct string as copy of a range.
|
612 |
|
|
+ * @param beg Start of range.
|
613 |
|
|
+ * @param end End of range.
|
614 |
|
|
+ * @param a Allocator to use (default is default allocator).
|
615 |
|
|
+ */
|
616 |
|
|
+ template<class _InputIterator>
|
617 |
|
|
+ basic_string(_InputIterator __beg, _InputIterator __end,
|
618 |
|
|
+ const _Alloc& __a = _Alloc());
|
619 |
|
|
+
|
620 |
|
|
+ /**
|
621 |
|
|
+ * @brief Destroy the string instance.
|
622 |
|
|
+ */
|
623 |
|
|
+ ~basic_string()
|
624 |
|
|
+ { _M_rep()->_M_dispose(this->get_allocator()); }
|
625 |
|
|
+
|
626 |
|
|
+ /**
|
627 |
|
|
+ * @brief Assign the value of @a str to this string.
|
628 |
|
|
+ * @param str Source string.
|
629 |
|
|
+ */
|
630 |
|
|
+ basic_string&
|
631 |
|
|
+ operator=(const basic_string& __str)
|
632 |
|
|
+ { return this->assign(__str); }
|
633 |
|
|
+
|
634 |
|
|
+ /**
|
635 |
|
|
+ * @brief Copy contents of @a s into this string.
|
636 |
|
|
+ * @param s Source null-terminated string.
|
637 |
|
|
+ */
|
638 |
|
|
+ basic_string&
|
639 |
|
|
+ operator=(const _CharT* __s)
|
640 |
|
|
+ { return this->assign(__s); }
|
641 |
|
|
+
|
642 |
|
|
+ /**
|
643 |
|
|
+ * @brief Set value to string of length 1.
|
644 |
|
|
+ * @param c Source character.
|
645 |
|
|
+ *
|
646 |
|
|
+ * Assigning to a character makes this string length 1 and
|
647 |
|
|
+ * (*this)[0] == @a c.
|
648 |
|
|
+ */
|
649 |
|
|
+ basic_string&
|
650 |
|
|
+ operator=(_CharT __c)
|
651 |
|
|
+ {
|
652 |
|
|
+ this->assign(1, __c);
|
653 |
|
|
+ return *this;
|
654 |
|
|
+ }
|
655 |
|
|
+
|
656 |
|
|
+ // Iterators:
|
657 |
|
|
+ /**
|
658 |
|
|
+ * Returns a read/write iterator that points to the first character in
|
659 |
|
|
+ * the %string. Unshares the string.
|
660 |
|
|
+ */
|
661 |
|
|
+ iterator
|
662 |
|
|
+ begin()
|
663 |
|
|
+ {
|
664 |
|
|
+ _M_leak();
|
665 |
|
|
+ return iterator(_M_data());
|
666 |
|
|
+ }
|
667 |
|
|
+
|
668 |
|
|
+ /**
|
669 |
|
|
+ * Returns a read-only (constant) iterator that points to the first
|
670 |
|
|
+ * character in the %string.
|
671 |
|
|
+ */
|
672 |
|
|
+ const_iterator
|
673 |
|
|
+ begin() const
|
674 |
|
|
+ { return const_iterator(_M_data()); }
|
675 |
|
|
+
|
676 |
|
|
+ /**
|
677 |
|
|
+ * Returns a read/write iterator that points one past the last
|
678 |
|
|
+ * character in the %string. Unshares the string.
|
679 |
|
|
+ */
|
680 |
|
|
+ iterator
|
681 |
|
|
+ end()
|
682 |
|
|
+ {
|
683 |
|
|
+ _M_leak();
|
684 |
|
|
+ return iterator(_M_data() + this->size());
|
685 |
|
|
+ }
|
686 |
|
|
+
|
687 |
|
|
+ /**
|
688 |
|
|
+ * Returns a read-only (constant) iterator that points one past the
|
689 |
|
|
+ * last character in the %string.
|
690 |
|
|
+ */
|
691 |
|
|
+ const_iterator
|
692 |
|
|
+ end() const
|
693 |
|
|
+ { return const_iterator(_M_data() + this->size()); }
|
694 |
|
|
+
|
695 |
|
|
+ /**
|
696 |
|
|
+ * Returns a read/write reverse iterator that points to the last
|
697 |
|
|
+ * character in the %string. Iteration is done in reverse element
|
698 |
|
|
+ * order. Unshares the string.
|
699 |
|
|
+ */
|
700 |
|
|
+ reverse_iterator
|
701 |
|
|
+ rbegin()
|
702 |
|
|
+ { return reverse_iterator(this->end()); }
|
703 |
|
|
+
|
704 |
|
|
+ /**
|
705 |
|
|
+ * Returns a read-only (constant) reverse iterator that points
|
706 |
|
|
+ * to the last character in the %string. Iteration is done in
|
707 |
|
|
+ * reverse element order.
|
708 |
|
|
+ */
|
709 |
|
|
+ const_reverse_iterator
|
710 |
|
|
+ rbegin() const
|
711 |
|
|
+ { return const_reverse_iterator(this->end()); }
|
712 |
|
|
+
|
713 |
|
|
+ /**
|
714 |
|
|
+ * Returns a read/write reverse iterator that points to one before the
|
715 |
|
|
+ * first character in the %string. Iteration is done in reverse
|
716 |
|
|
+ * element order. Unshares the string.
|
717 |
|
|
+ */
|
718 |
|
|
+ reverse_iterator
|
719 |
|
|
+ rend()
|
720 |
|
|
+ { return reverse_iterator(this->begin()); }
|
721 |
|
|
+
|
722 |
|
|
+ /**
|
723 |
|
|
+ * Returns a read-only (constant) reverse iterator that points
|
724 |
|
|
+ * to one before the first character in the %string. Iteration
|
725 |
|
|
+ * is done in reverse element order.
|
726 |
|
|
+ */
|
727 |
|
|
+ const_reverse_iterator
|
728 |
|
|
+ rend() const
|
729 |
|
|
+ { return const_reverse_iterator(this->begin()); }
|
730 |
|
|
+
|
731 |
|
|
+ public:
|
732 |
|
|
+ // Capacity:
|
733 |
|
|
+ /// Returns the number of characters in the string, not including any
|
734 |
|
|
+ /// null-termination.
|
735 |
|
|
+ size_type
|
736 |
|
|
+ size() const
|
737 |
|
|
+ { return _M_rep()->_M_length; }
|
738 |
|
|
+
|
739 |
|
|
+ /// Returns the number of characters in the string, not including any
|
740 |
|
|
+ /// null-termination.
|
741 |
|
|
+ size_type
|
742 |
|
|
+ length() const
|
743 |
|
|
+ { return _M_rep()->_M_length; }
|
744 |
|
|
+
|
745 |
|
|
+ /// Returns the size() of the largest possible %string.
|
746 |
|
|
+ size_type
|
747 |
|
|
+ max_size() const
|
748 |
|
|
+ { return _Rep::_S_max_size; }
|
749 |
|
|
+
|
750 |
|
|
+ /**
|
751 |
|
|
+ * @brief Resizes the %string to the specified number of characters.
|
752 |
|
|
+ * @param n Number of characters the %string should contain.
|
753 |
|
|
+ * @param c Character to fill any new elements.
|
754 |
|
|
+ *
|
755 |
|
|
+ * This function will %resize the %string to the specified
|
756 |
|
|
+ * number of characters. If the number is smaller than the
|
757 |
|
|
+ * %string's current size the %string is truncated, otherwise
|
758 |
|
|
+ * the %string is extended and new elements are set to @a c.
|
759 |
|
|
+ */
|
760 |
|
|
+ void
|
761 |
|
|
+ resize(size_type __n, _CharT __c);
|
762 |
|
|
+
|
763 |
|
|
+ /**
|
764 |
|
|
+ * @brief Resizes the %string to the specified number of characters.
|
765 |
|
|
+ * @param n Number of characters the %string should contain.
|
766 |
|
|
+ *
|
767 |
|
|
+ * This function will resize the %string to the specified length. If
|
768 |
|
|
+ * the new size is smaller than the %string's current size the %string
|
769 |
|
|
+ * is truncated, otherwise the %string is extended and new characters
|
770 |
|
|
+ * are default-constructed. For basic types such as char, this means
|
771 |
|
|
+ * setting them to 0.
|
772 |
|
|
+ */
|
773 |
|
|
+ void
|
774 |
|
|
+ resize(size_type __n)
|
775 |
|
|
+ { this->resize(__n, _CharT()); }
|
776 |
|
|
+
|
777 |
|
|
+ /**
|
778 |
|
|
+ * Returns the total number of characters that the %string can hold
|
779 |
|
|
+ * before needing to allocate more memory.
|
780 |
|
|
+ */
|
781 |
|
|
+ size_type
|
782 |
|
|
+ capacity() const
|
783 |
|
|
+ { return _M_rep()->_M_capacity; }
|
784 |
|
|
+
|
785 |
|
|
+ /**
|
786 |
|
|
+ * @brief Attempt to preallocate enough memory for specified number of
|
787 |
|
|
+ * characters.
|
788 |
|
|
+ * @param n Number of characters required.
|
789 |
|
|
+ * @throw std::length_error If @a n exceeds @c max_size().
|
790 |
|
|
+ *
|
791 |
|
|
+ * This function attempts to reserve enough memory for the
|
792 |
|
|
+ * %string to hold the specified number of characters. If the
|
793 |
|
|
+ * number requested is more than max_size(), length_error is
|
794 |
|
|
+ * thrown.
|
795 |
|
|
+ *
|
796 |
|
|
+ * The advantage of this function is that if optimal code is a
|
797 |
|
|
+ * necessity and the user can determine the string length that will be
|
798 |
|
|
+ * required, the user can reserve the memory in %advance, and thus
|
799 |
|
|
+ * prevent a possible reallocation of memory and copying of %string
|
800 |
|
|
+ * data.
|
801 |
|
|
+ */
|
802 |
|
|
+ void
|
803 |
|
|
+ reserve(size_type __res_arg = 0);
|
804 |
|
|
+
|
805 |
|
|
+ /**
|
806 |
|
|
+ * Erases the string, making it empty.
|
807 |
|
|
+ */
|
808 |
|
|
+ void
|
809 |
|
|
+ clear()
|
810 |
|
|
+ { _M_mutate(0, this->size(), 0); }
|
811 |
|
|
+
|
812 |
|
|
+ /**
|
813 |
|
|
+ * Returns true if the %string is empty. Equivalent to *this == "".
|
814 |
|
|
+ */
|
815 |
|
|
+ bool
|
816 |
|
|
+ empty() const
|
817 |
|
|
+ { return this->size() == 0; }
|
818 |
|
|
+
|
819 |
|
|
+ // Element access:
|
820 |
|
|
+ /**
|
821 |
|
|
+ * @brief Subscript access to the data contained in the %string.
|
822 |
|
|
+ * @param n The index of the character to access.
|
823 |
|
|
+ * @return Read-only (constant) reference to the character.
|
824 |
|
|
+ *
|
825 |
|
|
+ * This operator allows for easy, array-style, data access.
|
826 |
|
|
+ * Note that data access with this operator is unchecked and
|
827 |
|
|
+ * out_of_range lookups are not defined. (For checked lookups
|
828 |
|
|
+ * see at().)
|
829 |
|
|
+ */
|
830 |
|
|
+ const_reference
|
831 |
|
|
+ operator[] (size_type __pos) const
|
832 |
|
|
+ {
|
833 |
|
|
+ _GLIBCXX_DEBUG_ASSERT(__pos <= size());
|
834 |
|
|
+ return _M_data()[__pos];
|
835 |
|
|
+ }
|
836 |
|
|
+
|
837 |
|
|
+ /**
|
838 |
|
|
+ * @brief Subscript access to the data contained in the %string.
|
839 |
|
|
+ * @param n The index of the character to access.
|
840 |
|
|
+ * @return Read/write reference to the character.
|
841 |
|
|
+ *
|
842 |
|
|
+ * This operator allows for easy, array-style, data access.
|
843 |
|
|
+ * Note that data access with this operator is unchecked and
|
844 |
|
|
+ * out_of_range lookups are not defined. (For checked lookups
|
845 |
|
|
+ * see at().) Unshares the string.
|
846 |
|
|
+ */
|
847 |
|
|
+ reference
|
848 |
|
|
+ operator[](size_type __pos)
|
849 |
|
|
+ {
|
850 |
|
|
+ _GLIBCXX_DEBUG_ASSERT(__pos < size());
|
851 |
|
|
+ _M_leak();
|
852 |
|
|
+ return _M_data()[__pos];
|
853 |
|
|
+ }
|
854 |
|
|
+
|
855 |
|
|
+ /**
|
856 |
|
|
+ * @brief Provides access to the data contained in the %string.
|
857 |
|
|
+ * @param n The index of the character to access.
|
858 |
|
|
+ * @return Read-only (const) reference to the character.
|
859 |
|
|
+ * @throw std::out_of_range If @a n is an invalid index.
|
860 |
|
|
+ *
|
861 |
|
|
+ * This function provides for safer data access. The parameter is
|
862 |
|
|
+ * first checked that it is in the range of the string. The function
|
863 |
|
|
+ * throws out_of_range if the check fails.
|
864 |
|
|
+ */
|
865 |
|
|
+ const_reference
|
866 |
|
|
+ at(size_type __n) const
|
867 |
|
|
+ {
|
868 |
|
|
+ if (__n >= this->size())
|
869 |
|
|
+ __throw_out_of_range(__N("basic_string::at"));
|
870 |
|
|
+ return _M_data()[__n];
|
871 |
|
|
+ }
|
872 |
|
|
+
|
873 |
|
|
+ /**
|
874 |
|
|
+ * @brief Provides access to the data contained in the %string.
|
875 |
|
|
+ * @param n The index of the character to access.
|
876 |
|
|
+ * @return Read/write reference to the character.
|
877 |
|
|
+ * @throw std::out_of_range If @a n is an invalid index.
|
878 |
|
|
+ *
|
879 |
|
|
+ * This function provides for safer data access. The parameter is
|
880 |
|
|
+ * first checked that it is in the range of the string. The function
|
881 |
|
|
+ * throws out_of_range if the check fails. Success results in
|
882 |
|
|
+ * unsharing the string.
|
883 |
|
|
+ */
|
884 |
|
|
+ reference
|
885 |
|
|
+ at(size_type __n)
|
886 |
|
|
+ {
|
887 |
|
|
+ if (__n >= size())
|
888 |
|
|
+ __throw_out_of_range(__N("basic_string::at"));
|
889 |
|
|
+ _M_leak();
|
890 |
|
|
+ return _M_data()[__n];
|
891 |
|
|
+ }
|
892 |
|
|
+
|
893 |
|
|
+ // Modifiers:
|
894 |
|
|
+ /**
|
895 |
|
|
+ * @brief Append a string to this string.
|
896 |
|
|
+ * @param str The string to append.
|
897 |
|
|
+ * @return Reference to this string.
|
898 |
|
|
+ */
|
899 |
|
|
+ basic_string&
|
900 |
|
|
+ operator+=(const basic_string& __str)
|
901 |
|
|
+ { return this->append(__str); }
|
902 |
|
|
+
|
903 |
|
|
+ /**
|
904 |
|
|
+ * @brief Append a C string.
|
905 |
|
|
+ * @param s The C string to append.
|
906 |
|
|
+ * @return Reference to this string.
|
907 |
|
|
+ */
|
908 |
|
|
+ basic_string&
|
909 |
|
|
+ operator+=(const _CharT* __s)
|
910 |
|
|
+ { return this->append(__s); }
|
911 |
|
|
+
|
912 |
|
|
+ /**
|
913 |
|
|
+ * @brief Append a character.
|
914 |
|
|
+ * @param s The character to append.
|
915 |
|
|
+ * @return Reference to this string.
|
916 |
|
|
+ */
|
917 |
|
|
+ basic_string&
|
918 |
|
|
+ operator+=(_CharT __c)
|
919 |
|
|
+ {
|
920 |
|
|
+ this->push_back(__c);
|
921 |
|
|
+ return *this;
|
922 |
|
|
+ }
|
923 |
|
|
+
|
924 |
|
|
+ /**
|
925 |
|
|
+ * @brief Append a string to this string.
|
926 |
|
|
+ * @param str The string to append.
|
927 |
|
|
+ * @return Reference to this string.
|
928 |
|
|
+ */
|
929 |
|
|
+ basic_string&
|
930 |
|
|
+ append(const basic_string& __str);
|
931 |
|
|
+
|
932 |
|
|
+ /**
|
933 |
|
|
+ * @brief Append a substring.
|
934 |
|
|
+ * @param str The string to append.
|
935 |
|
|
+ * @param pos Index of the first character of str to append.
|
936 |
|
|
+ * @param n The number of characters to append.
|
937 |
|
|
+ * @return Reference to this string.
|
938 |
|
|
+ * @throw std::out_of_range if @a pos is not a valid index.
|
939 |
|
|
+ *
|
940 |
|
|
+ * This function appends @a n characters from @a str starting at @a pos
|
941 |
|
|
+ * to this string. If @a n is is larger than the number of available
|
942 |
|
|
+ * characters in @a str, the remainder of @a str is appended.
|
943 |
|
|
+ */
|
944 |
|
|
+ basic_string&
|
945 |
|
|
+ append(const basic_string& __str, size_type __pos, size_type __n);
|
946 |
|
|
+
|
947 |
|
|
+ /**
|
948 |
|
|
+ * @brief Append a C substring.
|
949 |
|
|
+ * @param s The C string to append.
|
950 |
|
|
+ * @param n The number of characters to append.
|
951 |
|
|
+ * @return Reference to this string.
|
952 |
|
|
+ */
|
953 |
|
|
+ basic_string&
|
954 |
|
|
+ append(const _CharT* __s, size_type __n);
|
955 |
|
|
+
|
956 |
|
|
+ /**
|
957 |
|
|
+ * @brief Append a C string.
|
958 |
|
|
+ * @param s The C string to append.
|
959 |
|
|
+ * @return Reference to this string.
|
960 |
|
|
+ */
|
961 |
|
|
+ basic_string&
|
962 |
|
|
+ append(const _CharT* __s)
|
963 |
|
|
+ {
|
964 |
|
|
+ __glibcxx_requires_string(__s);
|
965 |
|
|
+ return this->append(__s, traits_type::length(__s));
|
966 |
|
|
+ }
|
967 |
|
|
+
|
968 |
|
|
+ /**
|
969 |
|
|
+ * @brief Append multiple characters.
|
970 |
|
|
+ * @param n The number of characters to append.
|
971 |
|
|
+ * @param c The character to use.
|
972 |
|
|
+ * @return Reference to this string.
|
973 |
|
|
+ *
|
974 |
|
|
+ * Appends n copies of c to this string.
|
975 |
|
|
+ */
|
976 |
|
|
+ basic_string&
|
977 |
|
|
+ append(size_type __n, _CharT __c);
|
978 |
|
|
+
|
979 |
|
|
+ /**
|
980 |
|
|
+ * @brief Append a range of characters.
|
981 |
|
|
+ * @param first Iterator referencing the first character to append.
|
982 |
|
|
+ * @param last Iterator marking the end of the range.
|
983 |
|
|
+ * @return Reference to this string.
|
984 |
|
|
+ *
|
985 |
|
|
+ * Appends characters in the range [first,last) to this string.
|
986 |
|
|
+ */
|
987 |
|
|
+ template<class _InputIterator>
|
988 |
|
|
+ basic_string&
|
989 |
|
|
+ append(_InputIterator __first, _InputIterator __last)
|
990 |
|
|
+ { return this->replace(_M_iend(), _M_iend(), __first, __last); }
|
991 |
|
|
+
|
992 |
|
|
+ /**
|
993 |
|
|
+ * @brief Append a single character.
|
994 |
|
|
+ * @param c Character to append.
|
995 |
|
|
+ */
|
996 |
|
|
+ void
|
997 |
|
|
+ push_back(_CharT __c)
|
998 |
|
|
+ {
|
999 |
|
|
+ const size_type __len = 1 + this->size();
|
1000 |
|
|
+ if (__len > this->capacity() || _M_rep()->_M_is_shared())
|
1001 |
|
|
+ this->reserve(__len);
|
1002 |
|
|
+ traits_type::assign(_M_data()[this->size()], __c);
|
1003 |
|
|
+ _M_rep()->_M_set_length_and_sharable(__len);
|
1004 |
|
|
+ }
|
1005 |
|
|
+
|
1006 |
|
|
+ /**
|
1007 |
|
|
+ * @brief Set value to contents of another string.
|
1008 |
|
|
+ * @param str Source string to use.
|
1009 |
|
|
+ * @return Reference to this string.
|
1010 |
|
|
+ */
|
1011 |
|
|
+ basic_string&
|
1012 |
|
|
+ assign(const basic_string& __str);
|
1013 |
|
|
+
|
1014 |
|
|
+ /**
|
1015 |
|
|
+ * @brief Set value to a substring of a string.
|
1016 |
|
|
+ * @param str The string to use.
|
1017 |
|
|
+ * @param pos Index of the first character of str.
|
1018 |
|
|
+ * @param n Number of characters to use.
|
1019 |
|
|
+ * @return Reference to this string.
|
1020 |
|
|
+ * @throw std::out_of_range if @a pos is not a valid index.
|
1021 |
|
|
+ *
|
1022 |
|
|
+ * This function sets this string to the substring of @a str consisting
|
1023 |
|
|
+ * of @a n characters at @a pos. If @a n is is larger than the number
|
1024 |
|
|
+ * of available characters in @a str, the remainder of @a str is used.
|
1025 |
|
|
+ */
|
1026 |
|
|
+ basic_string&
|
1027 |
|
|
+ assign(const basic_string& __str, size_type __pos, size_type __n)
|
1028 |
|
|
+ { return this->assign(__str._M_data()
|
1029 |
|
|
+ + __str._M_check(__pos, "basic_string::assign"),
|
1030 |
|
|
+ __str._M_limit(__pos, __n)); }
|
1031 |
|
|
+
|
1032 |
|
|
+ /**
|
1033 |
|
|
+ * @brief Set value to a C substring.
|
1034 |
|
|
+ * @param s The C string to use.
|
1035 |
|
|
+ * @param n Number of characters to use.
|
1036 |
|
|
+ * @return Reference to this string.
|
1037 |
|
|
+ *
|
1038 |
|
|
+ * This function sets the value of this string to the first @a n
|
1039 |
|
|
+ * characters of @a s. If @a n is is larger than the number of
|
1040 |
|
|
+ * available characters in @a s, the remainder of @a s is used.
|
1041 |
|
|
+ */
|
1042 |
|
|
+ basic_string&
|
1043 |
|
|
+ assign(const _CharT* __s, size_type __n);
|
1044 |
|
|
+
|
1045 |
|
|
+ /**
|
1046 |
|
|
+ * @brief Set value to contents of a C string.
|
1047 |
|
|
+ * @param s The C string to use.
|
1048 |
|
|
+ * @return Reference to this string.
|
1049 |
|
|
+ *
|
1050 |
|
|
+ * This function sets the value of this string to the value of @a s.
|
1051 |
|
|
+ * The data is copied, so there is no dependence on @a s once the
|
1052 |
|
|
+ * function returns.
|
1053 |
|
|
+ */
|
1054 |
|
|
+ basic_string&
|
1055 |
|
|
+ assign(const _CharT* __s)
|
1056 |
|
|
+ {
|
1057 |
|
|
+ __glibcxx_requires_string(__s);
|
1058 |
|
|
+ return this->assign(__s, traits_type::length(__s));
|
1059 |
|
|
+ }
|
1060 |
|
|
+
|
1061 |
|
|
+ /**
|
1062 |
|
|
+ * @brief Set value to multiple characters.
|
1063 |
|
|
+ * @param n Length of the resulting string.
|
1064 |
|
|
+ * @param c The character to use.
|
1065 |
|
|
+ * @return Reference to this string.
|
1066 |
|
|
+ *
|
1067 |
|
|
+ * This function sets the value of this string to @a n copies of
|
1068 |
|
|
+ * character @a c.
|
1069 |
|
|
+ */
|
1070 |
|
|
+ basic_string&
|
1071 |
|
|
+ assign(size_type __n, _CharT __c)
|
1072 |
|
|
+ { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
|
1073 |
|
|
+
|
1074 |
|
|
+ /**
|
1075 |
|
|
+ * @brief Set value to a range of characters.
|
1076 |
|
|
+ * @param first Iterator referencing the first character to append.
|
1077 |
|
|
+ * @param last Iterator marking the end of the range.
|
1078 |
|
|
+ * @return Reference to this string.
|
1079 |
|
|
+ *
|
1080 |
|
|
+ * Sets value of string to characters in the range [first,last).
|
1081 |
|
|
+ */
|
1082 |
|
|
+ template<class _InputIterator>
|
1083 |
|
|
+ basic_string&
|
1084 |
|
|
+ assign(_InputIterator __first, _InputIterator __last)
|
1085 |
|
|
+ { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
|
1086 |
|
|
+
|
1087 |
|
|
+ /**
|
1088 |
|
|
+ * @brief Insert multiple characters.
|
1089 |
|
|
+ * @param p Iterator referencing location in string to insert at.
|
1090 |
|
|
+ * @param n Number of characters to insert
|
1091 |
|
|
+ * @param c The character to insert.
|
1092 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1093 |
|
|
+ *
|
1094 |
|
|
+ * Inserts @a n copies of character @a c starting at the position
|
1095 |
|
|
+ * referenced by iterator @a p. If adding characters causes the length
|
1096 |
|
|
+ * to exceed max_size(), length_error is thrown. The value of the
|
1097 |
|
|
+ * string doesn't change if an error is thrown.
|
1098 |
|
|
+ */
|
1099 |
|
|
+ void
|
1100 |
|
|
+ insert(iterator __p, size_type __n, _CharT __c)
|
1101 |
|
|
+ { this->replace(__p, __p, __n, __c); }
|
1102 |
|
|
+
|
1103 |
|
|
+ /**
|
1104 |
|
|
+ * @brief Insert a range of characters.
|
1105 |
|
|
+ * @param p Iterator referencing location in string to insert at.
|
1106 |
|
|
+ * @param beg Start of range.
|
1107 |
|
|
+ * @param end End of range.
|
1108 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1109 |
|
|
+ *
|
1110 |
|
|
+ * Inserts characters in range [beg,end). If adding characters causes
|
1111 |
|
|
+ * the length to exceed max_size(), length_error is thrown. The value
|
1112 |
|
|
+ * of the string doesn't change if an error is thrown.
|
1113 |
|
|
+ */
|
1114 |
|
|
+ template<class _InputIterator>
|
1115 |
|
|
+ void
|
1116 |
|
|
+ insert(iterator __p, _InputIterator __beg, _InputIterator __end)
|
1117 |
|
|
+ { this->replace(__p, __p, __beg, __end); }
|
1118 |
|
|
+
|
1119 |
|
|
+ /**
|
1120 |
|
|
+ * @brief Insert value of a string.
|
1121 |
|
|
+ * @param pos1 Iterator referencing location in string to insert at.
|
1122 |
|
|
+ * @param str The string to insert.
|
1123 |
|
|
+ * @return Reference to this string.
|
1124 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1125 |
|
|
+ *
|
1126 |
|
|
+ * Inserts value of @a str starting at @a pos1. If adding characters
|
1127 |
|
|
+ * causes the length to exceed max_size(), length_error is thrown. The
|
1128 |
|
|
+ * value of the string doesn't change if an error is thrown.
|
1129 |
|
|
+ */
|
1130 |
|
|
+ basic_string&
|
1131 |
|
|
+ insert(size_type __pos1, const basic_string& __str)
|
1132 |
|
|
+ { return this->insert(__pos1, __str, size_type(0), __str.size()); }
|
1133 |
|
|
+
|
1134 |
|
|
+ /**
|
1135 |
|
|
+ * @brief Insert a substring.
|
1136 |
|
|
+ * @param pos1 Iterator referencing location in string to insert at.
|
1137 |
|
|
+ * @param str The string to insert.
|
1138 |
|
|
+ * @param pos2 Start of characters in str to insert.
|
1139 |
|
|
+ * @param n Number of characters to insert.
|
1140 |
|
|
+ * @return Reference to this string.
|
1141 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1142 |
|
|
+ * @throw std::out_of_range If @a pos1 > size() or
|
1143 |
|
|
+ * @a pos2 > @a str.size().
|
1144 |
|
|
+ *
|
1145 |
|
|
+ * Starting at @a pos1, insert @a n character of @a str beginning with
|
1146 |
|
|
+ * @a pos2. If adding characters causes the length to exceed
|
1147 |
|
|
+ * max_size(), length_error is thrown. If @a pos1 is beyond the end of
|
1148 |
|
|
+ * this string or @a pos2 is beyond the end of @a str, out_of_range is
|
1149 |
|
|
+ * thrown. The value of the string doesn't change if an error is
|
1150 |
|
|
+ * thrown.
|
1151 |
|
|
+ */
|
1152 |
|
|
+ basic_string&
|
1153 |
|
|
+ insert(size_type __pos1, const basic_string& __str,
|
1154 |
|
|
+ size_type __pos2, size_type __n)
|
1155 |
|
|
+ { return this->insert(__pos1, __str._M_data()
|
1156 |
|
|
+ + __str._M_check(__pos2, "basic_string::insert"),
|
1157 |
|
|
+ __str._M_limit(__pos2, __n)); }
|
1158 |
|
|
+
|
1159 |
|
|
+ /**
|
1160 |
|
|
+ * @brief Insert a C substring.
|
1161 |
|
|
+ * @param pos Iterator referencing location in string to insert at.
|
1162 |
|
|
+ * @param s The C string to insert.
|
1163 |
|
|
+ * @param n The number of characters to insert.
|
1164 |
|
|
+ * @return Reference to this string.
|
1165 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1166 |
|
|
+ * @throw std::out_of_range If @a pos is beyond the end of this
|
1167 |
|
|
+ * string.
|
1168 |
|
|
+ *
|
1169 |
|
|
+ * Inserts the first @a n characters of @a s starting at @a pos. If
|
1170 |
|
|
+ * adding characters causes the length to exceed max_size(),
|
1171 |
|
|
+ * length_error is thrown. If @a pos is beyond end(), out_of_range is
|
1172 |
|
|
+ * thrown. The value of the string doesn't change if an error is
|
1173 |
|
|
+ * thrown.
|
1174 |
|
|
+ */
|
1175 |
|
|
+ basic_string&
|
1176 |
|
|
+ insert(size_type __pos, const _CharT* __s, size_type __n);
|
1177 |
|
|
+
|
1178 |
|
|
+ /**
|
1179 |
|
|
+ * @brief Insert a C string.
|
1180 |
|
|
+ * @param pos Iterator referencing location in string to insert at.
|
1181 |
|
|
+ * @param s The C string to insert.
|
1182 |
|
|
+ * @return Reference to this string.
|
1183 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1184 |
|
|
+ * @throw std::out_of_range If @a pos is beyond the end of this
|
1185 |
|
|
+ * string.
|
1186 |
|
|
+ *
|
1187 |
|
|
+ * Inserts the first @a n characters of @a s starting at @a pos. If
|
1188 |
|
|
+ * adding characters causes the length to exceed max_size(),
|
1189 |
|
|
+ * length_error is thrown. If @a pos is beyond end(), out_of_range is
|
1190 |
|
|
+ * thrown. The value of the string doesn't change if an error is
|
1191 |
|
|
+ * thrown.
|
1192 |
|
|
+ */
|
1193 |
|
|
+ basic_string&
|
1194 |
|
|
+ insert(size_type __pos, const _CharT* __s)
|
1195 |
|
|
+ {
|
1196 |
|
|
+ __glibcxx_requires_string(__s);
|
1197 |
|
|
+ return this->insert(__pos, __s, traits_type::length(__s));
|
1198 |
|
|
+ }
|
1199 |
|
|
+
|
1200 |
|
|
+ /**
|
1201 |
|
|
+ * @brief Insert multiple characters.
|
1202 |
|
|
+ * @param pos Index in string to insert at.
|
1203 |
|
|
+ * @param n Number of characters to insert
|
1204 |
|
|
+ * @param c The character to insert.
|
1205 |
|
|
+ * @return Reference to this string.
|
1206 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1207 |
|
|
+ * @throw std::out_of_range If @a pos is beyond the end of this
|
1208 |
|
|
+ * string.
|
1209 |
|
|
+ *
|
1210 |
|
|
+ * Inserts @a n copies of character @a c starting at index @a pos. If
|
1211 |
|
|
+ * adding characters causes the length to exceed max_size(),
|
1212 |
|
|
+ * length_error is thrown. If @a pos > length(), out_of_range is
|
1213 |
|
|
+ * thrown. The value of the string doesn't change if an error is
|
1214 |
|
|
+ * thrown.
|
1215 |
|
|
+ */
|
1216 |
|
|
+ basic_string&
|
1217 |
|
|
+ insert(size_type __pos, size_type __n, _CharT __c)
|
1218 |
|
|
+ { return _M_replace_aux(_M_check(__pos, "basic_string::insert"),
|
1219 |
|
|
+ size_type(0), __n, __c); }
|
1220 |
|
|
+
|
1221 |
|
|
+ /**
|
1222 |
|
|
+ * @brief Insert one character.
|
1223 |
|
|
+ * @param p Iterator referencing position in string to insert at.
|
1224 |
|
|
+ * @param c The character to insert.
|
1225 |
|
|
+ * @return Iterator referencing newly inserted char.
|
1226 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1227 |
|
|
+ *
|
1228 |
|
|
+ * Inserts character @a c at position referenced by @a p. If adding
|
1229 |
|
|
+ * character causes the length to exceed max_size(), length_error is
|
1230 |
|
|
+ * thrown. If @a p is beyond end of string, out_of_range is thrown.
|
1231 |
|
|
+ * The value of the string doesn't change if an error is thrown.
|
1232 |
|
|
+ */
|
1233 |
|
|
+ iterator
|
1234 |
|
|
+ insert(iterator __p, _CharT __c)
|
1235 |
|
|
+ {
|
1236 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
|
1237 |
|
|
+ const size_type __pos = __p - _M_ibegin();
|
1238 |
|
|
+ _M_replace_aux(__pos, size_type(0), size_type(1), __c);
|
1239 |
|
|
+ _M_rep()->_M_set_leaked();
|
1240 |
|
|
+ return this->_M_ibegin() + __pos;
|
1241 |
|
|
+ }
|
1242 |
|
|
+
|
1243 |
|
|
+ /**
|
1244 |
|
|
+ * @brief Remove characters.
|
1245 |
|
|
+ * @param pos Index of first character to remove (default 0).
|
1246 |
|
|
+ * @param n Number of characters to remove (default remainder).
|
1247 |
|
|
+ * @return Reference to this string.
|
1248 |
|
|
+ * @throw std::out_of_range If @a pos is beyond the end of this
|
1249 |
|
|
+ * string.
|
1250 |
|
|
+ *
|
1251 |
|
|
+ * Removes @a n characters from this string starting at @a pos. The
|
1252 |
|
|
+ * length of the string is reduced by @a n. If there are < @a n
|
1253 |
|
|
+ * characters to remove, the remainder of the string is truncated. If
|
1254 |
|
|
+ * @a p is beyond end of string, out_of_range is thrown. The value of
|
1255 |
|
|
+ * the string doesn't change if an error is thrown.
|
1256 |
|
|
+ */
|
1257 |
|
|
+ basic_string&
|
1258 |
|
|
+ erase(size_type __pos = 0, size_type __n = npos)
|
1259 |
|
|
+ {
|
1260 |
|
|
+ _M_mutate(_M_check(__pos, "basic_string::erase"),
|
1261 |
|
|
+ _M_limit(__pos, __n), size_type(0));
|
1262 |
|
|
+ return *this;
|
1263 |
|
|
+ }
|
1264 |
|
|
+
|
1265 |
|
|
+ /**
|
1266 |
|
|
+ * @brief Remove one character.
|
1267 |
|
|
+ * @param position Iterator referencing the character to remove.
|
1268 |
|
|
+ * @return iterator referencing same location after removal.
|
1269 |
|
|
+ *
|
1270 |
|
|
+ * Removes the character at @a position from this string. The value
|
1271 |
|
|
+ * of the string doesn't change if an error is thrown.
|
1272 |
|
|
+ */
|
1273 |
|
|
+ iterator
|
1274 |
|
|
+ erase(iterator __position)
|
1275 |
|
|
+ {
|
1276 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
|
1277 |
|
|
+ && __position < _M_iend());
|
1278 |
|
|
+ const size_type __pos = __position - _M_ibegin();
|
1279 |
|
|
+ _M_mutate(__pos, size_type(1), size_type(0));
|
1280 |
|
|
+ _M_rep()->_M_set_leaked();
|
1281 |
|
|
+ return _M_ibegin() + __pos;
|
1282 |
|
|
+ }
|
1283 |
|
|
+
|
1284 |
|
|
+ /**
|
1285 |
|
|
+ * @brief Remove a range of characters.
|
1286 |
|
|
+ * @param first Iterator referencing the first character to remove.
|
1287 |
|
|
+ * @param last Iterator referencing the end of the range.
|
1288 |
|
|
+ * @return Iterator referencing location of first after removal.
|
1289 |
|
|
+ *
|
1290 |
|
|
+ * Removes the characters in the range [first,last) from this string.
|
1291 |
|
|
+ * The value of the string doesn't change if an error is thrown.
|
1292 |
|
|
+ */
|
1293 |
|
|
+ iterator
|
1294 |
|
|
+ erase(iterator __first, iterator __last)
|
1295 |
|
|
+ {
|
1296 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
|
1297 |
|
|
+ && __last <= _M_iend());
|
1298 |
|
|
+ const size_type __pos = __first - _M_ibegin();
|
1299 |
|
|
+ _M_mutate(__pos, __last - __first, size_type(0));
|
1300 |
|
|
+ _M_rep()->_M_set_leaked();
|
1301 |
|
|
+ return _M_ibegin() + __pos;
|
1302 |
|
|
+ }
|
1303 |
|
|
+
|
1304 |
|
|
+ /**
|
1305 |
|
|
+ * @brief Replace characters with value from another string.
|
1306 |
|
|
+ * @param pos Index of first character to replace.
|
1307 |
|
|
+ * @param n Number of characters to be replaced.
|
1308 |
|
|
+ * @param str String to insert.
|
1309 |
|
|
+ * @return Reference to this string.
|
1310 |
|
|
+ * @throw std::out_of_range If @a pos is beyond the end of this
|
1311 |
|
|
+ * string.
|
1312 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1313 |
|
|
+ *
|
1314 |
|
|
+ * Removes the characters in the range [pos,pos+n) from this string.
|
1315 |
|
|
+ * In place, the value of @a str is inserted. If @a pos is beyond end
|
1316 |
|
|
+ * of string, out_of_range is thrown. If the length of the result
|
1317 |
|
|
+ * exceeds max_size(), length_error is thrown. The value of the string
|
1318 |
|
|
+ * doesn't change if an error is thrown.
|
1319 |
|
|
+ */
|
1320 |
|
|
+ basic_string&
|
1321 |
|
|
+ replace(size_type __pos, size_type __n, const basic_string& __str)
|
1322 |
|
|
+ { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
|
1323 |
|
|
+
|
1324 |
|
|
+ /**
|
1325 |
|
|
+ * @brief Replace characters with value from another string.
|
1326 |
|
|
+ * @param pos1 Index of first character to replace.
|
1327 |
|
|
+ * @param n1 Number of characters to be replaced.
|
1328 |
|
|
+ * @param str String to insert.
|
1329 |
|
|
+ * @param pos2 Index of first character of str to use.
|
1330 |
|
|
+ * @param n2 Number of characters from str to use.
|
1331 |
|
|
+ * @return Reference to this string.
|
1332 |
|
|
+ * @throw std::out_of_range If @a pos1 > size() or @a pos2 >
|
1333 |
|
|
+ * str.size().
|
1334 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1335 |
|
|
+ *
|
1336 |
|
|
+ * Removes the characters in the range [pos1,pos1 + n) from this
|
1337 |
|
|
+ * string. In place, the value of @a str is inserted. If @a pos is
|
1338 |
|
|
+ * beyond end of string, out_of_range is thrown. If the length of the
|
1339 |
|
|
+ * result exceeds max_size(), length_error is thrown. The value of the
|
1340 |
|
|
+ * string doesn't change if an error is thrown.
|
1341 |
|
|
+ */
|
1342 |
|
|
+ basic_string&
|
1343 |
|
|
+ replace(size_type __pos1, size_type __n1, const basic_string& __str,
|
1344 |
|
|
+ size_type __pos2, size_type __n2)
|
1345 |
|
|
+ { return this->replace(__pos1, __n1, __str._M_data()
|
1346 |
|
|
+ + __str._M_check(__pos2, "basic_string::replace"),
|
1347 |
|
|
+ __str._M_limit(__pos2, __n2)); }
|
1348 |
|
|
+
|
1349 |
|
|
+ /**
|
1350 |
|
|
+ * @brief Replace characters with value of a C substring.
|
1351 |
|
|
+ * @param pos Index of first character to replace.
|
1352 |
|
|
+ * @param n1 Number of characters to be replaced.
|
1353 |
|
|
+ * @param str C string to insert.
|
1354 |
|
|
+ * @param n2 Number of characters from str to use.
|
1355 |
|
|
+ * @return Reference to this string.
|
1356 |
|
|
+ * @throw std::out_of_range If @a pos1 > size().
|
1357 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1358 |
|
|
+ *
|
1359 |
|
|
+ * Removes the characters in the range [pos,pos + n1) from this string.
|
1360 |
|
|
+ * In place, the first @a n2 characters of @a str are inserted, or all
|
1361 |
|
|
+ * of @a str if @a n2 is too large. If @a pos is beyond end of string,
|
1362 |
|
|
+ * out_of_range is thrown. If the length of result exceeds max_size(),
|
1363 |
|
|
+ * length_error is thrown. The value of the string doesn't change if
|
1364 |
|
|
+ * an error is thrown.
|
1365 |
|
|
+ */
|
1366 |
|
|
+ basic_string&
|
1367 |
|
|
+ replace(size_type __pos, size_type __n1, const _CharT* __s,
|
1368 |
|
|
+ size_type __n2);
|
1369 |
|
|
+
|
1370 |
|
|
+ /**
|
1371 |
|
|
+ * @brief Replace characters with value of a C string.
|
1372 |
|
|
+ * @param pos Index of first character to replace.
|
1373 |
|
|
+ * @param n1 Number of characters to be replaced.
|
1374 |
|
|
+ * @param str C string to insert.
|
1375 |
|
|
+ * @return Reference to this string.
|
1376 |
|
|
+ * @throw std::out_of_range If @a pos > size().
|
1377 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1378 |
|
|
+ *
|
1379 |
|
|
+ * Removes the characters in the range [pos,pos + n1) from this string.
|
1380 |
|
|
+ * In place, the first @a n characters of @a str are inserted. If @a
|
1381 |
|
|
+ * pos is beyond end of string, out_of_range is thrown. If the length
|
1382 |
|
|
+ * of result exceeds max_size(), length_error is thrown. The value of
|
1383 |
|
|
+ * the string doesn't change if an error is thrown.
|
1384 |
|
|
+ */
|
1385 |
|
|
+ basic_string&
|
1386 |
|
|
+ replace(size_type __pos, size_type __n1, const _CharT* __s)
|
1387 |
|
|
+ {
|
1388 |
|
|
+ __glibcxx_requires_string(__s);
|
1389 |
|
|
+ return this->replace(__pos, __n1, __s, traits_type::length(__s));
|
1390 |
|
|
+ }
|
1391 |
|
|
+
|
1392 |
|
|
+ /**
|
1393 |
|
|
+ * @brief Replace characters with multiple characters.
|
1394 |
|
|
+ * @param pos Index of first character to replace.
|
1395 |
|
|
+ * @param n1 Number of characters to be replaced.
|
1396 |
|
|
+ * @param n2 Number of characters to insert.
|
1397 |
|
|
+ * @param c Character to insert.
|
1398 |
|
|
+ * @return Reference to this string.
|
1399 |
|
|
+ * @throw std::out_of_range If @a pos > size().
|
1400 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1401 |
|
|
+ *
|
1402 |
|
|
+ * Removes the characters in the range [pos,pos + n1) from this string.
|
1403 |
|
|
+ * In place, @a n2 copies of @a c are inserted. If @a pos is beyond
|
1404 |
|
|
+ * end of string, out_of_range is thrown. If the length of result
|
1405 |
|
|
+ * exceeds max_size(), length_error is thrown. The value of the string
|
1406 |
|
|
+ * doesn't change if an error is thrown.
|
1407 |
|
|
+ */
|
1408 |
|
|
+ basic_string&
|
1409 |
|
|
+ replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
|
1410 |
|
|
+ { return _M_replace_aux(_M_check(__pos, "basic_string::replace"),
|
1411 |
|
|
+ _M_limit(__pos, __n1), __n2, __c); }
|
1412 |
|
|
+
|
1413 |
|
|
+ /**
|
1414 |
|
|
+ * @brief Replace range of characters with string.
|
1415 |
|
|
+ * @param i1 Iterator referencing start of range to replace.
|
1416 |
|
|
+ * @param i2 Iterator referencing end of range to replace.
|
1417 |
|
|
+ * @param str String value to insert.
|
1418 |
|
|
+ * @return Reference to this string.
|
1419 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1420 |
|
|
+ *
|
1421 |
|
|
+ * Removes the characters in the range [i1,i2). In place, the value of
|
1422 |
|
|
+ * @a str is inserted. If the length of result exceeds max_size(),
|
1423 |
|
|
+ * length_error is thrown. The value of the string doesn't change if
|
1424 |
|
|
+ * an error is thrown.
|
1425 |
|
|
+ */
|
1426 |
|
|
+ basic_string&
|
1427 |
|
|
+ replace(iterator __i1, iterator __i2, const basic_string& __str)
|
1428 |
|
|
+ { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
|
1429 |
|
|
+
|
1430 |
|
|
+ /**
|
1431 |
|
|
+ * @brief Replace range of characters with C substring.
|
1432 |
|
|
+ * @param i1 Iterator referencing start of range to replace.
|
1433 |
|
|
+ * @param i2 Iterator referencing end of range to replace.
|
1434 |
|
|
+ * @param s C string value to insert.
|
1435 |
|
|
+ * @param n Number of characters from s to insert.
|
1436 |
|
|
+ * @return Reference to this string.
|
1437 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1438 |
|
|
+ *
|
1439 |
|
|
+ * Removes the characters in the range [i1,i2). In place, the first @a
|
1440 |
|
|
+ * n characters of @a s are inserted. If the length of result exceeds
|
1441 |
|
|
+ * max_size(), length_error is thrown. The value of the string doesn't
|
1442 |
|
|
+ * change if an error is thrown.
|
1443 |
|
|
+ */
|
1444 |
|
|
+ basic_string&
|
1445 |
|
|
+ replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
|
1446 |
|
|
+ {
|
1447 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
1448 |
|
|
+ && __i2 <= _M_iend());
|
1449 |
|
|
+ return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
|
1450 |
|
|
+ }
|
1451 |
|
|
+
|
1452 |
|
|
+ /**
|
1453 |
|
|
+ * @brief Replace range of characters with C string.
|
1454 |
|
|
+ * @param i1 Iterator referencing start of range to replace.
|
1455 |
|
|
+ * @param i2 Iterator referencing end of range to replace.
|
1456 |
|
|
+ * @param s C string value to insert.
|
1457 |
|
|
+ * @return Reference to this string.
|
1458 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1459 |
|
|
+ *
|
1460 |
|
|
+ * Removes the characters in the range [i1,i2). In place, the
|
1461 |
|
|
+ * characters of @a s are inserted. If the length of result exceeds
|
1462 |
|
|
+ * max_size(), length_error is thrown. The value of the string doesn't
|
1463 |
|
|
+ * change if an error is thrown.
|
1464 |
|
|
+ */
|
1465 |
|
|
+ basic_string&
|
1466 |
|
|
+ replace(iterator __i1, iterator __i2, const _CharT* __s)
|
1467 |
|
|
+ {
|
1468 |
|
|
+ __glibcxx_requires_string(__s);
|
1469 |
|
|
+ return this->replace(__i1, __i2, __s, traits_type::length(__s));
|
1470 |
|
|
+ }
|
1471 |
|
|
+
|
1472 |
|
|
+ /**
|
1473 |
|
|
+ * @brief Replace range of characters with multiple characters
|
1474 |
|
|
+ * @param i1 Iterator referencing start of range to replace.
|
1475 |
|
|
+ * @param i2 Iterator referencing end of range to replace.
|
1476 |
|
|
+ * @param n Number of characters to insert.
|
1477 |
|
|
+ * @param c Character to insert.
|
1478 |
|
|
+ * @return Reference to this string.
|
1479 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1480 |
|
|
+ *
|
1481 |
|
|
+ * Removes the characters in the range [i1,i2). In place, @a n copies
|
1482 |
|
|
+ * of @a c are inserted. If the length of result exceeds max_size(),
|
1483 |
|
|
+ * length_error is thrown. The value of the string doesn't change if
|
1484 |
|
|
+ * an error is thrown.
|
1485 |
|
|
+ */
|
1486 |
|
|
+ basic_string&
|
1487 |
|
|
+ replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
|
1488 |
|
|
+ {
|
1489 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
1490 |
|
|
+ && __i2 <= _M_iend());
|
1491 |
|
|
+ return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
|
1492 |
|
|
+ }
|
1493 |
|
|
+
|
1494 |
|
|
+ /**
|
1495 |
|
|
+ * @brief Replace range of characters with range.
|
1496 |
|
|
+ * @param i1 Iterator referencing start of range to replace.
|
1497 |
|
|
+ * @param i2 Iterator referencing end of range to replace.
|
1498 |
|
|
+ * @param k1 Iterator referencing start of range to insert.
|
1499 |
|
|
+ * @param k2 Iterator referencing end of range to insert.
|
1500 |
|
|
+ * @return Reference to this string.
|
1501 |
|
|
+ * @throw std::length_error If new length exceeds @c max_size().
|
1502 |
|
|
+ *
|
1503 |
|
|
+ * Removes the characters in the range [i1,i2). In place, characters
|
1504 |
|
|
+ * in the range [k1,k2) are inserted. If the length of result exceeds
|
1505 |
|
|
+ * max_size(), length_error is thrown. The value of the string doesn't
|
1506 |
|
|
+ * change if an error is thrown.
|
1507 |
|
|
+ */
|
1508 |
|
|
+ template<class _InputIterator>
|
1509 |
|
|
+ basic_string&
|
1510 |
|
|
+ replace(iterator __i1, iterator __i2,
|
1511 |
|
|
+ _InputIterator __k1, _InputIterator __k2)
|
1512 |
|
|
+ {
|
1513 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
1514 |
|
|
+ && __i2 <= _M_iend());
|
1515 |
|
|
+ __glibcxx_requires_valid_range(__k1, __k2);
|
1516 |
|
|
+ typedef typename std::__is_integer<_InputIterator>::__type _Integral;
|
1517 |
|
|
+ return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
|
1518 |
|
|
+ }
|
1519 |
|
|
+
|
1520 |
|
|
+ // Specializations for the common case of pointer and iterator:
|
1521 |
|
|
+ // useful to avoid the overhead of temporary buffering in _M_replace.
|
1522 |
|
|
+ basic_string&
|
1523 |
|
|
+ replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
|
1524 |
|
|
+ {
|
1525 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
1526 |
|
|
+ && __i2 <= _M_iend());
|
1527 |
|
|
+ __glibcxx_requires_valid_range(__k1, __k2);
|
1528 |
|
|
+ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
|
1529 |
|
|
+ __k1, __k2 - __k1);
|
1530 |
|
|
+ }
|
1531 |
|
|
+
|
1532 |
|
|
+ basic_string&
|
1533 |
|
|
+ replace(iterator __i1, iterator __i2,
|
1534 |
|
|
+ const _CharT* __k1, const _CharT* __k2)
|
1535 |
|
|
+ {
|
1536 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
1537 |
|
|
+ && __i2 <= _M_iend());
|
1538 |
|
|
+ __glibcxx_requires_valid_range(__k1, __k2);
|
1539 |
|
|
+ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
|
1540 |
|
|
+ __k1, __k2 - __k1);
|
1541 |
|
|
+ }
|
1542 |
|
|
+
|
1543 |
|
|
+ basic_string&
|
1544 |
|
|
+ replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
|
1545 |
|
|
+ {
|
1546 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
1547 |
|
|
+ && __i2 <= _M_iend());
|
1548 |
|
|
+ __glibcxx_requires_valid_range(__k1, __k2);
|
1549 |
|
|
+ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
|
1550 |
|
|
+ __k1.base(), __k2 - __k1);
|
1551 |
|
|
+ }
|
1552 |
|
|
+
|
1553 |
|
|
+ basic_string&
|
1554 |
|
|
+ replace(iterator __i1, iterator __i2,
|
1555 |
|
|
+ const_iterator __k1, const_iterator __k2)
|
1556 |
|
|
+ {
|
1557 |
|
|
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
1558 |
|
|
+ && __i2 <= _M_iend());
|
1559 |
|
|
+ __glibcxx_requires_valid_range(__k1, __k2);
|
1560 |
|
|
+ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
|
1561 |
|
|
+ __k1.base(), __k2 - __k1);
|
1562 |
|
|
+ }
|
1563 |
|
|
+
|
1564 |
|
|
+ private:
|
1565 |
|
|
+ template<class _Integer>
|
1566 |
|
|
+ basic_string&
|
1567 |
|
|
+ _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
|
1568 |
|
|
+ _Integer __val, __true_type)
|
1569 |
|
|
+ { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
|
1570 |
|
|
+
|
1571 |
|
|
+ template<class _InputIterator>
|
1572 |
|
|
+ basic_string&
|
1573 |
|
|
+ _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
|
1574 |
|
|
+ _InputIterator __k2, __false_type);
|
1575 |
|
|
+
|
1576 |
|
|
+ basic_string&
|
1577 |
|
|
+ _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
|
1578 |
|
|
+ _CharT __c);
|
1579 |
|
|
+
|
1580 |
|
|
+ basic_string&
|
1581 |
|
|
+ _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
|
1582 |
|
|
+ size_type __n2);
|
1583 |
|
|
+
|
1584 |
|
|
+ // _S_construct_aux is used to implement the 21.3.1 para 15 which
|
1585 |
|
|
+ // requires special behaviour if _InIter is an integral type
|
1586 |
|
|
+ template<class _InIterator>
|
1587 |
|
|
+ static _CharT*
|
1588 |
|
|
+ _S_construct_aux(_InIterator __beg, _InIterator __end,
|
1589 |
|
|
+ const _Alloc& __a, __false_type)
|
1590 |
|
|
+ {
|
1591 |
|
|
+ typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
|
1592 |
|
|
+ return _S_construct(__beg, __end, __a, _Tag());
|
1593 |
|
|
+ }
|
1594 |
|
|
+
|
1595 |
|
|
+ template<class _InIterator>
|
1596 |
|
|
+ static _CharT*
|
1597 |
|
|
+ _S_construct_aux(_InIterator __beg, _InIterator __end,
|
1598 |
|
|
+ const _Alloc& __a, __true_type)
|
1599 |
|
|
+ { return _S_construct(static_cast<size_type>(__beg),
|
1600 |
|
|
+ static_cast<value_type>(__end), __a); }
|
1601 |
|
|
+
|
1602 |
|
|
+ template<class _InIterator>
|
1603 |
|
|
+ static _CharT*
|
1604 |
|
|
+ _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
|
1605 |
|
|
+ {
|
1606 |
|
|
+ typedef typename std::__is_integer<_InIterator>::__type _Integral;
|
1607 |
|
|
+ return _S_construct_aux(__beg, __end, __a, _Integral());
|
1608 |
|
|
+ }
|
1609 |
|
|
+
|
1610 |
|
|
+ // For Input Iterators, used in istreambuf_iterators, etc.
|
1611 |
|
|
+ template<class _InIterator>
|
1612 |
|
|
+ static _CharT*
|
1613 |
|
|
+ _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
|
1614 |
|
|
+ input_iterator_tag);
|
1615 |
|
|
+
|
1616 |
|
|
+ // For forward_iterators up to random_access_iterators, used for
|
1617 |
|
|
+ // string::iterator, _CharT*, etc.
|
1618 |
|
|
+ template<class _FwdIterator>
|
1619 |
|
|
+ static _CharT*
|
1620 |
|
|
+ _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
|
1621 |
|
|
+ forward_iterator_tag);
|
1622 |
|
|
+
|
1623 |
|
|
+ static _CharT*
|
1624 |
|
|
+ _S_construct(size_type __req, _CharT __c, const _Alloc& __a);
|
1625 |
|
|
+
|
1626 |
|
|
+ public:
|
1627 |
|
|
+
|
1628 |
|
|
+ /**
|
1629 |
|
|
+ * @brief Copy substring into C string.
|
1630 |
|
|
+ * @param s C string to copy value into.
|
1631 |
|
|
+ * @param n Number of characters to copy.
|
1632 |
|
|
+ * @param pos Index of first character to copy.
|
1633 |
|
|
+ * @return Number of characters actually copied
|
1634 |
|
|
+ * @throw std::out_of_range If pos > size().
|
1635 |
|
|
+ *
|
1636 |
|
|
+ * Copies up to @a n characters starting at @a pos into the C string @a
|
1637 |
|
|
+ * s. If @a pos is greater than size(), out_of_range is thrown.
|
1638 |
|
|
+ */
|
1639 |
|
|
+ size_type
|
1640 |
|
|
+ copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
|
1641 |
|
|
+
|
1642 |
|
|
+ /**
|
1643 |
|
|
+ * @brief Swap contents with another string.
|
1644 |
|
|
+ * @param s String to swap with.
|
1645 |
|
|
+ *
|
1646 |
|
|
+ * Exchanges the contents of this string with that of @a s in constant
|
1647 |
|
|
+ * time.
|
1648 |
|
|
+ */
|
1649 |
|
|
+ void
|
1650 |
|
|
+ swap(basic_string& __s);
|
1651 |
|
|
+
|
1652 |
|
|
+ // String operations:
|
1653 |
|
|
+ /**
|
1654 |
|
|
+ * @brief Return const pointer to null-terminated contents.
|
1655 |
|
|
+ *
|
1656 |
|
|
+ * This is a handle to internal data. Do not modify or dire things may
|
1657 |
|
|
+ * happen.
|
1658 |
|
|
+ */
|
1659 |
|
|
+ const _CharT*
|
1660 |
|
|
+ c_str() const
|
1661 |
|
|
+ { return _M_data(); }
|
1662 |
|
|
+
|
1663 |
|
|
+ /**
|
1664 |
|
|
+ * @brief Return const pointer to contents.
|
1665 |
|
|
+ *
|
1666 |
|
|
+ * This is a handle to internal data. Do not modify or dire things may
|
1667 |
|
|
+ * happen.
|
1668 |
|
|
+ */
|
1669 |
|
|
+ const _CharT*
|
1670 |
|
|
+ data() const
|
1671 |
|
|
+ { return _M_data(); }
|
1672 |
|
|
+
|
1673 |
|
|
+ /**
|
1674 |
|
|
+ * @brief Return copy of allocator used to construct this string.
|
1675 |
|
|
+ */
|
1676 |
|
|
+ allocator_type
|
1677 |
|
|
+ get_allocator() const
|
1678 |
|
|
+ { return _M_dataplus; }
|
1679 |
|
|
+
|
1680 |
|
|
+ /**
|
1681 |
|
|
+ * @brief Find position of a C substring.
|
1682 |
|
|
+ * @param s C string to locate.
|
1683 |
|
|
+ * @param pos Index of character to search from.
|
1684 |
|
|
+ * @param n Number of characters from @a s to search for.
|
1685 |
|
|
+ * @return Index of start of first occurrence.
|
1686 |
|
|
+ *
|
1687 |
|
|
+ * Starting from @a pos, searches forward for the first @a n characters
|
1688 |
|
|
+ * in @a s within this string. If found, returns the index where it
|
1689 |
|
|
+ * begins. If not found, returns npos.
|
1690 |
|
|
+ */
|
1691 |
|
|
+ size_type
|
1692 |
|
|
+ find(const _CharT* __s, size_type __pos, size_type __n) const;
|
1693 |
|
|
+
|
1694 |
|
|
+ /**
|
1695 |
|
|
+ * @brief Find position of a string.
|
1696 |
|
|
+ * @param str String to locate.
|
1697 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1698 |
|
|
+ * @return Index of start of first occurrence.
|
1699 |
|
|
+ *
|
1700 |
|
|
+ * Starting from @a pos, searches forward for value of @a str within
|
1701 |
|
|
+ * this string. If found, returns the index where it begins. If not
|
1702 |
|
|
+ * found, returns npos.
|
1703 |
|
|
+ */
|
1704 |
|
|
+ size_type
|
1705 |
|
|
+ find(const basic_string& __str, size_type __pos = 0) const
|
1706 |
|
|
+ { return this->find(__str.data(), __pos, __str.size()); }
|
1707 |
|
|
+
|
1708 |
|
|
+ /**
|
1709 |
|
|
+ * @brief Find position of a C string.
|
1710 |
|
|
+ * @param s C string to locate.
|
1711 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1712 |
|
|
+ * @return Index of start of first occurrence.
|
1713 |
|
|
+ *
|
1714 |
|
|
+ * Starting from @a pos, searches forward for the value of @a s within
|
1715 |
|
|
+ * this string. If found, returns the index where it begins. If not
|
1716 |
|
|
+ * found, returns npos.
|
1717 |
|
|
+ */
|
1718 |
|
|
+ size_type
|
1719 |
|
|
+ find(const _CharT* __s, size_type __pos = 0) const
|
1720 |
|
|
+ {
|
1721 |
|
|
+ __glibcxx_requires_string(__s);
|
1722 |
|
|
+ return this->find(__s, __pos, traits_type::length(__s));
|
1723 |
|
|
+ }
|
1724 |
|
|
+
|
1725 |
|
|
+ /**
|
1726 |
|
|
+ * @brief Find position of a character.
|
1727 |
|
|
+ * @param c Character to locate.
|
1728 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1729 |
|
|
+ * @return Index of first occurrence.
|
1730 |
|
|
+ *
|
1731 |
|
|
+ * Starting from @a pos, searches forward for @a c within this string.
|
1732 |
|
|
+ * If found, returns the index where it was found. If not found,
|
1733 |
|
|
+ * returns npos.
|
1734 |
|
|
+ */
|
1735 |
|
|
+ size_type
|
1736 |
|
|
+ find(_CharT __c, size_type __pos = 0) const;
|
1737 |
|
|
+
|
1738 |
|
|
+ /**
|
1739 |
|
|
+ * @brief Find last position of a string.
|
1740 |
|
|
+ * @param str String to locate.
|
1741 |
|
|
+ * @param pos Index of character to search back from (default end).
|
1742 |
|
|
+ * @return Index of start of last occurrence.
|
1743 |
|
|
+ *
|
1744 |
|
|
+ * Starting from @a pos, searches backward for value of @a str within
|
1745 |
|
|
+ * this string. If found, returns the index where it begins. If not
|
1746 |
|
|
+ * found, returns npos.
|
1747 |
|
|
+ */
|
1748 |
|
|
+ size_type
|
1749 |
|
|
+ rfind(const basic_string& __str, size_type __pos = npos) const
|
1750 |
|
|
+ { return this->rfind(__str.data(), __pos, __str.size()); }
|
1751 |
|
|
+
|
1752 |
|
|
+ /**
|
1753 |
|
|
+ * @brief Find last position of a C substring.
|
1754 |
|
|
+ * @param s C string to locate.
|
1755 |
|
|
+ * @param pos Index of character to search back from.
|
1756 |
|
|
+ * @param n Number of characters from s to search for.
|
1757 |
|
|
+ * @return Index of start of last occurrence.
|
1758 |
|
|
+ *
|
1759 |
|
|
+ * Starting from @a pos, searches backward for the first @a n
|
1760 |
|
|
+ * characters in @a s within this string. If found, returns the index
|
1761 |
|
|
+ * where it begins. If not found, returns npos.
|
1762 |
|
|
+ */
|
1763 |
|
|
+ size_type
|
1764 |
|
|
+ rfind(const _CharT* __s, size_type __pos, size_type __n) const;
|
1765 |
|
|
+
|
1766 |
|
|
+ /**
|
1767 |
|
|
+ * @brief Find last position of a C string.
|
1768 |
|
|
+ * @param s C string to locate.
|
1769 |
|
|
+ * @param pos Index of character to start search at (default 0).
|
1770 |
|
|
+ * @return Index of start of last occurrence.
|
1771 |
|
|
+ *
|
1772 |
|
|
+ * Starting from @a pos, searches backward for the value of @a s within
|
1773 |
|
|
+ * this string. If found, returns the index where it begins. If not
|
1774 |
|
|
+ * found, returns npos.
|
1775 |
|
|
+ */
|
1776 |
|
|
+ size_type
|
1777 |
|
|
+ rfind(const _CharT* __s, size_type __pos = npos) const
|
1778 |
|
|
+ {
|
1779 |
|
|
+ __glibcxx_requires_string(__s);
|
1780 |
|
|
+ return this->rfind(__s, __pos, traits_type::length(__s));
|
1781 |
|
|
+ }
|
1782 |
|
|
+
|
1783 |
|
|
+ /**
|
1784 |
|
|
+ * @brief Find last position of a character.
|
1785 |
|
|
+ * @param c Character to locate.
|
1786 |
|
|
+ * @param pos Index of character to search back from (default 0).
|
1787 |
|
|
+ * @return Index of last occurrence.
|
1788 |
|
|
+ *
|
1789 |
|
|
+ * Starting from @a pos, searches backward for @a c within this string.
|
1790 |
|
|
+ * If found, returns the index where it was found. If not found,
|
1791 |
|
|
+ * returns npos.
|
1792 |
|
|
+ */
|
1793 |
|
|
+ size_type
|
1794 |
|
|
+ rfind(_CharT __c, size_type __pos = npos) const;
|
1795 |
|
|
+
|
1796 |
|
|
+ /**
|
1797 |
|
|
+ * @brief Find position of a character of string.
|
1798 |
|
|
+ * @param str String containing characters to locate.
|
1799 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1800 |
|
|
+ * @return Index of first occurrence.
|
1801 |
|
|
+ *
|
1802 |
|
|
+ * Starting from @a pos, searches forward for one of the characters of
|
1803 |
|
|
+ * @a str within this string. If found, returns the index where it was
|
1804 |
|
|
+ * found. If not found, returns npos.
|
1805 |
|
|
+ */
|
1806 |
|
|
+ size_type
|
1807 |
|
|
+ find_first_of(const basic_string& __str, size_type __pos = 0) const
|
1808 |
|
|
+ { return this->find_first_of(__str.data(), __pos, __str.size()); }
|
1809 |
|
|
+
|
1810 |
|
|
+ /**
|
1811 |
|
|
+ * @brief Find position of a character of C substring.
|
1812 |
|
|
+ * @param s String containing characters to locate.
|
1813 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1814 |
|
|
+ * @param n Number of characters from s to search for.
|
1815 |
|
|
+ * @return Index of first occurrence.
|
1816 |
|
|
+ *
|
1817 |
|
|
+ * Starting from @a pos, searches forward for one of the first @a n
|
1818 |
|
|
+ * characters of @a s within this string. If found, returns the index
|
1819 |
|
|
+ * where it was found. If not found, returns npos.
|
1820 |
|
|
+ */
|
1821 |
|
|
+ size_type
|
1822 |
|
|
+ find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
|
1823 |
|
|
+
|
1824 |
|
|
+ /**
|
1825 |
|
|
+ * @brief Find position of a character of C string.
|
1826 |
|
|
+ * @param s String containing characters to locate.
|
1827 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1828 |
|
|
+ * @return Index of first occurrence.
|
1829 |
|
|
+ *
|
1830 |
|
|
+ * Starting from @a pos, searches forward for one of the characters of
|
1831 |
|
|
+ * @a s within this string. If found, returns the index where it was
|
1832 |
|
|
+ * found. If not found, returns npos.
|
1833 |
|
|
+ */
|
1834 |
|
|
+ size_type
|
1835 |
|
|
+ find_first_of(const _CharT* __s, size_type __pos = 0) const
|
1836 |
|
|
+ {
|
1837 |
|
|
+ __glibcxx_requires_string(__s);
|
1838 |
|
|
+ return this->find_first_of(__s, __pos, traits_type::length(__s));
|
1839 |
|
|
+ }
|
1840 |
|
|
+
|
1841 |
|
|
+ /**
|
1842 |
|
|
+ * @brief Find position of a character.
|
1843 |
|
|
+ * @param c Character to locate.
|
1844 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1845 |
|
|
+ * @return Index of first occurrence.
|
1846 |
|
|
+ *
|
1847 |
|
|
+ * Starting from @a pos, searches forward for the character @a c within
|
1848 |
|
|
+ * this string. If found, returns the index where it was found. If
|
1849 |
|
|
+ * not found, returns npos.
|
1850 |
|
|
+ *
|
1851 |
|
|
+ * Note: equivalent to find(c, pos).
|
1852 |
|
|
+ */
|
1853 |
|
|
+ size_type
|
1854 |
|
|
+ find_first_of(_CharT __c, size_type __pos = 0) const
|
1855 |
|
|
+ { return this->find(__c, __pos); }
|
1856 |
|
|
+
|
1857 |
|
|
+ /**
|
1858 |
|
|
+ * @brief Find last position of a character of string.
|
1859 |
|
|
+ * @param str String containing characters to locate.
|
1860 |
|
|
+ * @param pos Index of character to search back from (default end).
|
1861 |
|
|
+ * @return Index of last occurrence.
|
1862 |
|
|
+ *
|
1863 |
|
|
+ * Starting from @a pos, searches backward for one of the characters of
|
1864 |
|
|
+ * @a str within this string. If found, returns the index where it was
|
1865 |
|
|
+ * found. If not found, returns npos.
|
1866 |
|
|
+ */
|
1867 |
|
|
+ size_type
|
1868 |
|
|
+ find_last_of(const basic_string& __str, size_type __pos = npos) const
|
1869 |
|
|
+ { return this->find_last_of(__str.data(), __pos, __str.size()); }
|
1870 |
|
|
+
|
1871 |
|
|
+ /**
|
1872 |
|
|
+ * @brief Find last position of a character of C substring.
|
1873 |
|
|
+ * @param s C string containing characters to locate.
|
1874 |
|
|
+ * @param pos Index of character to search back from (default end).
|
1875 |
|
|
+ * @param n Number of characters from s to search for.
|
1876 |
|
|
+ * @return Index of last occurrence.
|
1877 |
|
|
+ *
|
1878 |
|
|
+ * Starting from @a pos, searches backward for one of the first @a n
|
1879 |
|
|
+ * characters of @a s within this string. If found, returns the index
|
1880 |
|
|
+ * where it was found. If not found, returns npos.
|
1881 |
|
|
+ */
|
1882 |
|
|
+ size_type
|
1883 |
|
|
+ find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
|
1884 |
|
|
+
|
1885 |
|
|
+ /**
|
1886 |
|
|
+ * @brief Find last position of a character of C string.
|
1887 |
|
|
+ * @param s C string containing characters to locate.
|
1888 |
|
|
+ * @param pos Index of character to search back from (default end).
|
1889 |
|
|
+ * @return Index of last occurrence.
|
1890 |
|
|
+ *
|
1891 |
|
|
+ * Starting from @a pos, searches backward for one of the characters of
|
1892 |
|
|
+ * @a s within this string. If found, returns the index where it was
|
1893 |
|
|
+ * found. If not found, returns npos.
|
1894 |
|
|
+ */
|
1895 |
|
|
+ size_type
|
1896 |
|
|
+ find_last_of(const _CharT* __s, size_type __pos = npos) const
|
1897 |
|
|
+ {
|
1898 |
|
|
+ __glibcxx_requires_string(__s);
|
1899 |
|
|
+ return this->find_last_of(__s, __pos, traits_type::length(__s));
|
1900 |
|
|
+ }
|
1901 |
|
|
+
|
1902 |
|
|
+ /**
|
1903 |
|
|
+ * @brief Find last position of a character.
|
1904 |
|
|
+ * @param c Character to locate.
|
1905 |
|
|
+ * @param pos Index of character to search back from (default 0).
|
1906 |
|
|
+ * @return Index of last occurrence.
|
1907 |
|
|
+ *
|
1908 |
|
|
+ * Starting from @a pos, searches backward for @a c within this string.
|
1909 |
|
|
+ * If found, returns the index where it was found. If not found,
|
1910 |
|
|
+ * returns npos.
|
1911 |
|
|
+ *
|
1912 |
|
|
+ * Note: equivalent to rfind(c, pos).
|
1913 |
|
|
+ */
|
1914 |
|
|
+ size_type
|
1915 |
|
|
+ find_last_of(_CharT __c, size_type __pos = npos) const
|
1916 |
|
|
+ { return this->rfind(__c, __pos); }
|
1917 |
|
|
+
|
1918 |
|
|
+ /**
|
1919 |
|
|
+ * @brief Find position of a character not in string.
|
1920 |
|
|
+ * @param str String containing characters to avoid.
|
1921 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1922 |
|
|
+ * @return Index of first occurrence.
|
1923 |
|
|
+ *
|
1924 |
|
|
+ * Starting from @a pos, searches forward for a character not contained
|
1925 |
|
|
+ * in @a str within this string. If found, returns the index where it
|
1926 |
|
|
+ * was found. If not found, returns npos.
|
1927 |
|
|
+ */
|
1928 |
|
|
+ size_type
|
1929 |
|
|
+ find_first_not_of(const basic_string& __str, size_type __pos = 0) const
|
1930 |
|
|
+ { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
|
1931 |
|
|
+
|
1932 |
|
|
+ /**
|
1933 |
|
|
+ * @brief Find position of a character not in C substring.
|
1934 |
|
|
+ * @param s C string containing characters to avoid.
|
1935 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1936 |
|
|
+ * @param n Number of characters from s to consider.
|
1937 |
|
|
+ * @return Index of first occurrence.
|
1938 |
|
|
+ *
|
1939 |
|
|
+ * Starting from @a pos, searches forward for a character not contained
|
1940 |
|
|
+ * in the first @a n characters of @a s within this string. If found,
|
1941 |
|
|
+ * returns the index where it was found. If not found, returns npos.
|
1942 |
|
|
+ */
|
1943 |
|
|
+ size_type
|
1944 |
|
|
+ find_first_not_of(const _CharT* __s, size_type __pos,
|
1945 |
|
|
+ size_type __n) const;
|
1946 |
|
|
+
|
1947 |
|
|
+ /**
|
1948 |
|
|
+ * @brief Find position of a character not in C string.
|
1949 |
|
|
+ * @param s C string containing characters to avoid.
|
1950 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1951 |
|
|
+ * @return Index of first occurrence.
|
1952 |
|
|
+ *
|
1953 |
|
|
+ * Starting from @a pos, searches forward for a character not contained
|
1954 |
|
|
+ * in @a s within this string. If found, returns the index where it
|
1955 |
|
|
+ * was found. If not found, returns npos.
|
1956 |
|
|
+ */
|
1957 |
|
|
+ size_type
|
1958 |
|
|
+ find_first_not_of(const _CharT* __s, size_type __pos = 0) const
|
1959 |
|
|
+ {
|
1960 |
|
|
+ __glibcxx_requires_string(__s);
|
1961 |
|
|
+ return this->find_first_not_of(__s, __pos, traits_type::length(__s));
|
1962 |
|
|
+ }
|
1963 |
|
|
+
|
1964 |
|
|
+ /**
|
1965 |
|
|
+ * @brief Find position of a different character.
|
1966 |
|
|
+ * @param c Character to avoid.
|
1967 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1968 |
|
|
+ * @return Index of first occurrence.
|
1969 |
|
|
+ *
|
1970 |
|
|
+ * Starting from @a pos, searches forward for a character other than @a c
|
1971 |
|
|
+ * within this string. If found, returns the index where it was found.
|
1972 |
|
|
+ * If not found, returns npos.
|
1973 |
|
|
+ */
|
1974 |
|
|
+ size_type
|
1975 |
|
|
+ find_first_not_of(_CharT __c, size_type __pos = 0) const;
|
1976 |
|
|
+
|
1977 |
|
|
+ /**
|
1978 |
|
|
+ * @brief Find last position of a character not in string.
|
1979 |
|
|
+ * @param str String containing characters to avoid.
|
1980 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1981 |
|
|
+ * @return Index of first occurrence.
|
1982 |
|
|
+ *
|
1983 |
|
|
+ * Starting from @a pos, searches backward for a character not
|
1984 |
|
|
+ * contained in @a str within this string. If found, returns the index
|
1985 |
|
|
+ * where it was found. If not found, returns npos.
|
1986 |
|
|
+ */
|
1987 |
|
|
+ size_type
|
1988 |
|
|
+ find_last_not_of(const basic_string& __str, size_type __pos = npos) const
|
1989 |
|
|
+ { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
|
1990 |
|
|
+
|
1991 |
|
|
+ /**
|
1992 |
|
|
+ * @brief Find last position of a character not in C substring.
|
1993 |
|
|
+ * @param s C string containing characters to avoid.
|
1994 |
|
|
+ * @param pos Index of character to search from (default 0).
|
1995 |
|
|
+ * @param n Number of characters from s to consider.
|
1996 |
|
|
+ * @return Index of first occurrence.
|
1997 |
|
|
+ *
|
1998 |
|
|
+ * Starting from @a pos, searches backward for a character not
|
1999 |
|
|
+ * contained in the first @a n characters of @a s within this string.
|
2000 |
|
|
+ * If found, returns the index where it was found. If not found,
|
2001 |
|
|
+ * returns npos.
|
2002 |
|
|
+ */
|
2003 |
|
|
+ size_type
|
2004 |
|
|
+ find_last_not_of(const _CharT* __s, size_type __pos,
|
2005 |
|
|
+ size_type __n) const;
|
2006 |
|
|
+ /**
|
2007 |
|
|
+ * @brief Find position of a character not in C string.
|
2008 |
|
|
+ * @param s C string containing characters to avoid.
|
2009 |
|
|
+ * @param pos Index of character to search from (default 0).
|
2010 |
|
|
+ * @return Index of first occurrence.
|
2011 |
|
|
+ *
|
2012 |
|
|
+ * Starting from @a pos, searches backward for a character not
|
2013 |
|
|
+ * contained in @a s within this string. If found, returns the index
|
2014 |
|
|
+ * where it was found. If not found, returns npos.
|
2015 |
|
|
+ */
|
2016 |
|
|
+ size_type
|
2017 |
|
|
+ find_last_not_of(const _CharT* __s, size_type __pos = npos) const
|
2018 |
|
|
+ {
|
2019 |
|
|
+ __glibcxx_requires_string(__s);
|
2020 |
|
|
+ return this->find_last_not_of(__s, __pos, traits_type::length(__s));
|
2021 |
|
|
+ }
|
2022 |
|
|
+
|
2023 |
|
|
+ /**
|
2024 |
|
|
+ * @brief Find last position of a different character.
|
2025 |
|
|
+ * @param c Character to avoid.
|
2026 |
|
|
+ * @param pos Index of character to search from (default 0).
|
2027 |
|
|
+ * @return Index of first occurrence.
|
2028 |
|
|
+ *
|
2029 |
|
|
+ * Starting from @a pos, searches backward for a character other than
|
2030 |
|
|
+ * @a c within this string. If found, returns the index where it was
|
2031 |
|
|
+ * found. If not found, returns npos.
|
2032 |
|
|
+ */
|
2033 |
|
|
+ size_type
|
2034 |
|
|
+ find_last_not_of(_CharT __c, size_type __pos = npos) const;
|
2035 |
|
|
+
|
2036 |
|
|
+ /**
|
2037 |
|
|
+ * @brief Get a substring.
|
2038 |
|
|
+ * @param pos Index of first character (default 0).
|
2039 |
|
|
+ * @param n Number of characters in substring (default remainder).
|
2040 |
|
|
+ * @return The new string.
|
2041 |
|
|
+ * @throw std::out_of_range If pos > size().
|
2042 |
|
|
+ *
|
2043 |
|
|
+ * Construct and return a new string using the @a n characters starting
|
2044 |
|
|
+ * at @a pos. If the string is too short, use the remainder of the
|
2045 |
|
|
+ * characters. If @a pos is beyond the end of the string, out_of_range
|
2046 |
|
|
+ * is thrown.
|
2047 |
|
|
+ */
|
2048 |
|
|
+ basic_string
|
2049 |
|
|
+ substr(size_type __pos = 0, size_type __n = npos) const
|
2050 |
|
|
+ { return basic_string(*this,
|
2051 |
|
|
+ _M_check(__pos, "basic_string::substr"), __n); }
|
2052 |
|
|
+
|
2053 |
|
|
+ /**
|
2054 |
|
|
+ * @brief Compare to a string.
|
2055 |
|
|
+ * @param str String to compare against.
|
2056 |
|
|
+ * @return Integer < 0, 0, or > 0.
|
2057 |
|
|
+ *
|
2058 |
|
|
+ * Returns an integer < 0 if this string is ordered before @a str, 0 if
|
2059 |
|
|
+ * their values are equivalent, or > 0 if this string is ordered after
|
2060 |
|
|
+ * @a str. If the lengths of @a str and this string are different, the
|
2061 |
|
|
+ * shorter one is ordered first. If they are the same, returns the
|
2062 |
|
|
+ * result of traits::compare(data(),str.data(),size());
|
2063 |
|
|
+ */
|
2064 |
|
|
+ int
|
2065 |
|
|
+ compare(const basic_string& __str) const
|
2066 |
|
|
+ {
|
2067 |
|
|
+ const size_type __size = this->size();
|
2068 |
|
|
+ const size_type __osize = __str.size();
|
2069 |
|
|
+ const size_type __len = std::min(__size, __osize);
|
2070 |
|
|
+
|
2071 |
|
|
+ int __r = traits_type::compare(_M_data(), __str.data(), __len);
|
2072 |
|
|
+ if (!__r)
|
2073 |
|
|
+ __r = __size - __osize;
|
2074 |
|
|
+ return __r;
|
2075 |
|
|
+ }
|
2076 |
|
|
+
|
2077 |
|
|
+ /**
|
2078 |
|
|
+ * @brief Compare substring to a string.
|
2079 |
|
|
+ * @param pos Index of first character of substring.
|
2080 |
|
|
+ * @param n Number of characters in substring.
|
2081 |
|
|
+ * @param str String to compare against.
|
2082 |
|
|
+ * @return Integer < 0, 0, or > 0.
|
2083 |
|
|
+ *
|
2084 |
|
|
+ * Form the substring of this string from the @a n characters starting
|
2085 |
|
|
+ * at @a pos. Returns an integer < 0 if the substring is ordered
|
2086 |
|
|
+ * before @a str, 0 if their values are equivalent, or > 0 if the
|
2087 |
|
|
+ * substring is ordered after @a str. If the lengths @a of str and the
|
2088 |
|
|
+ * substring are different, the shorter one is ordered first. If they
|
2089 |
|
|
+ * are the same, returns the result of
|
2090 |
|
|
+ * traits::compare(substring.data(),str.data(),size());
|
2091 |
|
|
+ */
|
2092 |
|
|
+ int
|
2093 |
|
|
+ compare(size_type __pos, size_type __n, const basic_string& __str) const;
|
2094 |
|
|
+
|
2095 |
|
|
+ /**
|
2096 |
|
|
+ * @brief Compare substring to a substring.
|
2097 |
|
|
+ * @param pos1 Index of first character of substring.
|
2098 |
|
|
+ * @param n1 Number of characters in substring.
|
2099 |
|
|
+ * @param str String to compare against.
|
2100 |
|
|
+ * @param pos2 Index of first character of substring of str.
|
2101 |
|
|
+ * @param n2 Number of characters in substring of str.
|
2102 |
|
|
+ * @return Integer < 0, 0, or > 0.
|
2103 |
|
|
+ *
|
2104 |
|
|
+ * Form the substring of this string from the @a n1 characters starting
|
2105 |
|
|
+ * at @a pos1. Form the substring of @a str from the @a n2 characters
|
2106 |
|
|
+ * starting at @a pos2. Returns an integer < 0 if this substring is
|
2107 |
|
|
+ * ordered before the substring of @a str, 0 if their values are
|
2108 |
|
|
+ * equivalent, or > 0 if this substring is ordered after the substring
|
2109 |
|
|
+ * of @a str. If the lengths of the substring of @a str and this
|
2110 |
|
|
+ * substring are different, the shorter one is ordered first. If they
|
2111 |
|
|
+ * are the same, returns the result of
|
2112 |
|
|
+ * traits::compare(substring.data(),str.substr(pos2,n2).data(),size());
|
2113 |
|
|
+ */
|
2114 |
|
|
+ int
|
2115 |
|
|
+ compare(size_type __pos1, size_type __n1, const basic_string& __str,
|
2116 |
|
|
+ size_type __pos2, size_type __n2) const;
|
2117 |
|
|
+
|
2118 |
|
|
+ /**
|
2119 |
|
|
+ * @brief Compare to a C string.
|
2120 |
|
|
+ * @param s C string to compare against.
|
2121 |
|
|
+ * @return Integer < 0, 0, or > 0.
|
2122 |
|
|
+ *
|
2123 |
|
|
+ * Returns an integer < 0 if this string is ordered before @a s, 0 if
|
2124 |
|
|
+ * their values are equivalent, or > 0 if this string is ordered after
|
2125 |
|
|
+ * @a s. If the lengths of @a s and this string are different, the
|
2126 |
|
|
+ * shorter one is ordered first. If they are the same, returns the
|
2127 |
|
|
+ * result of traits::compare(data(),s,size());
|
2128 |
|
|
+ */
|
2129 |
|
|
+ int
|
2130 |
|
|
+ compare(const _CharT* __s) const;
|
2131 |
|
|
+
|
2132 |
|
|
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
|
2133 |
|
|
+ // 5 String::compare specification questionable
|
2134 |
|
|
+ /**
|
2135 |
|
|
+ * @brief Compare substring to a C string.
|
2136 |
|
|
+ * @param pos Index of first character of substring.
|
2137 |
|
|
+ * @param n1 Number of characters in substring.
|
2138 |
|
|
+ * @param s C string to compare against.
|
2139 |
|
|
+ * @return Integer < 0, 0, or > 0.
|
2140 |
|
|
+ *
|
2141 |
|
|
+ * Form the substring of this string from the @a n1 characters starting
|
2142 |
|
|
+ * at @a pos. Returns an integer < 0 if the substring is ordered
|
2143 |
|
|
+ * before @a s, 0 if their values are equivalent, or > 0 if the
|
2144 |
|
|
+ * substring is ordered after @a s. If the lengths of @a s and the
|
2145 |
|
|
+ * substring are different, the shorter one is ordered first. If they
|
2146 |
|
|
+ * are the same, returns the result of
|
2147 |
|
|
+ * traits::compare(substring.data(),s,size());
|
2148 |
|
|
+ */
|
2149 |
|
|
+ int
|
2150 |
|
|
+ compare(size_type __pos, size_type __n1, const _CharT* __s) const;
|
2151 |
|
|
+
|
2152 |
|
|
+ /**
|
2153 |
|
|
+ * @brief Compare substring against a character array.
|
2154 |
|
|
+ * @param pos1 Index of first character of substring.
|
2155 |
|
|
+ * @param n1 Number of characters in substring.
|
2156 |
|
|
+ * @param s character array to compare against.
|
2157 |
|
|
+ * @param n2 Number of characters of s.
|
2158 |
|
|
+ * @return Integer < 0, 0, or > 0.
|
2159 |
|
|
+ *
|
2160 |
|
|
+ * Form the substring of this string from the @a n1 characters starting
|
2161 |
|
|
+ * at @a pos1. Form a string from the first @a n2 characters of @a s.
|
2162 |
|
|
+ * Returns an integer < 0 if this substring is ordered before the string
|
2163 |
|
|
+ * from @a s, 0 if their values are equivalent, or > 0 if this substring
|
2164 |
|
|
+ * is ordered after the string from @a s. If the lengths of this
|
2165 |
|
|
+ * substring and @a n2 are different, the shorter one is ordered first.
|
2166 |
|
|
+ * If they are the same, returns the result of
|
2167 |
|
|
+ * traits::compare(substring.data(),s,size());
|
2168 |
|
|
+ *
|
2169 |
|
|
+ * NB: s must have at least n2 characters, '\0' has no special
|
2170 |
|
|
+ * meaning.
|
2171 |
|
|
+ */
|
2172 |
|
|
+ int
|
2173 |
|
|
+ compare(size_type __pos, size_type __n1, const _CharT* __s,
|
2174 |
|
|
+ size_type __n2) const;
|
2175 |
|
|
+ };
|
2176 |
|
|
+
|
2177 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2178 |
|
|
+ inline basic_string<_CharT, _Traits, _Alloc>::
|
2179 |
|
|
+ basic_string()
|
2180 |
|
|
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
|
2181 |
|
|
+ : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
|
2182 |
|
|
+#else
|
2183 |
|
|
+ : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { }
|
2184 |
|
|
+#endif
|
2185 |
|
|
+
|
2186 |
|
|
+ // operator+
|
2187 |
|
|
+ /**
|
2188 |
|
|
+ * @brief Concatenate two strings.
|
2189 |
|
|
+ * @param lhs First string.
|
2190 |
|
|
+ * @param rhs Last string.
|
2191 |
|
|
+ * @return New string with value of @a lhs followed by @a rhs.
|
2192 |
|
|
+ */
|
2193 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2194 |
|
|
+ basic_string<_CharT, _Traits, _Alloc>
|
2195 |
|
|
+ operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2196 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2197 |
|
|
+ {
|
2198 |
|
|
+ basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
|
2199 |
|
|
+ __str.append(__rhs);
|
2200 |
|
|
+ return __str;
|
2201 |
|
|
+ }
|
2202 |
|
|
+
|
2203 |
|
|
+ /**
|
2204 |
|
|
+ * @brief Concatenate C string and string.
|
2205 |
|
|
+ * @param lhs First string.
|
2206 |
|
|
+ * @param rhs Last string.
|
2207 |
|
|
+ * @return New string with value of @a lhs followed by @a rhs.
|
2208 |
|
|
+ */
|
2209 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2210 |
|
|
+ basic_string<_CharT,_Traits,_Alloc>
|
2211 |
|
|
+ operator+(const _CharT* __lhs,
|
2212 |
|
|
+ const basic_string<_CharT,_Traits,_Alloc>& __rhs);
|
2213 |
|
|
+
|
2214 |
|
|
+ /**
|
2215 |
|
|
+ * @brief Concatenate character and string.
|
2216 |
|
|
+ * @param lhs First string.
|
2217 |
|
|
+ * @param rhs Last string.
|
2218 |
|
|
+ * @return New string with @a lhs followed by @a rhs.
|
2219 |
|
|
+ */
|
2220 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2221 |
|
|
+ basic_string<_CharT,_Traits,_Alloc>
|
2222 |
|
|
+ operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs);
|
2223 |
|
|
+
|
2224 |
|
|
+ /**
|
2225 |
|
|
+ * @brief Concatenate string and C string.
|
2226 |
|
|
+ * @param lhs First string.
|
2227 |
|
|
+ * @param rhs Last string.
|
2228 |
|
|
+ * @return New string with @a lhs followed by @a rhs.
|
2229 |
|
|
+ */
|
2230 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2231 |
|
|
+ inline basic_string<_CharT, _Traits, _Alloc>
|
2232 |
|
|
+ operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2233 |
|
|
+ const _CharT* __rhs)
|
2234 |
|
|
+ {
|
2235 |
|
|
+ basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
|
2236 |
|
|
+ __str.append(__rhs);
|
2237 |
|
|
+ return __str;
|
2238 |
|
|
+ }
|
2239 |
|
|
+
|
2240 |
|
|
+ /**
|
2241 |
|
|
+ * @brief Concatenate string and character.
|
2242 |
|
|
+ * @param lhs First string.
|
2243 |
|
|
+ * @param rhs Last string.
|
2244 |
|
|
+ * @return New string with @a lhs followed by @a rhs.
|
2245 |
|
|
+ */
|
2246 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2247 |
|
|
+ inline basic_string<_CharT, _Traits, _Alloc>
|
2248 |
|
|
+ operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
|
2249 |
|
|
+ {
|
2250 |
|
|
+ typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
|
2251 |
|
|
+ typedef typename __string_type::size_type __size_type;
|
2252 |
|
|
+ __string_type __str(__lhs);
|
2253 |
|
|
+ __str.append(__size_type(1), __rhs);
|
2254 |
|
|
+ return __str;
|
2255 |
|
|
+ }
|
2256 |
|
|
+
|
2257 |
|
|
+ // operator ==
|
2258 |
|
|
+ /**
|
2259 |
|
|
+ * @brief Test equivalence of two strings.
|
2260 |
|
|
+ * @param lhs First string.
|
2261 |
|
|
+ * @param rhs Second string.
|
2262 |
|
|
+ * @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
|
2263 |
|
|
+ */
|
2264 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2265 |
|
|
+ inline bool
|
2266 |
|
|
+ operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2267 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2268 |
|
|
+ { return __lhs.compare(__rhs) == 0; }
|
2269 |
|
|
+
|
2270 |
|
|
+ /**
|
2271 |
|
|
+ * @brief Test equivalence of C string and string.
|
2272 |
|
|
+ * @param lhs C string.
|
2273 |
|
|
+ * @param rhs String.
|
2274 |
|
|
+ * @return True if @a rhs.compare(@a lhs) == 0. False otherwise.
|
2275 |
|
|
+ */
|
2276 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2277 |
|
|
+ inline bool
|
2278 |
|
|
+ operator==(const _CharT* __lhs,
|
2279 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2280 |
|
|
+ { return __rhs.compare(__lhs) == 0; }
|
2281 |
|
|
+
|
2282 |
|
|
+ /**
|
2283 |
|
|
+ * @brief Test equivalence of string and C string.
|
2284 |
|
|
+ * @param lhs String.
|
2285 |
|
|
+ * @param rhs C string.
|
2286 |
|
|
+ * @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
|
2287 |
|
|
+ */
|
2288 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2289 |
|
|
+ inline bool
|
2290 |
|
|
+ operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2291 |
|
|
+ const _CharT* __rhs)
|
2292 |
|
|
+ { return __lhs.compare(__rhs) == 0; }
|
2293 |
|
|
+
|
2294 |
|
|
+ // operator !=
|
2295 |
|
|
+ /**
|
2296 |
|
|
+ * @brief Test difference of two strings.
|
2297 |
|
|
+ * @param lhs First string.
|
2298 |
|
|
+ * @param rhs Second string.
|
2299 |
|
|
+ * @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
|
2300 |
|
|
+ */
|
2301 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2302 |
|
|
+ inline bool
|
2303 |
|
|
+ operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2304 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2305 |
|
|
+ { return __rhs.compare(__lhs) != 0; }
|
2306 |
|
|
+
|
2307 |
|
|
+ /**
|
2308 |
|
|
+ * @brief Test difference of C string and string.
|
2309 |
|
|
+ * @param lhs C string.
|
2310 |
|
|
+ * @param rhs String.
|
2311 |
|
|
+ * @return True if @a rhs.compare(@a lhs) != 0. False otherwise.
|
2312 |
|
|
+ */
|
2313 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2314 |
|
|
+ inline bool
|
2315 |
|
|
+ operator!=(const _CharT* __lhs,
|
2316 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2317 |
|
|
+ { return __rhs.compare(__lhs) != 0; }
|
2318 |
|
|
+
|
2319 |
|
|
+ /**
|
2320 |
|
|
+ * @brief Test difference of string and C string.
|
2321 |
|
|
+ * @param lhs String.
|
2322 |
|
|
+ * @param rhs C string.
|
2323 |
|
|
+ * @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
|
2324 |
|
|
+ */
|
2325 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2326 |
|
|
+ inline bool
|
2327 |
|
|
+ operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2328 |
|
|
+ const _CharT* __rhs)
|
2329 |
|
|
+ { return __lhs.compare(__rhs) != 0; }
|
2330 |
|
|
+
|
2331 |
|
|
+ // operator <
|
2332 |
|
|
+ /**
|
2333 |
|
|
+ * @brief Test if string precedes string.
|
2334 |
|
|
+ * @param lhs First string.
|
2335 |
|
|
+ * @param rhs Second string.
|
2336 |
|
|
+ * @return True if @a lhs precedes @a rhs. False otherwise.
|
2337 |
|
|
+ */
|
2338 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2339 |
|
|
+ inline bool
|
2340 |
|
|
+ operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2341 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2342 |
|
|
+ { return __lhs.compare(__rhs) < 0; }
|
2343 |
|
|
+
|
2344 |
|
|
+ /**
|
2345 |
|
|
+ * @brief Test if string precedes C string.
|
2346 |
|
|
+ * @param lhs String.
|
2347 |
|
|
+ * @param rhs C string.
|
2348 |
|
|
+ * @return True if @a lhs precedes @a rhs. False otherwise.
|
2349 |
|
|
+ */
|
2350 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2351 |
|
|
+ inline bool
|
2352 |
|
|
+ operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2353 |
|
|
+ const _CharT* __rhs)
|
2354 |
|
|
+ { return __lhs.compare(__rhs) < 0; }
|
2355 |
|
|
+
|
2356 |
|
|
+ /**
|
2357 |
|
|
+ * @brief Test if C string precedes string.
|
2358 |
|
|
+ * @param lhs C string.
|
2359 |
|
|
+ * @param rhs String.
|
2360 |
|
|
+ * @return True if @a lhs precedes @a rhs. False otherwise.
|
2361 |
|
|
+ */
|
2362 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2363 |
|
|
+ inline bool
|
2364 |
|
|
+ operator<(const _CharT* __lhs,
|
2365 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2366 |
|
|
+ { return __rhs.compare(__lhs) > 0; }
|
2367 |
|
|
+
|
2368 |
|
|
+ // operator >
|
2369 |
|
|
+ /**
|
2370 |
|
|
+ * @brief Test if string follows string.
|
2371 |
|
|
+ * @param lhs First string.
|
2372 |
|
|
+ * @param rhs Second string.
|
2373 |
|
|
+ * @return True if @a lhs follows @a rhs. False otherwise.
|
2374 |
|
|
+ */
|
2375 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2376 |
|
|
+ inline bool
|
2377 |
|
|
+ operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2378 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2379 |
|
|
+ { return __lhs.compare(__rhs) > 0; }
|
2380 |
|
|
+
|
2381 |
|
|
+ /**
|
2382 |
|
|
+ * @brief Test if string follows C string.
|
2383 |
|
|
+ * @param lhs String.
|
2384 |
|
|
+ * @param rhs C string.
|
2385 |
|
|
+ * @return True if @a lhs follows @a rhs. False otherwise.
|
2386 |
|
|
+ */
|
2387 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2388 |
|
|
+ inline bool
|
2389 |
|
|
+ operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2390 |
|
|
+ const _CharT* __rhs)
|
2391 |
|
|
+ { return __lhs.compare(__rhs) > 0; }
|
2392 |
|
|
+
|
2393 |
|
|
+ /**
|
2394 |
|
|
+ * @brief Test if C string follows string.
|
2395 |
|
|
+ * @param lhs C string.
|
2396 |
|
|
+ * @param rhs String.
|
2397 |
|
|
+ * @return True if @a lhs follows @a rhs. False otherwise.
|
2398 |
|
|
+ */
|
2399 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2400 |
|
|
+ inline bool
|
2401 |
|
|
+ operator>(const _CharT* __lhs,
|
2402 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2403 |
|
|
+ { return __rhs.compare(__lhs) < 0; }
|
2404 |
|
|
+
|
2405 |
|
|
+ // operator <=
|
2406 |
|
|
+ /**
|
2407 |
|
|
+ * @brief Test if string doesn't follow string.
|
2408 |
|
|
+ * @param lhs First string.
|
2409 |
|
|
+ * @param rhs Second string.
|
2410 |
|
|
+ * @return True if @a lhs doesn't follow @a rhs. False otherwise.
|
2411 |
|
|
+ */
|
2412 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2413 |
|
|
+ inline bool
|
2414 |
|
|
+ operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2415 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2416 |
|
|
+ { return __lhs.compare(__rhs) <= 0; }
|
2417 |
|
|
+
|
2418 |
|
|
+ /**
|
2419 |
|
|
+ * @brief Test if string doesn't follow C string.
|
2420 |
|
|
+ * @param lhs String.
|
2421 |
|
|
+ * @param rhs C string.
|
2422 |
|
|
+ * @return True if @a lhs doesn't follow @a rhs. False otherwise.
|
2423 |
|
|
+ */
|
2424 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2425 |
|
|
+ inline bool
|
2426 |
|
|
+ operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2427 |
|
|
+ const _CharT* __rhs)
|
2428 |
|
|
+ { return __lhs.compare(__rhs) <= 0; }
|
2429 |
|
|
+
|
2430 |
|
|
+ /**
|
2431 |
|
|
+ * @brief Test if C string doesn't follow string.
|
2432 |
|
|
+ * @param lhs C string.
|
2433 |
|
|
+ * @param rhs String.
|
2434 |
|
|
+ * @return True if @a lhs doesn't follow @a rhs. False otherwise.
|
2435 |
|
|
+ */
|
2436 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2437 |
|
|
+ inline bool
|
2438 |
|
|
+ operator<=(const _CharT* __lhs,
|
2439 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2440 |
|
|
+ { return __rhs.compare(__lhs) >= 0; }
|
2441 |
|
|
+
|
2442 |
|
|
+ // operator >=
|
2443 |
|
|
+ /**
|
2444 |
|
|
+ * @brief Test if string doesn't precede string.
|
2445 |
|
|
+ * @param lhs First string.
|
2446 |
|
|
+ * @param rhs Second string.
|
2447 |
|
|
+ * @return True if @a lhs doesn't precede @a rhs. False otherwise.
|
2448 |
|
|
+ */
|
2449 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2450 |
|
|
+ inline bool
|
2451 |
|
|
+ operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2452 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2453 |
|
|
+ { return __lhs.compare(__rhs) >= 0; }
|
2454 |
|
|
+
|
2455 |
|
|
+ /**
|
2456 |
|
|
+ * @brief Test if string doesn't precede C string.
|
2457 |
|
|
+ * @param lhs String.
|
2458 |
|
|
+ * @param rhs C string.
|
2459 |
|
|
+ * @return True if @a lhs doesn't precede @a rhs. False otherwise.
|
2460 |
|
|
+ */
|
2461 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2462 |
|
|
+ inline bool
|
2463 |
|
|
+ operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2464 |
|
|
+ const _CharT* __rhs)
|
2465 |
|
|
+ { return __lhs.compare(__rhs) >= 0; }
|
2466 |
|
|
+
|
2467 |
|
|
+ /**
|
2468 |
|
|
+ * @brief Test if C string doesn't precede string.
|
2469 |
|
|
+ * @param lhs C string.
|
2470 |
|
|
+ * @param rhs String.
|
2471 |
|
|
+ * @return True if @a lhs doesn't precede @a rhs. False otherwise.
|
2472 |
|
|
+ */
|
2473 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2474 |
|
|
+ inline bool
|
2475 |
|
|
+ operator>=(const _CharT* __lhs,
|
2476 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2477 |
|
|
+ { return __rhs.compare(__lhs) <= 0; }
|
2478 |
|
|
+
|
2479 |
|
|
+ /**
|
2480 |
|
|
+ * @brief Swap contents of two strings.
|
2481 |
|
|
+ * @param lhs First string.
|
2482 |
|
|
+ * @param rhs Second string.
|
2483 |
|
|
+ *
|
2484 |
|
|
+ * Exchanges the contents of @a lhs and @a rhs in constant time.
|
2485 |
|
|
+ */
|
2486 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2487 |
|
|
+ inline void
|
2488 |
|
|
+ swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
2489 |
|
|
+ basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2490 |
|
|
+ { __lhs.swap(__rhs); }
|
2491 |
|
|
+
|
2492 |
|
|
+ /**
|
2493 |
|
|
+ * @brief Read stream into a string.
|
2494 |
|
|
+ * @param is Input stream.
|
2495 |
|
|
+ * @param str Buffer to store into.
|
2496 |
|
|
+ * @return Reference to the input stream.
|
2497 |
|
|
+ *
|
2498 |
|
|
+ * Stores characters from @a is into @a str until whitespace is found, the
|
2499 |
|
|
+ * end of the stream is encountered, or str.max_size() is reached. If
|
2500 |
|
|
+ * is.width() is non-zero, that is the limit on the number of characters
|
2501 |
|
|
+ * stored into @a str. Any previous contents of @a str are erased.
|
2502 |
|
|
+ */
|
2503 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2504 |
|
|
+ basic_istream<_CharT, _Traits>&
|
2505 |
|
|
+ operator>>(basic_istream<_CharT, _Traits>& __is,
|
2506 |
|
|
+ basic_string<_CharT, _Traits, _Alloc>& __str);
|
2507 |
|
|
+
|
2508 |
|
|
+ /**
|
2509 |
|
|
+ * @brief Write string to a stream.
|
2510 |
|
|
+ * @param os Output stream.
|
2511 |
|
|
+ * @param str String to write out.
|
2512 |
|
|
+ * @return Reference to the output stream.
|
2513 |
|
|
+ *
|
2514 |
|
|
+ * Output characters of @a str into os following the same rules as for
|
2515 |
|
|
+ * writing a C string.
|
2516 |
|
|
+ */
|
2517 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2518 |
|
|
+ basic_ostream<_CharT, _Traits>&
|
2519 |
|
|
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
|
2520 |
|
|
+ const basic_string<_CharT, _Traits, _Alloc>& __str);
|
2521 |
|
|
+
|
2522 |
|
|
+ /**
|
2523 |
|
|
+ * @brief Read a line from stream into a string.
|
2524 |
|
|
+ * @param is Input stream.
|
2525 |
|
|
+ * @param str Buffer to store into.
|
2526 |
|
|
+ * @param delim Character marking end of line.
|
2527 |
|
|
+ * @return Reference to the input stream.
|
2528 |
|
|
+ *
|
2529 |
|
|
+ * Stores characters from @a is into @a str until @a delim is found, the
|
2530 |
|
|
+ * end of the stream is encountered, or str.max_size() is reached. If
|
2531 |
|
|
+ * is.width() is non-zero, that is the limit on the number of characters
|
2532 |
|
|
+ * stored into @a str. Any previous contents of @a str are erased. If @a
|
2533 |
|
|
+ * delim was encountered, it is extracted but not stored into @a str.
|
2534 |
|
|
+ */
|
2535 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2536 |
|
|
+ basic_istream<_CharT, _Traits>&
|
2537 |
|
|
+ getline(basic_istream<_CharT, _Traits>& __is,
|
2538 |
|
|
+ basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
|
2539 |
|
|
+
|
2540 |
|
|
+ /**
|
2541 |
|
|
+ * @brief Read a line from stream into a string.
|
2542 |
|
|
+ * @param is Input stream.
|
2543 |
|
|
+ * @param str Buffer to store into.
|
2544 |
|
|
+ * @return Reference to the input stream.
|
2545 |
|
|
+ *
|
2546 |
|
|
+ * Stores characters from is into @a str until '\n' is found, the end of
|
2547 |
|
|
+ * the stream is encountered, or str.max_size() is reached. If is.width()
|
2548 |
|
|
+ * is non-zero, that is the limit on the number of characters stored into
|
2549 |
|
|
+ * @a str. Any previous contents of @a str are erased. If end of line was
|
2550 |
|
|
+ * encountered, it is extracted but not stored into @a str.
|
2551 |
|
|
+ */
|
2552 |
|
|
+ template<typename _CharT, typename _Traits, typename _Alloc>
|
2553 |
|
|
+ inline basic_istream<_CharT, _Traits>&
|
2554 |
|
|
+ getline(basic_istream<_CharT, _Traits>& __is,
|
2555 |
|
|
+ basic_string<_CharT, _Traits, _Alloc>& __str);
|
2556 |
|
|
+
|
2557 |
|
|
+ template<>
|
2558 |
|
|
+ basic_istream<char>&
|
2559 |
|
|
+ getline(basic_istream<char>& __in, basic_string<char>& __str,
|
2560 |
|
|
+ char __delim);
|
2561 |
|
|
+
|
2562 |
|
|
+#ifdef _GLIBCXX_USE_WCHAR_T
|
2563 |
|
|
+ template<>
|
2564 |
|
|
+ basic_istream<wchar_t>&
|
2565 |
|
|
+ getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
|
2566 |
|
|
+ wchar_t __delim);
|
2567 |
|
|
+#endif
|
2568 |
|
|
+} // namespace std
|
2569 |
|
|
+
|
2570 |
|
|
+#endif /* _BASIC_STRING_H */
|
2571 |
|
|
+
|
2572 |
|
|
+
|
2573 |
|
|
+//
|
2574 |
|
|
+
|
2575 |
|
|
+#ifndef _GLIBCXX_EXPORT_TEMPLATE
|
2576 |
|
|
+# include <algorithm> // for find_if
|
2577 |
|
|
+# include <bits/basic_string.tcc>
|
2578 |
|
|
+#endif
|
2579 |
|
|
+
|
2580 |
|
|
+#endif /* _GLIBCXX_STRING */
|
2581 |
|
|
diff -Nur gccxml-060p2/share/gccxml-0.6/GCC/find_flags gccxml-060p3/share/gccxml-0.6/GCC/find_flags
|
2582 |
|
|
--- gccxml-060p2/share/gccxml-0.6/GCC/find_flags 2005-11-16 17:15:40.000000000 +0100
|
2583 |
|
|
+++ gccxml-060p3/share/gccxml-0.6/GCC/find_flags 2005-11-18 09:57:25.000000000 +0100
|
2584 |
|
|
@@ -66,7 +66,10 @@
|
2585 |
|
|
if [ "$MINOR_VERSION" = 96 ]; then
|
2586 |
|
|
INCLUDES="-iwrapper$SELFPATH/2.96 $INCLUDES"
|
2587 |
|
|
fi
|
2588 |
|
|
-elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" -ge 3 ]; then
|
2589 |
|
|
+elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" -ge 4 ]; then
|
2590 |
|
|
+ INCLUDES="-iwrapper$SELFPATH/3.4 $INCLUDES"
|
2591 |
|
|
+ SPECIAL="-include $SELFPATH/3.4/gccxml_builtins.h"
|
2592 |
|
|
+elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 3 ]; then
|
2593 |
|
|
INCLUDES="-iwrapper$SELFPATH/3.3 $INCLUDES"
|
2594 |
|
|
SPECIAL="-include $SELFPATH/3.3/gccxml_builtins.h"
|
2595 |
|
|
elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 2 ]; then
|
2596 |
|
|
@@ -75,10 +78,13 @@
|
2597 |
|
|
INCLUDES="-iwrapper$SELFPATH/3.1 $INCLUDES"
|
2598 |
|
|
elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 0 ]; then
|
2599 |
|
|
INCLUDES="-iwrapper$SELFPATH/3.0 $INCLUDES"
|
2600 |
|
|
+elif [ "$MAJOR_VERSION" = 4 -a "$MINOR_VERSION" -ge 0 ]; then
|
2601 |
|
|
+ SPECIAL="-include $SELFPATH/4.0/string"
|
2602 |
|
|
fi
|
2603 |
|
|
|
2604 |
|
|
# Format and print out the options.
|
2605 |
|
|
-OPTIONS="$MACROS -D__declspec(x)=__attribute__((x)) $INCLUDES $SPECIAL"
|
2606 |
|
|
+# OPTIONS="$MACROS -D__declspec(x)= -__attribute__(x)= $INCLUDES $SPECIAL"
|
2607 |
|
|
+OPTIONS="$MACROS -D__declspec(x)= -D__attribute__(x)= $INCLUDES $SPECIAL"
|
2608 |
|
|
echo $OPTIONS
|
2609 |
|
|
|
2610 |
|
|
|