williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* Copyright (c) 2004
|
williamr@4
|
3 |
* Francois Dumont
|
williamr@4
|
4 |
*
|
williamr@4
|
5 |
* This material is provided "as is", with absolutely no warranty expressed
|
williamr@4
|
6 |
* or implied. Any use is at your own risk.
|
williamr@4
|
7 |
*
|
williamr@4
|
8 |
* Permission to use or copy this software for any purpose is hereby granted
|
williamr@4
|
9 |
* without fee, provided the above notices are retained on all copies.
|
williamr@4
|
10 |
* Permission to modify the code and to distribute modified code is granted,
|
williamr@4
|
11 |
* provided the above notices are retained, and a notice that the code was
|
williamr@4
|
12 |
* modified is included with the above copyright notice.
|
williamr@4
|
13 |
*
|
williamr@4
|
14 |
*/
|
williamr@4
|
15 |
|
williamr@4
|
16 |
//Included from _string.h, no need for macro guarding.
|
williamr@4
|
17 |
|
williamr@4
|
18 |
_STLP_BEGIN_NAMESPACE
|
williamr@4
|
19 |
|
williamr@4
|
20 |
#if defined (_STLP_DEBUG)
|
williamr@4
|
21 |
# define basic_string _STLP_NON_DBG_NAME(str)
|
williamr@4
|
22 |
_STLP_MOVE_TO_PRIV_NAMESPACE
|
williamr@4
|
23 |
#endif
|
williamr@4
|
24 |
|
williamr@4
|
25 |
#define _STLP_NO_MEM_T_STRING_BASE _STLP_PRIV _STLP_NO_MEM_T_NAME(str)<_CharT, _Traits, _Alloc>
|
williamr@4
|
26 |
|
williamr@4
|
27 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@4
|
28 |
class basic_string : public _STLP_NO_MEM_T_STRING_BASE
|
williamr@4
|
29 |
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && \
|
williamr@4
|
30 |
!defined (basic_string)
|
williamr@4
|
31 |
, public __stlport_class<basic_string<_CharT, _Traits, _Alloc> >
|
williamr@4
|
32 |
#endif
|
williamr@4
|
33 |
{
|
williamr@4
|
34 |
protected: // Protected members inherited from base.
|
williamr@4
|
35 |
typedef basic_string<_CharT, _Traits, _Alloc> _Self;
|
williamr@4
|
36 |
typedef _STLP_NO_MEM_T_STRING_BASE _Base;
|
williamr@4
|
37 |
typedef typename _Base::_Char_Is_POD _Char_Is_POD;
|
williamr@4
|
38 |
|
williamr@4
|
39 |
public:
|
williamr@4
|
40 |
|
williamr@4
|
41 |
__IMPORT_WITH_REVERSE_ITERATORS(_Base)
|
williamr@4
|
42 |
|
williamr@4
|
43 |
typedef typename _Base::_Iterator_category _Iterator_category;
|
williamr@4
|
44 |
typedef typename _Base::traits_type traits_type;
|
williamr@4
|
45 |
typedef typename _Base::_Reserve_t _Reserve_t;
|
williamr@4
|
46 |
|
williamr@4
|
47 |
public: // Constructor, destructor, assignment.
|
williamr@4
|
48 |
explicit basic_string(const allocator_type& __a = allocator_type())
|
williamr@4
|
49 |
: _STLP_NO_MEM_T_STRING_BASE(__a) {}
|
williamr@4
|
50 |
|
williamr@4
|
51 |
basic_string(_Reserve_t __r, size_t __n,
|
williamr@4
|
52 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
53 |
: _STLP_NO_MEM_T_STRING_BASE(__r, __n, __a) {}
|
williamr@4
|
54 |
|
williamr@4
|
55 |
basic_string(const _Self& __s)
|
williamr@4
|
56 |
: _STLP_NO_MEM_T_STRING_BASE(__s) {}
|
williamr@4
|
57 |
|
williamr@4
|
58 |
basic_string(const _Self& __s, size_type __pos, size_type __n = npos,
|
williamr@4
|
59 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
60 |
: _STLP_NO_MEM_T_STRING_BASE(__s, __pos, __n, __a) {}
|
williamr@4
|
61 |
|
williamr@4
|
62 |
basic_string(const _CharT* __s, size_type __n,
|
williamr@4
|
63 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
64 |
: _STLP_NO_MEM_T_STRING_BASE(__s, __n, __a) {}
|
williamr@4
|
65 |
|
williamr@4
|
66 |
basic_string(const _CharT* __s,
|
williamr@4
|
67 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
68 |
: _STLP_NO_MEM_T_STRING_BASE(__s, __a) {}
|
williamr@4
|
69 |
|
williamr@4
|
70 |
basic_string(size_type __n, _CharT __c,
|
williamr@4
|
71 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
72 |
: _STLP_NO_MEM_T_STRING_BASE(__n, __c, __a) {}
|
williamr@4
|
73 |
|
williamr@4
|
74 |
basic_string(__move_source<_Self> src)
|
williamr@4
|
75 |
: _STLP_NO_MEM_T_STRING_BASE(__move_source<_Base>(src.get())) {}
|
williamr@4
|
76 |
|
williamr@4
|
77 |
// Check to see if _InputIterator is an integer type. If so, then
|
williamr@4
|
78 |
// it can't be an iterator.
|
williamr@4
|
79 |
#if !(defined(__MRC__) || (defined(__SC__) && !defined(__DMC__))) //*ty 04/30/2001 - mpw compilers choke on this ctor
|
williamr@4
|
80 |
template <class _InputIterator>
|
williamr@4
|
81 |
basic_string(_InputIterator __f, _InputIterator __l,
|
williamr@4
|
82 |
const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)
|
williamr@4
|
83 |
: _STLP_NO_MEM_T_STRING_BASE(_Base::_CalledFromWorkaround_t(), __a) {
|
williamr@4
|
84 |
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
|
williamr@4
|
85 |
_M_initialize_dispatch(__f, __l, _Integral());
|
williamr@4
|
86 |
}
|
williamr@4
|
87 |
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
williamr@4
|
88 |
template <class _InputIterator>
|
williamr@4
|
89 |
basic_string(_InputIterator __f, _InputIterator __l)
|
williamr@4
|
90 |
: _STLP_NO_MEM_T_STRING_BASE(_Base::_CalledFromWorkaround_t(), allocator_type()) {
|
williamr@4
|
91 |
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
|
williamr@4
|
92 |
_M_initialize_dispatch(__f, __l, _Integral());
|
williamr@4
|
93 |
}
|
williamr@4
|
94 |
# endif
|
williamr@4
|
95 |
#endif /* !__MRC__ || (__SC__ && !__DMC__) */
|
williamr@4
|
96 |
|
williamr@4
|
97 |
_Self& operator=(const _Self& __s) {
|
williamr@4
|
98 |
_Base::operator=(__s);
|
williamr@4
|
99 |
return *this;
|
williamr@4
|
100 |
}
|
williamr@4
|
101 |
|
williamr@4
|
102 |
_Self& operator=(const _CharT* __s) {
|
williamr@4
|
103 |
_Base::operator=(__s);
|
williamr@4
|
104 |
return *this;
|
williamr@4
|
105 |
}
|
williamr@4
|
106 |
|
williamr@4
|
107 |
_Self& operator=(_CharT __c) {
|
williamr@4
|
108 |
_Base::operator=(__c);
|
williamr@4
|
109 |
return *this;
|
williamr@4
|
110 |
}
|
williamr@4
|
111 |
|
williamr@4
|
112 |
private:
|
williamr@4
|
113 |
template <class _InputIter>
|
williamr@4
|
114 |
void _M_range_initialize(_InputIter __f, _InputIter __l,
|
williamr@4
|
115 |
const input_iterator_tag &__tag) {
|
williamr@4
|
116 |
this->_M_allocate_block();
|
williamr@4
|
117 |
this->_M_construct_null(this->_M_Finish());
|
williamr@4
|
118 |
_STLP_TRY {
|
williamr@4
|
119 |
_M_appendT(__f, __l, __tag);
|
williamr@4
|
120 |
}
|
williamr@4
|
121 |
_STLP_UNWIND(this->_M_destroy_range())
|
williamr@4
|
122 |
}
|
williamr@4
|
123 |
|
williamr@4
|
124 |
template <class _ForwardIter>
|
williamr@4
|
125 |
void _M_range_initialize(_ForwardIter __f, _ForwardIter __l,
|
williamr@4
|
126 |
const forward_iterator_tag &) {
|
williamr@4
|
127 |
difference_type __n = distance(__f, __l);
|
williamr@4
|
128 |
this->_M_allocate_block(__n + 1);
|
williamr@4
|
129 |
#if defined (_STLP_USE_SHORT_STRING_OPTIM)
|
williamr@4
|
130 |
if (this->_M_using_static_buf()) {
|
williamr@4
|
131 |
_M_copyT(__f, __l, this->_M_Start());
|
williamr@4
|
132 |
this->_M_finish = this->_M_Start() + __n;
|
williamr@4
|
133 |
}
|
williamr@4
|
134 |
else
|
williamr@4
|
135 |
#endif /* _STLP_USE_SHORT_STRING_OPTIM */
|
williamr@4
|
136 |
this->_M_finish = uninitialized_copy(__f, __l, this->_M_Start());
|
williamr@4
|
137 |
this->_M_terminate_string();
|
williamr@4
|
138 |
}
|
williamr@4
|
139 |
|
williamr@4
|
140 |
template <class _InputIter>
|
williamr@4
|
141 |
void _M_range_initializeT(_InputIter __f, _InputIter __l) {
|
williamr@4
|
142 |
_M_range_initialize(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
|
williamr@4
|
143 |
}
|
williamr@4
|
144 |
|
williamr@4
|
145 |
template <class _Integer>
|
williamr@4
|
146 |
void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) {
|
williamr@4
|
147 |
this->_M_allocate_block(__n + 1);
|
williamr@4
|
148 |
#if defined (_STLP_USE_SHORT_STRING_OPTIM)
|
williamr@4
|
149 |
if (this->_M_using_static_buf()) {
|
williamr@4
|
150 |
_Traits::assign(this->_M_Start(), __n, __x);
|
williamr@4
|
151 |
this->_M_finish = this->_M_Start() + __n;
|
williamr@4
|
152 |
}
|
williamr@4
|
153 |
else
|
williamr@4
|
154 |
#endif /* _STLP_USE_SHORT_STRING_OPTIM */
|
williamr@4
|
155 |
this->_M_finish = uninitialized_fill_n(this->_M_Start(), __n, __x);
|
williamr@4
|
156 |
this->_M_terminate_string();
|
williamr@4
|
157 |
}
|
williamr@4
|
158 |
|
williamr@4
|
159 |
template <class _InputIter>
|
williamr@4
|
160 |
void _M_initialize_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {
|
williamr@4
|
161 |
_M_range_initializeT(__f, __l);
|
williamr@4
|
162 |
}
|
williamr@4
|
163 |
|
williamr@4
|
164 |
public: // Append, operator+=, push_back.
|
williamr@4
|
165 |
_Self& operator+=(const _Self& __s) {
|
williamr@4
|
166 |
_Base::operator+=(__s);
|
williamr@4
|
167 |
return *this;
|
williamr@4
|
168 |
}
|
williamr@4
|
169 |
_Self& operator+=(const _CharT* __s) {
|
williamr@4
|
170 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
171 |
_Base::operator+=(__s);
|
williamr@4
|
172 |
return *this;
|
williamr@4
|
173 |
}
|
williamr@4
|
174 |
_Self& operator+=(_CharT __c) {
|
williamr@4
|
175 |
_Base::operator+=(__c);
|
williamr@4
|
176 |
return *this;
|
williamr@4
|
177 |
}
|
williamr@4
|
178 |
|
williamr@4
|
179 |
_Self& append(const _Self& __s) {
|
williamr@4
|
180 |
_Base::append(__s);
|
williamr@4
|
181 |
return *this;
|
williamr@4
|
182 |
}
|
williamr@4
|
183 |
|
williamr@4
|
184 |
_Self& append(const _Self& __s,
|
williamr@4
|
185 |
size_type __pos, size_type __n) {
|
williamr@4
|
186 |
_Base::append(__s, __pos, __n);
|
williamr@4
|
187 |
return *this;
|
williamr@4
|
188 |
}
|
williamr@4
|
189 |
|
williamr@4
|
190 |
_Self& append(const _CharT* __s, size_type __n) {
|
williamr@4
|
191 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
192 |
_Base::append(__s, __n);
|
williamr@4
|
193 |
return *this;
|
williamr@4
|
194 |
}
|
williamr@4
|
195 |
_Self& append(const _CharT* __s) {
|
williamr@4
|
196 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
197 |
_Base::append(__s);
|
williamr@4
|
198 |
return *this;
|
williamr@4
|
199 |
}
|
williamr@4
|
200 |
_Self& append(size_type __n, _CharT __c) {
|
williamr@4
|
201 |
_Base::append(__n, __c);
|
williamr@4
|
202 |
return *this;
|
williamr@4
|
203 |
}
|
williamr@4
|
204 |
|
williamr@4
|
205 |
// Check to see if _InputIterator is an integer type. If so, then
|
williamr@4
|
206 |
// it can't be an iterator.
|
williamr@4
|
207 |
template <class _InputIter>
|
williamr@4
|
208 |
_Self& append(_InputIter __first, _InputIter __last) {
|
williamr@4
|
209 |
typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
|
williamr@4
|
210 |
return _M_append_dispatch(__first, __last, _Integral());
|
williamr@4
|
211 |
}
|
williamr@4
|
212 |
|
williamr@4
|
213 |
#if !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
|
williamr@4
|
214 |
//See equivalent assign method remark.
|
williamr@4
|
215 |
_Self& append(const _CharT* __f, const _CharT* __l) {
|
williamr@4
|
216 |
_STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
|
williamr@4
|
217 |
_Base::append(__f, __l);
|
williamr@4
|
218 |
return *this;
|
williamr@4
|
219 |
}
|
williamr@4
|
220 |
#endif
|
williamr@4
|
221 |
|
williamr@4
|
222 |
private: // Helper functions for append.
|
williamr@4
|
223 |
|
williamr@4
|
224 |
template <class _InputIter>
|
williamr@4
|
225 |
_Self& _M_appendT(_InputIter __first, _InputIter __last,
|
williamr@4
|
226 |
const input_iterator_tag &) {
|
williamr@4
|
227 |
for ( ; __first != __last ; ++__first)
|
williamr@4
|
228 |
_Base::push_back(*__first);
|
williamr@4
|
229 |
return *this;
|
williamr@4
|
230 |
}
|
williamr@4
|
231 |
|
williamr@4
|
232 |
template <class _ForwardIter>
|
williamr@4
|
233 |
_Self& _M_appendT(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
234 |
const forward_iterator_tag &) {
|
williamr@4
|
235 |
if (__first != __last) {
|
williamr@4
|
236 |
const size_type __old_size = this->size();
|
williamr@4
|
237 |
difference_type __n = distance(__first, __last);
|
williamr@4
|
238 |
if (__STATIC_CAST(size_type,__n) > max_size() || __old_size > max_size() - __STATIC_CAST(size_type,__n))
|
williamr@4
|
239 |
this->_M_throw_length_error();
|
williamr@4
|
240 |
if (__old_size + __n > capacity()) {
|
williamr@4
|
241 |
const size_type __len = __old_size +
|
williamr@4
|
242 |
(max)(__old_size, __STATIC_CAST(size_type,__n)) + 1;
|
williamr@4
|
243 |
pointer __new_start = this->_M_end_of_storage.allocate(__len);
|
williamr@4
|
244 |
pointer __new_finish = __new_start;
|
williamr@4
|
245 |
_STLP_TRY {
|
williamr@4
|
246 |
__new_finish = uninitialized_copy(this->_M_Start(), this->_M_Finish(), __new_start);
|
williamr@4
|
247 |
__new_finish = uninitialized_copy(__first, __last, __new_finish);
|
williamr@4
|
248 |
_M_construct_null(__new_finish);
|
williamr@4
|
249 |
}
|
williamr@4
|
250 |
_STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish),
|
williamr@4
|
251 |
this->_M_end_of_storage.deallocate(__new_start,__len)))
|
williamr@4
|
252 |
this->_M_destroy_range();
|
williamr@4
|
253 |
this->_M_deallocate_block();
|
williamr@4
|
254 |
this->_M_reset(__new_start, __new_finish, __new_start + __len);
|
williamr@4
|
255 |
}
|
williamr@4
|
256 |
else {
|
williamr@4
|
257 |
_ForwardIter __f1 = __first;
|
williamr@4
|
258 |
++__f1;
|
williamr@4
|
259 |
#if defined (_STLP_USE_SHORT_STRING_OPTIM)
|
williamr@4
|
260 |
if (this->_M_using_static_buf())
|
williamr@4
|
261 |
_M_copyT(__f1, __last, this->_M_Finish() + 1);
|
williamr@4
|
262 |
else
|
williamr@4
|
263 |
#endif /* _STLP_USE_SHORT_STRING_OPTIM */
|
williamr@4
|
264 |
uninitialized_copy(__f1, __last, this->_M_Finish() + 1);
|
williamr@4
|
265 |
_STLP_TRY {
|
williamr@4
|
266 |
this->_M_construct_null(this->_M_Finish() + __n);
|
williamr@4
|
267 |
}
|
williamr@4
|
268 |
_STLP_UNWIND(this->_M_destroy_ptr_range(this->_M_Finish() + 1, this->_M_Finish() + __n))
|
williamr@4
|
269 |
_Traits::assign(*this->_M_finish, *__first);
|
williamr@4
|
270 |
this->_M_finish += __n;
|
williamr@4
|
271 |
}
|
williamr@4
|
272 |
}
|
williamr@4
|
273 |
return *this;
|
williamr@4
|
274 |
}
|
williamr@4
|
275 |
|
williamr@4
|
276 |
template <class _Integer>
|
williamr@4
|
277 |
_Self& _M_append_dispatch(_Integer __n, _Integer __x, const __true_type& /*Integral*/) {
|
williamr@4
|
278 |
return append((size_type) __n, (_CharT) __x);
|
williamr@4
|
279 |
}
|
williamr@4
|
280 |
|
williamr@4
|
281 |
template <class _InputIter>
|
williamr@4
|
282 |
_Self& _M_append_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*Integral*/) {
|
williamr@4
|
283 |
return _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
|
williamr@4
|
284 |
}
|
williamr@4
|
285 |
|
williamr@4
|
286 |
public: // Assign
|
williamr@4
|
287 |
|
williamr@4
|
288 |
_Self& assign(const _Self& __s) {
|
williamr@4
|
289 |
_Base::assign(__s);
|
williamr@4
|
290 |
return *this;
|
williamr@4
|
291 |
}
|
williamr@4
|
292 |
|
williamr@4
|
293 |
_Self& assign(const _Self& __s,
|
williamr@4
|
294 |
size_type __pos, size_type __n) {
|
williamr@4
|
295 |
_Base::assign(__s, __pos, __n);
|
williamr@4
|
296 |
return *this;
|
williamr@4
|
297 |
}
|
williamr@4
|
298 |
|
williamr@4
|
299 |
_Self& assign(const _CharT* __s, size_type __n) {
|
williamr@4
|
300 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
301 |
_Base::assign(__s, __n);
|
williamr@4
|
302 |
return *this;
|
williamr@4
|
303 |
}
|
williamr@4
|
304 |
|
williamr@4
|
305 |
_Self& assign(const _CharT* __s) {
|
williamr@4
|
306 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
307 |
_Base::assign(__s);
|
williamr@4
|
308 |
return *this;
|
williamr@4
|
309 |
}
|
williamr@4
|
310 |
|
williamr@4
|
311 |
_Self& assign(size_type __n, _CharT __c) {
|
williamr@4
|
312 |
_Base::assign(__n, __c);
|
williamr@4
|
313 |
return *this;
|
williamr@4
|
314 |
}
|
williamr@4
|
315 |
|
williamr@4
|
316 |
private: // Helper functions for assign.
|
williamr@4
|
317 |
|
williamr@4
|
318 |
template <class _Integer>
|
williamr@4
|
319 |
_Self& _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) {
|
williamr@4
|
320 |
return assign((size_type) __n, (_CharT) __x);
|
williamr@4
|
321 |
}
|
williamr@4
|
322 |
|
williamr@4
|
323 |
template <class _InputIter>
|
williamr@4
|
324 |
_Self& _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {
|
williamr@4
|
325 |
pointer __cur = this->_M_Start();
|
williamr@4
|
326 |
while (__f != __l && __cur != this->_M_Finish()) {
|
williamr@4
|
327 |
_Traits::assign(*__cur, *__f);
|
williamr@4
|
328 |
++__f;
|
williamr@4
|
329 |
++__cur;
|
williamr@4
|
330 |
}
|
williamr@4
|
331 |
if (__f == __l)
|
williamr@4
|
332 |
_Base::erase(__cur, this->_M_Finish());
|
williamr@4
|
333 |
else
|
williamr@4
|
334 |
_M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
|
williamr@4
|
335 |
return *this;
|
williamr@4
|
336 |
}
|
williamr@4
|
337 |
|
williamr@4
|
338 |
public:
|
williamr@4
|
339 |
// Check to see if _InputIterator is an integer type. If so, then
|
williamr@4
|
340 |
// it can't be an iterator.
|
williamr@4
|
341 |
template <class _InputIter>
|
williamr@4
|
342 |
_Self& assign(_InputIter __first, _InputIter __last) {
|
williamr@4
|
343 |
typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
|
williamr@4
|
344 |
return _M_assign_dispatch(__first, __last, _Integral());
|
williamr@4
|
345 |
}
|
williamr@4
|
346 |
|
williamr@4
|
347 |
#if !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
|
williamr@4
|
348 |
/* This method is not part of the standard and is a specialization of the
|
williamr@4
|
349 |
* template method assign. It is only granted for convenience to call assign
|
williamr@4
|
350 |
* with mixed parameters iterator and const_iterator.
|
williamr@4
|
351 |
*/
|
williamr@4
|
352 |
_Self& assign(const _CharT* __f, const _CharT* __l) {
|
williamr@4
|
353 |
_STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
|
williamr@4
|
354 |
_Base::assign(__f, __l);
|
williamr@4
|
355 |
return *this;
|
williamr@4
|
356 |
}
|
williamr@4
|
357 |
#endif
|
williamr@4
|
358 |
|
williamr@4
|
359 |
public: // Insert
|
williamr@4
|
360 |
|
williamr@4
|
361 |
_Self& insert(size_type __pos, const _Self& __s) {
|
williamr@4
|
362 |
_Base::insert(__pos, __s);
|
williamr@4
|
363 |
return *this;
|
williamr@4
|
364 |
}
|
williamr@4
|
365 |
|
williamr@4
|
366 |
_Self& insert(size_type __pos, const _Self& __s,
|
williamr@4
|
367 |
size_type __beg, size_type __n) {
|
williamr@4
|
368 |
_Base::insert(__pos, __s, __beg, __n);
|
williamr@4
|
369 |
return *this;
|
williamr@4
|
370 |
}
|
williamr@4
|
371 |
_Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
|
williamr@4
|
372 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
373 |
_Base::insert(__pos, __s, __n);
|
williamr@4
|
374 |
return *this;
|
williamr@4
|
375 |
}
|
williamr@4
|
376 |
|
williamr@4
|
377 |
_Self& insert(size_type __pos, const _CharT* __s) {
|
williamr@4
|
378 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
379 |
_Base::insert(__pos, __s);
|
williamr@4
|
380 |
return *this;
|
williamr@4
|
381 |
}
|
williamr@4
|
382 |
|
williamr@4
|
383 |
_Self& insert(size_type __pos, size_type __n, _CharT __c) {
|
williamr@4
|
384 |
_Base::insert(__pos, __n, __c);
|
williamr@4
|
385 |
return *this;
|
williamr@4
|
386 |
}
|
williamr@4
|
387 |
|
williamr@4
|
388 |
iterator insert(iterator __p, _CharT __c) {
|
williamr@4
|
389 |
return _Base::insert(__p, __c);
|
williamr@4
|
390 |
}
|
williamr@4
|
391 |
|
williamr@4
|
392 |
void insert(iterator __p, size_t __n, _CharT __c) {
|
williamr@4
|
393 |
_Base::insert(__p, __n, __c);
|
williamr@4
|
394 |
}
|
williamr@4
|
395 |
|
williamr@4
|
396 |
// Check to see if _InputIterator is an integer type. If so, then
|
williamr@4
|
397 |
// it can't be an iterator.
|
williamr@4
|
398 |
template <class _InputIter>
|
williamr@4
|
399 |
void insert(iterator __p, _InputIter __first, _InputIter __last) {
|
williamr@4
|
400 |
typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
|
williamr@4
|
401 |
_M_insert_dispatch(__p, __first, __last, _Integral());
|
williamr@4
|
402 |
}
|
williamr@4
|
403 |
|
williamr@4
|
404 |
private: // Helper functions for insert.
|
williamr@4
|
405 |
|
williamr@4
|
406 |
void _M_insert(iterator __p, const _CharT* __f, const _CharT* __l, bool __self_ref) {
|
williamr@4
|
407 |
_STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
|
williamr@4
|
408 |
_Base::_M_insert(__p, __f, __l, __self_ref);
|
williamr@4
|
409 |
}
|
williamr@4
|
410 |
|
williamr@4
|
411 |
template <class _ForwardIter>
|
williamr@4
|
412 |
void _M_insert_overflow(iterator __position, _ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
413 |
difference_type __n) {
|
williamr@4
|
414 |
const size_type __old_size = this->size();
|
williamr@4
|
415 |
const size_type __len = __old_size + (max)(__old_size, __STATIC_CAST(size_type,__n)) + 1;
|
williamr@4
|
416 |
pointer __new_start = this->_M_end_of_storage.allocate(__len);
|
williamr@4
|
417 |
pointer __new_finish = __new_start;
|
williamr@4
|
418 |
_STLP_TRY {
|
williamr@4
|
419 |
__new_finish = uninitialized_copy(this->_M_Start(), __position, __new_start);
|
williamr@4
|
420 |
__new_finish = uninitialized_copy(__first, __last, __new_finish);
|
williamr@4
|
421 |
__new_finish = uninitialized_copy(__position, this->_M_Finish(), __new_finish);
|
williamr@4
|
422 |
this->_M_construct_null(__new_finish);
|
williamr@4
|
423 |
}
|
williamr@4
|
424 |
_STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish),
|
williamr@4
|
425 |
this->_M_end_of_storage.deallocate(__new_start,__len)))
|
williamr@4
|
426 |
this->_M_destroy_range();
|
williamr@4
|
427 |
this->_M_deallocate_block();
|
williamr@4
|
428 |
this->_M_reset(__new_start, __new_finish, __new_start + __len);
|
williamr@4
|
429 |
}
|
williamr@4
|
430 |
|
williamr@4
|
431 |
template <class _InputIter>
|
williamr@4
|
432 |
void _M_insertT(iterator __p, _InputIter __first, _InputIter __last,
|
williamr@4
|
433 |
const input_iterator_tag &) {
|
williamr@4
|
434 |
for ( ; __first != __last; ++__first) {
|
williamr@4
|
435 |
__p = insert(__p, *__first);
|
williamr@4
|
436 |
++__p;
|
williamr@4
|
437 |
}
|
williamr@4
|
438 |
}
|
williamr@4
|
439 |
|
williamr@4
|
440 |
template <class _ForwardIter>
|
williamr@4
|
441 |
void _M_insertT(iterator __position, _ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
442 |
const forward_iterator_tag &) {
|
williamr@4
|
443 |
if (__first != __last) {
|
williamr@4
|
444 |
difference_type __n = distance(__first, __last);
|
williamr@4
|
445 |
if (this->_M_end_of_storage._M_data - this->_M_finish >= __n + 1) {
|
williamr@4
|
446 |
const difference_type __elems_after = this->_M_finish - __position;
|
williamr@4
|
447 |
if (__elems_after >= __n) {
|
williamr@4
|
448 |
#if defined (_STLP_USE_SHORT_STRING_OPTIM)
|
williamr@4
|
449 |
if (this->_M_using_static_buf())
|
williamr@4
|
450 |
_Base::_M_copy((this->_M_Finish() - __n) + 1, this->_M_Finish() + 1, this->_M_Finish() + 1);
|
williamr@4
|
451 |
else
|
williamr@4
|
452 |
#endif /* _STLP_USE_SHORT_STRING_OPTIM */
|
williamr@4
|
453 |
uninitialized_copy((this->_M_Finish() - __n) + 1, this->_M_Finish() + 1, this->_M_Finish() + 1);
|
williamr@4
|
454 |
this->_M_finish += __n;
|
williamr@4
|
455 |
_Traits::move(__position + __n, __position, (__elems_after - __n) + 1);
|
williamr@4
|
456 |
_M_copyT(__first, __last, __position);
|
williamr@4
|
457 |
}
|
williamr@4
|
458 |
else {
|
williamr@4
|
459 |
pointer __old_finish = this->_M_Finish();
|
williamr@4
|
460 |
_ForwardIter __mid = __first;
|
williamr@4
|
461 |
advance(__mid, __elems_after + 1);
|
williamr@4
|
462 |
#if defined (_STLP_USE_SHORT_STRING_OPTIM)
|
williamr@4
|
463 |
if (this->_M_using_static_buf())
|
williamr@4
|
464 |
_M_copyT(__mid, __last, this->_M_Finish() + 1);
|
williamr@4
|
465 |
else
|
williamr@4
|
466 |
#endif /* _STLP_USE_SHORT_STRING_OPTIM */
|
williamr@4
|
467 |
uninitialized_copy(__mid, __last, this->_M_Finish() + 1);
|
williamr@4
|
468 |
this->_M_finish += __n - __elems_after;
|
williamr@4
|
469 |
_STLP_TRY {
|
williamr@4
|
470 |
#if defined (_STLP_USE_SHORT_STRING_OPTIM)
|
williamr@4
|
471 |
if (this->_M_using_static_buf())
|
williamr@4
|
472 |
_Base::_M_copy(__position, __old_finish + 1, this->_M_Finish());
|
williamr@4
|
473 |
else
|
williamr@4
|
474 |
#endif /* _STLP_USE_SHORT_STRING_OPTIM */
|
williamr@4
|
475 |
uninitialized_copy(__position, __old_finish + 1, this->_M_Finish());
|
williamr@4
|
476 |
this->_M_finish += __elems_after;
|
williamr@4
|
477 |
}
|
williamr@4
|
478 |
_STLP_UNWIND((this->_M_destroy_ptr_range(__old_finish + 1, this->_M_Finish()),
|
williamr@4
|
479 |
this->_M_finish = __old_finish))
|
williamr@4
|
480 |
_M_copyT(__first, __mid, __position);
|
williamr@4
|
481 |
}
|
williamr@4
|
482 |
}
|
williamr@4
|
483 |
else {
|
williamr@4
|
484 |
_M_insert_overflow(__position, __first, __last, __n);
|
williamr@4
|
485 |
}
|
williamr@4
|
486 |
}
|
williamr@4
|
487 |
}
|
williamr@4
|
488 |
|
williamr@4
|
489 |
template <class _Integer>
|
williamr@4
|
490 |
void _M_insert_dispatch(iterator __p, _Integer __n, _Integer __x,
|
williamr@4
|
491 |
const __true_type& /*Integral*/) {
|
williamr@4
|
492 |
insert(__p, (size_type) __n, (_CharT) __x);
|
williamr@4
|
493 |
}
|
williamr@4
|
494 |
|
williamr@4
|
495 |
template <class _InputIter>
|
williamr@4
|
496 |
void _M_insert_dispatch(iterator __p, _InputIter __first, _InputIter __last,
|
williamr@4
|
497 |
const __false_type& /*Integral*/) {
|
williamr@4
|
498 |
_STLP_FIX_LITERAL_BUG(__p)
|
williamr@4
|
499 |
/*
|
williamr@4
|
500 |
* Within the basic_string implementation we are only going to check for
|
williamr@4
|
501 |
* self referencing if iterators are string iterators or _CharT pointers.
|
williamr@4
|
502 |
* A user could encapsulate those iterator within their own iterator interface
|
williamr@4
|
503 |
* and in this case lead to a bad behavior, this is a known limitation.
|
williamr@4
|
504 |
*/
|
williamr@4
|
505 |
typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsIterator;
|
williamr@4
|
506 |
typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
|
williamr@4
|
507 |
typedef typename _Lor2<_IsIterator, _IsConstIterator>::_Ret _CheckInside;
|
williamr@4
|
508 |
_M_insert_aux(__p, __first, __last, _CheckInside());
|
williamr@4
|
509 |
}
|
williamr@4
|
510 |
|
williamr@4
|
511 |
template <class _RandomIter>
|
williamr@4
|
512 |
void _M_insert_aux (iterator __p, _RandomIter __first, _RandomIter __last,
|
williamr@4
|
513 |
const __true_type& /*_CheckInside*/) {
|
williamr@4
|
514 |
_STLP_FIX_LITERAL_BUG(__p)
|
williamr@4
|
515 |
_M_insert(__p, &(*__first), &(*__last), _Base::_M_inside(&(*__first)));
|
williamr@4
|
516 |
}
|
williamr@4
|
517 |
|
williamr@4
|
518 |
template<class _InputIter>
|
williamr@4
|
519 |
void _M_insert_aux (iterator __p, _InputIter __first, _InputIter __last,
|
williamr@4
|
520 |
const __false_type& /*_CheckInside*/) {
|
williamr@4
|
521 |
_STLP_FIX_LITERAL_BUG(__p)
|
williamr@4
|
522 |
_M_insertT(__p, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
|
williamr@4
|
523 |
}
|
williamr@4
|
524 |
|
williamr@4
|
525 |
template <class _InputIterator>
|
williamr@4
|
526 |
void _M_copyT(_InputIterator __first, _InputIterator __last, pointer __result) {
|
williamr@4
|
527 |
_STLP_FIX_LITERAL_BUG(__p)
|
williamr@4
|
528 |
for ( ; __first != __last; ++__first, ++__result)
|
williamr@4
|
529 |
_Traits::assign(*__result, *__first);
|
williamr@4
|
530 |
}
|
williamr@4
|
531 |
|
williamr@4
|
532 |
#if !defined (_STLP_NO_METHOD_SPECIALIZATION)
|
williamr@4
|
533 |
void _M_copyT(const _CharT* __f, const _CharT* __l, _CharT* __res) {
|
williamr@4
|
534 |
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) _STLP_FIX_LITERAL_BUG(__res)
|
williamr@4
|
535 |
_Base::_M_copy(__f, __l, __res);
|
williamr@4
|
536 |
}
|
williamr@4
|
537 |
#endif
|
williamr@4
|
538 |
|
williamr@4
|
539 |
public: // Erase.
|
williamr@4
|
540 |
|
williamr@4
|
541 |
_Self& erase(size_type __pos = 0, size_type __n = npos) {
|
williamr@4
|
542 |
_Base::erase(__pos, __n);
|
williamr@4
|
543 |
return *this;
|
williamr@4
|
544 |
}
|
williamr@4
|
545 |
|
williamr@4
|
546 |
iterator erase(iterator __pos) {
|
williamr@4
|
547 |
_STLP_FIX_LITERAL_BUG(__pos)
|
williamr@4
|
548 |
return _Base::erase(__pos);
|
williamr@4
|
549 |
}
|
williamr@4
|
550 |
|
williamr@4
|
551 |
iterator erase(iterator __first, iterator __last) {
|
williamr@4
|
552 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
553 |
return _Base::erase(__first, __last);
|
williamr@4
|
554 |
}
|
williamr@4
|
555 |
|
williamr@4
|
556 |
public: // Replace. (Conceptually equivalent
|
williamr@4
|
557 |
// to erase followed by insert.)
|
williamr@4
|
558 |
_Self& replace(size_type __pos, size_type __n, const _Self& __s) {
|
williamr@4
|
559 |
_Base::replace(__pos, __n, __s);
|
williamr@4
|
560 |
return *this;
|
williamr@4
|
561 |
}
|
williamr@4
|
562 |
|
williamr@4
|
563 |
_Self& replace(size_type __pos1, size_type __n1, const _Self& __s,
|
williamr@4
|
564 |
size_type __pos2, size_type __n2) {
|
williamr@4
|
565 |
_Base::replace(__pos1, __n1, __s, __pos2, __n2);
|
williamr@4
|
566 |
return *this;
|
williamr@4
|
567 |
}
|
williamr@4
|
568 |
|
williamr@4
|
569 |
_Self& replace(size_type __pos, size_type __n1,
|
williamr@4
|
570 |
const _CharT* __s, size_type __n2) {
|
williamr@4
|
571 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
572 |
_Base::replace(__pos, __n1, __s, __n2);
|
williamr@4
|
573 |
return *this;
|
williamr@4
|
574 |
}
|
williamr@4
|
575 |
|
williamr@4
|
576 |
_Self& replace(size_type __pos, size_type __n1, const _CharT* __s) {
|
williamr@4
|
577 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
578 |
_Base::replace(__pos, __n1, __s);
|
williamr@4
|
579 |
return *this;
|
williamr@4
|
580 |
}
|
williamr@4
|
581 |
|
williamr@4
|
582 |
_Self& replace(size_type __pos, size_type __n1,
|
williamr@4
|
583 |
size_type __n2, _CharT __c) {
|
williamr@4
|
584 |
_Base::replace(__pos, __n1, __n2, __c);
|
williamr@4
|
585 |
return *this;
|
williamr@4
|
586 |
}
|
williamr@4
|
587 |
|
williamr@4
|
588 |
_Self& replace(iterator __first, iterator __last, const _Self& __s) {
|
williamr@4
|
589 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
590 |
_Base::replace(__first, __last, __s);
|
williamr@4
|
591 |
return *this;
|
williamr@4
|
592 |
}
|
williamr@4
|
593 |
|
williamr@4
|
594 |
_Self& replace(iterator __first, iterator __last,
|
williamr@4
|
595 |
const _CharT* __s, size_type __n) {
|
williamr@4
|
596 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
597 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
598 |
_Base::replace(__first, __last, __s, __n);
|
williamr@4
|
599 |
return *this;
|
williamr@4
|
600 |
}
|
williamr@4
|
601 |
|
williamr@4
|
602 |
_Self& replace(iterator __first, iterator __last,
|
williamr@4
|
603 |
const _CharT* __s) {
|
williamr@4
|
604 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
605 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@4
|
606 |
_Base::replace(__first, __last, __s);
|
williamr@4
|
607 |
return *this;
|
williamr@4
|
608 |
}
|
williamr@4
|
609 |
|
williamr@4
|
610 |
_Self& replace(iterator __first, iterator __last,
|
williamr@4
|
611 |
size_type __n, _CharT __c) {
|
williamr@4
|
612 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
613 |
_Base::replace(__first, __last, __n, __c);
|
williamr@4
|
614 |
return *this;
|
williamr@4
|
615 |
}
|
williamr@4
|
616 |
|
williamr@4
|
617 |
// Check to see if _InputIter is an integer type. If so, then
|
williamr@4
|
618 |
// it can't be an iterator.
|
williamr@4
|
619 |
template <class _InputIter>
|
williamr@4
|
620 |
_Self& replace(iterator __first, iterator __last,
|
williamr@4
|
621 |
_InputIter __f, _InputIter __l) {
|
williamr@4
|
622 |
_STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
623 |
typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
|
williamr@4
|
624 |
return _M_replace_dispatch(__first, __last, __f, __l, _Integral());
|
williamr@4
|
625 |
}
|
williamr@4
|
626 |
|
williamr@4
|
627 |
#if !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
|
williamr@4
|
628 |
_Self& replace(iterator __first, iterator __last,
|
williamr@4
|
629 |
const _CharT* __f, const _CharT* __l) {
|
williamr@4
|
630 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
631 |
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
williamr@4
|
632 |
_Base::replace(__first, __last, __f, __l);
|
williamr@4
|
633 |
return *this;
|
williamr@4
|
634 |
}
|
williamr@4
|
635 |
#endif
|
williamr@4
|
636 |
|
williamr@4
|
637 |
protected: // Helper functions for replace.
|
williamr@4
|
638 |
_Self& _M_replace(iterator __first, iterator __last,
|
williamr@4
|
639 |
const _CharT* __f, const _CharT* __l, bool __self_ref) {
|
williamr@4
|
640 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
641 |
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
williamr@4
|
642 |
_Base::_M_replace(__first, __last, __f, __l, __self_ref);
|
williamr@4
|
643 |
return *this;
|
williamr@4
|
644 |
}
|
williamr@4
|
645 |
|
williamr@4
|
646 |
template <class _Integer>
|
williamr@4
|
647 |
_Self& _M_replace_dispatch(iterator __first, iterator __last,
|
williamr@4
|
648 |
_Integer __n, _Integer __x, const __true_type& /*IsIntegral*/) {
|
williamr@4
|
649 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
650 |
return replace(__first, __last, (size_type) __n, (_CharT) __x);
|
williamr@4
|
651 |
}
|
williamr@4
|
652 |
|
williamr@4
|
653 |
template <class _InputIter>
|
williamr@4
|
654 |
_Self& _M_replace_dispatch(iterator __first, iterator __last,
|
williamr@4
|
655 |
_InputIter __f, _InputIter __l, const __false_type& /*IsIntegral*/) {
|
williamr@4
|
656 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
657 |
typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsIterator;
|
williamr@4
|
658 |
typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
|
williamr@4
|
659 |
typedef typename _Lor2<_IsIterator, _IsConstIterator>::_Ret _CheckInside;
|
williamr@4
|
660 |
return _M_replace_aux(__first, __last, __f, __l, _CheckInside());
|
williamr@4
|
661 |
}
|
williamr@4
|
662 |
|
williamr@4
|
663 |
template <class _RandomIter>
|
williamr@4
|
664 |
_Self& _M_replace_aux(iterator __first, iterator __last,
|
williamr@4
|
665 |
_RandomIter __f, _RandomIter __l, __true_type const& /*_CheckInside*/) {
|
williamr@4
|
666 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
667 |
return _M_replace(__first, __last, &(*__f), &(*__l), _Base::_M_inside(&(*__f)));
|
williamr@4
|
668 |
}
|
williamr@4
|
669 |
|
williamr@4
|
670 |
template <class _InputIter>
|
williamr@4
|
671 |
_Self& _M_replace_aux(iterator __first, iterator __last,
|
williamr@4
|
672 |
_InputIter __f, _InputIter __l, __false_type const& /*_CheckInside*/) {
|
williamr@4
|
673 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
674 |
return _M_replaceT(__first, __last, __f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
|
williamr@4
|
675 |
}
|
williamr@4
|
676 |
|
williamr@4
|
677 |
template <class _InputIter>
|
williamr@4
|
678 |
_Self& _M_replaceT(iterator __first, iterator __last,
|
williamr@4
|
679 |
_InputIter __f, _InputIter __l, const input_iterator_tag&__ite_tag) {
|
williamr@4
|
680 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
681 |
for ( ; __first != __last && __f != __l; ++__first, ++__f)
|
williamr@4
|
682 |
_Traits::assign(*__first, *__f);
|
williamr@4
|
683 |
if (__f == __l)
|
williamr@4
|
684 |
_Base::erase(__first, __last);
|
williamr@4
|
685 |
else
|
williamr@4
|
686 |
_M_insertT(__last, __f, __l, __ite_tag);
|
williamr@4
|
687 |
return *this;
|
williamr@4
|
688 |
}
|
williamr@4
|
689 |
|
williamr@4
|
690 |
template <class _ForwardIter>
|
williamr@4
|
691 |
_Self& _M_replaceT(iterator __first, iterator __last,
|
williamr@4
|
692 |
_ForwardIter __f, _ForwardIter __l, const forward_iterator_tag &__ite_tag) {
|
williamr@4
|
693 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@4
|
694 |
difference_type __n = distance(__f, __l);
|
williamr@4
|
695 |
const difference_type __len = __last - __first;
|
williamr@4
|
696 |
if (__len >= __n) {
|
williamr@4
|
697 |
_M_copyT(__f, __l, __first);
|
williamr@4
|
698 |
_Base::erase(__first + __n, __last);
|
williamr@4
|
699 |
}
|
williamr@4
|
700 |
else {
|
williamr@4
|
701 |
_ForwardIter __m = __f;
|
williamr@4
|
702 |
advance(__m, __len);
|
williamr@4
|
703 |
_M_copyT(__f, __m, __first);
|
williamr@4
|
704 |
_M_insertT(__last, __m, __l, __ite_tag);
|
williamr@4
|
705 |
}
|
williamr@4
|
706 |
return *this;
|
williamr@4
|
707 |
}
|
williamr@4
|
708 |
|
williamr@4
|
709 |
public: // Other modifier member functions.
|
williamr@4
|
710 |
|
williamr@4
|
711 |
void swap(_Self& __s)
|
williamr@4
|
712 |
{ _Base::swap(__s); }
|
williamr@4
|
713 |
|
williamr@4
|
714 |
public: // Substring.
|
williamr@4
|
715 |
|
williamr@4
|
716 |
_Self substr(size_type __pos = 0, size_type __n = npos) const
|
williamr@4
|
717 |
{ return _Self(*this, __pos, __n, get_allocator()); }
|
williamr@4
|
718 |
|
williamr@4
|
719 |
#if defined (_STLP_USE_TEMPLATE_EXPRESSION) && !defined (_STLP_DEBUG)
|
williamr@4
|
720 |
# define _STLP_STRING_SUM_BASE _STLP_NO_MEM_T_STRING_BASE
|
williamr@4
|
721 |
# include <stl/_string_sum_methods.h>
|
williamr@4
|
722 |
# undef _STLP_STRING_SUM_BASE
|
williamr@4
|
723 |
#endif
|
williamr@4
|
724 |
};
|
williamr@4
|
725 |
|
williamr@4
|
726 |
#undef _STLP_NO_MEM_T_STRING_BASE
|
williamr@4
|
727 |
|
williamr@4
|
728 |
#if defined (basic_string)
|
williamr@4
|
729 |
_STLP_MOVE_TO_STD_NAMESPACE
|
williamr@4
|
730 |
# undef basic_string
|
williamr@4
|
731 |
#endif
|
williamr@4
|
732 |
|
williamr@4
|
733 |
_STLP_END_NAMESPACE
|