2 * Copyright (c) 1997-1999
3 * Silicon Graphics Computer Systems, Inc.
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
18 #ifndef _STLP_DBG_STRING_H
19 #define _STLP_DBG_STRING_H
21 #ifndef _STLP_DBG_ITERATOR_H
22 # include <stl/debug/_iterator.h>
27 #define _STLP_NON_DBG_STRING_NAME _STLP_NON_DBG_NAME(str)
28 #define _STLP_NON_DBG_STRING _STLP_PRIV _STLP_NON_DBG_STRING_NAME <_CharT, _Traits, _Alloc>
30 #if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
31 template <class _CharT
,class _Traits
, class _Alloc
>
33 value_type(const _STLP_PRIV _DBG_iter_base
< _STLP_NON_DBG_STRING
>&)
34 { return (_CharT
*)0; }
35 template <class _CharT
, class _Traits
, class _Alloc
>
36 inline random_access_iterator_tag
37 iterator_category(const _STLP_PRIV _DBG_iter_base
< _STLP_NON_DBG_STRING
>&)
38 { return random_access_iterator_tag(); }
41 template <class _CharT
, class _Traits
, class _Alloc
>
43 #if !defined (__DMC__)
48 _STLP_PRIV __construct_checker
<_STLP_NON_DBG_STRING
>
49 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string)
50 , public __stlport_class
<basic_string
<_CharT
, _Traits
, _Alloc
> >
54 typedef _STLP_NON_DBG_STRING _Base
;
55 typedef basic_string
<_CharT
, _Traits
, _Alloc
> _Self
;
56 typedef _STLP_PRIV __construct_checker
<_STLP_NON_DBG_STRING
> _ConstructCheck
;
57 typedef typename _IsPOD
<_CharT
>::_Type _Char_Is_POD
;
60 __IMPORT_CONTAINER_TYPEDEFS(_Base
)
61 typedef typename
_Base::traits_type traits_type
;
62 typedef _STLP_PRIV _DBG_iter
<_Base
, _STLP_PRIV _DbgTraits
<_Nonconst_traits
<value_type
> > > iterator
;
63 typedef _STLP_PRIV _DBG_iter
<_Base
, _STLP_PRIV _DbgTraits
<_Const_traits
<value_type
> > > const_iterator
;
64 _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS
;
66 public: // Constructor, destructor, assignment.
67 typedef typename
_Base::_Reserve_t _Reserve_t
;
70 _Base _M_non_dbg_impl
;
71 _STLP_PRIV __owned_list _M_iter_list
;
73 void _Invalidate_all()
74 { _M_iter_list
._Invalidate_all(); }
75 void _Compare_Capacity (size_type __old_capacity
) {
76 if (this->capacity() > __old_capacity
) {
80 void _Invalidate_iterator(const iterator
& __it
)
81 { _STLP_PRIV
__invalidate_iterator(&_M_iter_list
, __it
); }
82 void _Invalidate_iterators(const iterator
& __f
, const iterator
& __l
)
83 { _STLP_PRIV
__invalidate_range(&_M_iter_list
, __f
, __l
); }
86 #include <stl/_string_npos.h>
88 allocator_type
get_allocator() const { return _M_non_dbg_impl
.get_allocator(); }
90 explicit basic_string(const allocator_type
& __a
= allocator_type())
91 : _M_non_dbg_impl(__a
), _M_iter_list(&_M_non_dbg_impl
) {}
93 basic_string(_Reserve_t __r
, size_t __n
,
94 const allocator_type
& __a
= allocator_type())
95 : _M_non_dbg_impl(__r
, __n
, __a
), _M_iter_list(&_M_non_dbg_impl
) {}
97 basic_string(const _Self
& __s
)
98 : _ConstructCheck(__s
),
99 _M_non_dbg_impl(__s
._M_non_dbg_impl
), _M_iter_list(&_M_non_dbg_impl
) {}
101 basic_string(const _Self
& __s
, size_type __pos
, size_type __n
= npos
,
102 const allocator_type
& __a
= allocator_type())
103 : _M_non_dbg_impl(__s
._M_non_dbg_impl
, __pos
, __n
, __a
),
104 _M_iter_list(&_M_non_dbg_impl
) {}
106 basic_string(const _CharT
* __s
, size_type __n
,
107 const allocator_type
& __a
= allocator_type())
108 : _ConstructCheck(__s
), _M_non_dbg_impl(__s
, __n
, __a
),
109 _M_iter_list(&_M_non_dbg_impl
) {}
111 basic_string(const _CharT
* __s
,
112 const allocator_type
& __a
= allocator_type())
113 : _ConstructCheck(__s
),
114 _M_non_dbg_impl(__s
, __a
), _M_iter_list(&_M_non_dbg_impl
) {}
116 basic_string(size_type __n
, _CharT __c
,
117 const allocator_type
& __a
= allocator_type())
118 : _M_non_dbg_impl(__n
, __c
, __a
), _M_iter_list(&_M_non_dbg_impl
) {}
120 #if !defined (_STLP_NO_MOVE_SEMANTIC)
121 basic_string(__move_source
<_Self
> src
)
122 : _M_non_dbg_impl(__move_source
<_Base
>(src
.get()._M_non_dbg_impl
)),
123 _M_iter_list(&_M_non_dbg_impl
) {
124 # if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
125 src
.get()._M_iter_list
._Invalidate_all();
127 src
.get()._M_iter_list
._Set_owner(_M_iter_list
);
132 #if !defined (_STLP_MEMBER_TEMPLATES)
133 basic_string(const _CharT
* __f
, const _CharT
* __l
,
134 const allocator_type
& __a
= allocator_type())
135 : _ConstructCheck(__f
, __l
),
136 _M_non_dbg_impl(__f
, __l
, __a
), _M_iter_list(&_M_non_dbg_impl
) {
138 basic_string(const_iterator __f
, const_iterator __l
,
139 const allocator_type
& __a
= allocator_type())
140 : _ConstructCheck(__f
, __l
),
141 _M_non_dbg_impl(__f
._M_iterator
, __l
._M_iterator
, __a
), _M_iter_list(&_M_non_dbg_impl
) {
144 template <class _InputIterator
>
145 basic_string(_InputIterator __f
, _InputIterator __l
,
146 const allocator_type
& __a _STLP_ALLOCATOR_TYPE_DFL
)
147 : _ConstructCheck(__f
, __l
),
148 _M_non_dbg_impl(_STLP_PRIV
_Non_Dbg_iter(__f
), _STLP_PRIV
_Non_Dbg_iter(__l
), __a
),
149 _M_iter_list(&_M_non_dbg_impl
) {}
150 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
151 template <class _InputIterator
>
152 basic_string(_InputIterator __f
, _InputIterator __l
)
153 : _ConstructCheck(__f
, __l
),
154 _M_non_dbg_impl(_STLP_PRIV
_Non_Dbg_iter(__f
), _STLP_PRIV
_Non_Dbg_iter(__l
)),
155 _M_iter_list(&_M_non_dbg_impl
) {}
160 // constructor from non-debug version for substr
161 basic_string (const _Base
& __x
)
162 : _M_non_dbg_impl(__x
), _M_iter_list(&_M_non_dbg_impl
) {}
165 _Self
& operator=(const _Self
& __s
) {
172 _Self
& operator=(const _CharT
* __s
) {
173 _STLP_FIX_LITERAL_BUG(__s
)
174 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
178 _Self
& operator=(_CharT __c
) {
179 return assign(1, __c
);
183 iterator
begin() { return iterator(&_M_iter_list
, _M_non_dbg_impl
.begin()); }
184 const_iterator
begin() const { return const_iterator(&_M_iter_list
, _M_non_dbg_impl
.begin()); }
185 iterator
end() { return iterator(&_M_iter_list
, _M_non_dbg_impl
.end()); }
186 const_iterator
end() const { return const_iterator(&_M_iter_list
, _M_non_dbg_impl
.end()); }
188 reverse_iterator
rbegin() { return reverse_iterator(end()); }
189 const_reverse_iterator
rbegin() const { return const_reverse_iterator(end()); }
190 reverse_iterator
rend() { return reverse_iterator(begin()); }
191 const_reverse_iterator
rend() const { return const_reverse_iterator(begin()); }
193 // Size, capacity, etc.
194 size_type
size() const { return _M_non_dbg_impl
.size(); }
195 size_type
length() const { return _M_non_dbg_impl
.length(); }
196 size_t max_size() const { return _M_non_dbg_impl
.max_size(); }
198 void resize(size_type __n
, _CharT __c
) {
199 if (__n
> capacity())
201 else if (__n
< size())
202 _Invalidate_iterators(begin() + __n
, end());
203 _M_non_dbg_impl
.resize(__n
, __c
);
205 void resize(size_type __n
) { resize(__n
, _STLP_DEFAULT_CONSTRUCTED(_CharT
)); }
206 size_type
capacity() const { return _M_non_dbg_impl
.capacity(); }
208 void reserve(size_type __s
= 0) {
209 if (__s
> capacity()) _Invalidate_all();
210 _M_non_dbg_impl
.reserve(__s
);
215 _M_non_dbg_impl
.clear();
218 bool empty() const { return _M_non_dbg_impl
.empty(); }
220 const_reference
operator[](size_type __n
) const {
221 _STLP_VERBOSE_ASSERT(__n
<= this->size(), _StlMsg_OUT_OF_BOUNDS
);
222 return _M_non_dbg_impl
[__n
];
225 reference
operator[](size_type __n
) {
226 _STLP_VERBOSE_ASSERT(__n
< this->size(), _StlMsg_OUT_OF_BOUNDS
)
227 return _M_non_dbg_impl
[__n
];
230 const_reference
at(size_type __n
) const { return _M_non_dbg_impl
.at(__n
); }
231 reference
at(size_type __n
) { return _M_non_dbg_impl
.at(__n
); }
233 // Append, operator+=, push_back.
234 _Self
& operator+=(const _Self
& __s
) { return append(__s
); }
235 _Self
& operator+=(const _CharT
* __s
) {
236 _STLP_FIX_LITERAL_BUG(__s
)
237 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
240 _Self
& operator+=(_CharT __c
) { return append(1, __c
); }
242 #if defined (_STLP_MEMBER_TEMPLATES)
243 template <class _InputIter
>
244 _Self
& append(_InputIter __first
, _InputIter __last
) {
245 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__first
, __last
))
246 size_type __old_capacity
= capacity();
247 _M_non_dbg_impl
.append(_STLP_PRIV
_Non_Dbg_iter(__first
), _STLP_PRIV
_Non_Dbg_iter(__last
));
248 _Compare_Capacity(__old_capacity
);
253 #if !defined (_STLP_MEMBER_TEMPLATES) || \
254 !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
255 _Self
& append(const _CharT
* __f
, const _CharT
* __l
) {
256 _STLP_FIX_LITERAL_BUG(__f
) _STLP_FIX_LITERAL_BUG(__l
)
257 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_ptr_range(__f
, __l
))
258 size_type __old_capacity
= capacity();
259 _M_non_dbg_impl
.append(__f
, __l
);
260 _Compare_Capacity(__old_capacity
);
264 _Self
& append(const_iterator __f
, const_iterator __l
) {
265 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
))
266 size_type __old_capacity
= capacity();
267 _M_non_dbg_impl
.append(__f
._M_iterator
, __l
._M_iterator
);
268 _Compare_Capacity(__old_capacity
);
273 _Self
& append(const _Self
& __s
) {
274 size_type __old_capacity
= capacity();
275 _M_non_dbg_impl
.append(__s
._M_non_dbg_impl
);
276 _Compare_Capacity(__old_capacity
);
280 _Self
& append(const _Self
& __s
, size_type __pos
, size_type __n
) {
281 size_type __old_capacity
= capacity();
282 _M_non_dbg_impl
.append(__s
._M_non_dbg_impl
, __pos
, __n
);
283 _Compare_Capacity(__old_capacity
);
287 _Self
& append(const _CharT
* __s
, size_type __n
) {
288 _STLP_FIX_LITERAL_BUG(__s
)
289 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
290 size_type __old_capacity
= capacity();
291 _M_non_dbg_impl
.append(__s
, __n
);
292 _Compare_Capacity(__old_capacity
);
296 _Self
& append(const _CharT
* __s
) {
297 _STLP_FIX_LITERAL_BUG(__s
)
298 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
299 size_type __old_capacity
= capacity();
300 _M_non_dbg_impl
.append(__s
);
301 _Compare_Capacity(__old_capacity
);
305 _Self
& append(size_type __n
, _CharT __c
) {
306 size_type __old_capacity
= this->capacity();
307 _M_non_dbg_impl
.append(__n
, __c
);
308 _Compare_Capacity(__old_capacity
);
312 void push_back(_CharT __c
) {
313 size_type __old_capacity
= this->capacity();
314 _M_non_dbg_impl
.push_back(__c
);
315 _Compare_Capacity(__old_capacity
);
319 _Invalidate_iterator(this->end());
320 _M_non_dbg_impl
.pop_back();
324 _Self
& assign(const _Self
& __s
) {
326 _M_non_dbg_impl
.assign(__s
._M_non_dbg_impl
);
330 _Self
& assign(const _Self
& __s
, size_type __pos
, size_type __n
) {
331 if (__pos
< __s
.size()) {
334 _M_non_dbg_impl
.assign(__s
._M_non_dbg_impl
, __pos
, __n
);
338 _Self
& assign(const _CharT
* __s
, size_type __n
) {
339 _STLP_FIX_LITERAL_BUG(__s
)
340 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
342 _M_non_dbg_impl
.assign(__s
, __s
+ __n
);
346 _Self
& assign(const _CharT
* __s
) {
347 _STLP_FIX_LITERAL_BUG(__s
)
348 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
350 _M_non_dbg_impl
.assign(__s
);
354 _Self
& assign(size_type __n
, _CharT __c
) {
356 _M_non_dbg_impl
.assign(__n
, __c
);
360 #if defined(_STLP_MEMBER_TEMPLATES)
361 template <class _InputIter
>
362 inline _Self
& assign(_InputIter __first
, _InputIter __last
) {
363 _STLP_FIX_LITERAL_BUG(__first
) _STLP_FIX_LITERAL_BUG(__last
)
364 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__first
, __last
))
366 _M_non_dbg_impl
.assign(_STLP_PRIV
_Non_Dbg_iter(__first
), _STLP_PRIV
_Non_Dbg_iter(__last
));
371 #if !defined (_STLP_MEMBER_TEMPLATES) || \
372 !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
373 _Self
& assign(const _CharT
* __f
, const _CharT
* __l
) {
374 _STLP_FIX_LITERAL_BUG(__f
) _STLP_FIX_LITERAL_BUG(__l
)
375 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_ptr_range(__f
, __l
))
377 _M_non_dbg_impl
.assign(__f
, __l
);
380 _Self
& assign(const_iterator __f
, const_iterator __l
) {
381 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
))
383 _M_non_dbg_impl
.assign(__f
._M_iterator
, __l
._M_iterator
);
389 _Self
& insert(size_type __pos
, const _Self
& __s
) {
390 size_type __old_capacity
= capacity();
391 _M_non_dbg_impl
.insert(__pos
, __s
._M_non_dbg_impl
);
392 _Compare_Capacity(__old_capacity
);
396 _Self
& insert(size_type __pos
, const _Self
& __s
,
397 size_type __beg
, size_type __n
) {
398 size_type __old_capacity
= capacity();
399 _M_non_dbg_impl
.insert(__pos
, __s
._M_non_dbg_impl
, __beg
, __n
);
400 _Compare_Capacity(__old_capacity
);
404 _Self
& insert(size_type __pos
, const _CharT
* __s
, size_type __n
) {
405 _STLP_FIX_LITERAL_BUG(__s
)
406 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
407 size_type __old_capacity
= capacity();
408 _M_non_dbg_impl
.insert(__pos
, __s
, __n
);
409 _Compare_Capacity(__old_capacity
);
413 _Self
& insert(size_type __pos
, const _CharT
* __s
) {
414 _STLP_FIX_LITERAL_BUG(__s
)
415 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
416 return insert(__pos
, __s
, _Traits::length(__s
));
419 _Self
& insert(size_type __pos
, size_type __n
, _CharT __c
) {
420 size_type __old_capacity
= capacity();
421 _M_non_dbg_impl
.insert(__pos
, __n
, __c
);
422 _Compare_Capacity(__old_capacity
);
426 iterator
insert(iterator __p
, _CharT __c
) {
427 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_if_owner(&_M_iter_list
,__p
))
428 size_type __old_capacity
= capacity();
429 typename
_Base::iterator __ret
= _M_non_dbg_impl
.insert(__p
._M_iterator
, __c
);
430 _Compare_Capacity(__old_capacity
);
431 return iterator(&_M_iter_list
, __ret
);
434 void insert(iterator __p
, size_t __n
, _CharT __c
) {
435 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_if_owner(&_M_iter_list
,__p
))
436 size_type __old_capacity
= capacity();
437 _M_non_dbg_impl
.insert(__p
._M_iterator
, __n
, __c
);
438 _Compare_Capacity(__old_capacity
);
441 #if defined (_STLP_MEMBER_TEMPLATES)
442 template <class _InputIter
>
443 void insert(iterator __p
, _InputIter __first
, _InputIter __last
) {
444 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_if_owner(&_M_iter_list
,__p
))
445 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__first
,__last
))
447 size_type __old_capacity
= this->capacity();
448 _M_non_dbg_impl
.insert(__p
._M_iterator
,
449 _STLP_PRIV
_Non_Dbg_iter(__first
), _STLP_PRIV
_Non_Dbg_iter(__last
));
450 _Compare_Capacity(__old_capacity
);
454 #if !defined (_STLP_MEMBER_TEMPLATES)
455 void insert(iterator __p
, const _CharT
* __f
, const _CharT
* __l
) {
456 _STLP_FIX_LITERAL_BUG(__f
)_STLP_FIX_LITERAL_BUG(__l
)
457 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_if_owner(&_M_iter_list
,__p
))
458 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_ptr_range(__f
,__l
))
459 size_type __old_capacity
= capacity();
460 _M_non_dbg_impl
.insert(__p
._M_iterator
, __f
, __l
);
461 _Compare_Capacity(__old_capacity
);
465 #if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
466 // Those overloads are necessary to check self referencing correctly in non debug
467 // basic_string implementation
468 void insert(iterator __p
, const_iterator __f
, const_iterator __l
) {
469 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_if_owner(&_M_iter_list
,__p
))
470 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
,__l
))
471 # if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
472 _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list
, __f
))
474 size_type __old_capacity
= capacity();
475 _M_non_dbg_impl
.insert(__p
._M_iterator
, __f
._M_iterator
, __l
._M_iterator
);
476 _Compare_Capacity(__old_capacity
);
478 void insert(iterator __p
, iterator __f
, iterator __l
) {
479 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_if_owner(&_M_iter_list
,__p
))
480 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
,__l
))
481 # if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
482 _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list
, __f
))
484 size_type __old_capacity
= capacity();
485 _M_non_dbg_impl
.insert(__p
._M_iterator
, __f
._M_iterator
, __l
._M_iterator
);
486 _Compare_Capacity(__old_capacity
);
491 _Self
& erase(size_type __pos
= 0, size_type __n
= npos
) {
492 if (__pos
< size()) {
493 _Invalidate_iterators(begin() + __pos
, end());
495 _M_non_dbg_impl
.erase(__pos
, __n
);
498 iterator
erase(iterator __pos
) {
499 _STLP_DEBUG_CHECK(_STLP_PRIV
_Dereferenceable(__pos
))
500 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_if_owner(&_M_iter_list
,__pos
))
501 _Invalidate_iterators(__pos
, end());
502 return iterator(&_M_iter_list
, _M_non_dbg_impl
.erase(__pos
._M_iterator
));
504 iterator
erase(iterator __f
, iterator __l
) {
505 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
, begin(), end()))
506 _Invalidate_iterators(__f
, end());
507 return iterator(&_M_iter_list
, _M_non_dbg_impl
.erase(__f
._M_iterator
, __l
._M_iterator
));
511 _Self
substr(size_type __pos
= 0, size_type __n
= npos
) const
512 { return _M_non_dbg_impl
.substr(__pos
, __n
); }
514 // Replace. (Conceptually equivalent to erase followed by insert.)
515 _Self
& replace(size_type __pos
, size_type __n
, const _Self
& __s
) {
516 size_type __old_capacity
= capacity();
517 _M_non_dbg_impl
.replace(__pos
, __n
, __s
._M_non_dbg_impl
);
518 _Compare_Capacity(__old_capacity
);
522 _Self
& replace(size_type __pos1
, size_type __n1
, const _Self
& __s
,
523 size_type __pos2
, size_type __n2
) {
524 size_type __old_capacity
= capacity();
525 _M_non_dbg_impl
.replace(__pos1
, __n1
, __s
._M_non_dbg_impl
, __pos2
, __n2
);
526 _Compare_Capacity(__old_capacity
);
530 _Self
& replace(size_type __pos
, size_type __n1
, const _CharT
* __s
, size_type __n2
) {
531 _STLP_FIX_LITERAL_BUG(__s
)
532 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
533 size_type __old_capacity
= capacity();
534 _M_non_dbg_impl
.replace(__pos
, __n1
, __s
, __n2
);
535 _Compare_Capacity(__old_capacity
);
539 _Self
& replace(size_type __pos
, size_type __n1
, const _CharT
* __s
) {
540 _STLP_FIX_LITERAL_BUG(__s
)
541 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
542 size_type __old_capacity
= capacity();
543 _M_non_dbg_impl
.replace(__pos
, __n1
, __s
);
544 _Compare_Capacity(__old_capacity
);
548 _Self
& replace(size_type __pos
, size_type __n1
, size_type __n2
, _CharT __c
) {
549 size_type __old_capacity
= capacity();
550 _M_non_dbg_impl
.replace(__pos
, __n1
, __n2
, __c
);
551 _Compare_Capacity(__old_capacity
);
555 _Self
& replace(iterator __f
, iterator __l
, const _Self
& __s
) {
556 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
, begin(), end()))
557 size_type __old_capacity
= capacity();
558 _M_non_dbg_impl
.replace(__f
._M_iterator
, __l
._M_iterator
, __s
._M_non_dbg_impl
);
559 _Compare_Capacity(__old_capacity
);
563 _Self
& replace(iterator __f
, iterator __l
, const _CharT
* __s
, size_type __n
) {
564 _STLP_FIX_LITERAL_BUG(__s
)
565 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
, begin(), end()))
566 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
567 size_type __old_capacity
= capacity();
568 _M_non_dbg_impl
.replace(__f
._M_iterator
, __l
._M_iterator
, __s
, __n
);
569 _Compare_Capacity(__old_capacity
);
573 _Self
& replace(iterator __f
, iterator __l
, const _CharT
* __s
) {
574 _STLP_FIX_LITERAL_BUG(__s
)
575 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
, begin(), end()))
576 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
577 size_type __old_capacity
= capacity();
578 _M_non_dbg_impl
.replace(__f
._M_iterator
, __l
._M_iterator
, __s
);
579 _Compare_Capacity(__old_capacity
);
583 _Self
& replace(iterator __f
, iterator __l
, size_type __n
, _CharT __c
) {
584 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
, begin(), end()))
585 size_type __old_capacity
= capacity();
586 _M_non_dbg_impl
.replace(__f
._M_iterator
, __l
._M_iterator
, __n
, __c
);
587 _Compare_Capacity(__old_capacity
);
591 #if defined (_STLP_MEMBER_TEMPLATES)
592 template <class _InputIter
>
593 _Self
& replace(iterator __first
, iterator __last
,
594 _InputIter __f
, _InputIter __l
) {
595 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__first
, __last
, begin(), end()))
596 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
))
598 size_type __old_capacity
= capacity();
599 _M_non_dbg_impl
.replace(__first
._M_iterator
, __last
._M_iterator
,
600 _STLP_PRIV
_Non_Dbg_iter(__f
), _STLP_PRIV
_Non_Dbg_iter(__l
));
601 _Compare_Capacity(__old_capacity
);
606 #if !defined (_STLP_MEMBER_TEMPLATES)
607 _Self
& replace(iterator __first
, iterator __last
,
608 const _CharT
* __f
, const _CharT
* __l
) {
609 _STLP_FIX_LITERAL_BUG(__f
)_STLP_FIX_LITERAL_BUG(__l
)
610 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__first
, __last
, begin(), end()))
611 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_ptr_range(__f
, __l
))
612 size_type __old_capacity
= capacity();
613 _M_non_dbg_impl
.replace(__first
._M_iterator
, __last
._M_iterator
, __f
, __l
);
614 _Compare_Capacity(__old_capacity
);
619 #if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
620 _Self
& replace(iterator __first
, iterator __last
,
621 const_iterator __f
, const_iterator __l
) {
622 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__first
, __last
, begin(), end()))
623 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
))
624 size_type __old_capacity
= capacity();
625 _M_non_dbg_impl
.replace(__first
._M_iterator
, __last
._M_iterator
,
626 __f
._M_iterator
, __l
._M_iterator
);
627 _Compare_Capacity(__old_capacity
);
630 _Self
& replace(iterator __first
, iterator __last
,
631 iterator __f
, iterator __l
) {
632 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__first
, __last
, begin(), end()))
633 _STLP_DEBUG_CHECK(_STLP_PRIV
__check_range(__f
, __l
))
634 size_type __old_capacity
= capacity();
635 _M_non_dbg_impl
.replace(__first
._M_iterator
, __last
._M_iterator
,
636 __f
._M_iterator
, __l
._M_iterator
);
637 _Compare_Capacity(__old_capacity
);
642 // Other modifier member functions.
643 void swap(_Self
& __s
) {
644 _M_iter_list
._Swap_owners(__s
._M_iter_list
);
645 _M_non_dbg_impl
.swap(__s
._M_non_dbg_impl
);
647 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
648 void _M_swap_workaround(_Self
& __x
) { swap(__x
); }
651 int compare(const _Self
& __s
) const
652 { return _M_non_dbg_impl
.compare(__s
._M_non_dbg_impl
); }
653 int compare(size_type __pos
, size_type __n
, const _Self
& __s
) const
654 { return _M_non_dbg_impl
.compare(__pos
, __n
, __s
._M_non_dbg_impl
); }
655 int compare(size_type __pos1
, size_type __n1
, const _Self
& __s
,
656 size_type __pos2
, size_type __n2
) const
657 { return _M_non_dbg_impl
.compare(__pos1
, __n1
, __s
._M_non_dbg_impl
, __pos2
, __n2
); }
658 int compare(const _CharT
* __s
) const {
659 _STLP_FIX_LITERAL_BUG(__s
)
660 return _M_non_dbg_impl
.compare(__s
);
662 int compare(size_type __pos
, size_type __n
, const _CharT
* __s
) const {
663 _STLP_FIX_LITERAL_BUG(__s
)
664 return _M_non_dbg_impl
.compare(__pos
, __n
, __s
);
666 int compare(size_type __pos1
, size_type __n1
, const _CharT
* __s
,
667 size_type __n2
) const {
668 _STLP_FIX_LITERAL_BUG(__s
)
669 return _M_non_dbg_impl
.compare(__pos1
, __n1
, __s
, __n2
);
672 // Helper functions for compare.
673 static int _STLP_CALL
_M_compare(const _CharT
* __f1
, const _CharT
* __l1
,
674 const _CharT
* __f2
, const _CharT
* __l2
)
675 { return _Base::_M_compare(__f1
, __l1
, __f2
, __l2
); }
676 static int _STLP_CALL
_M_compare(const_iterator __f1
, const_iterator __l1
,
677 const _CharT
* __f2
, const _CharT
* __l2
)
678 { return _Base::_M_compare(__f1
._M_iterator
, __l1
._M_iterator
, __f2
, __l2
); }
679 static int _STLP_CALL
_M_compare(const _CharT
* __f1
, const _CharT
* __l1
,
680 const_iterator __f2
, const_iterator __l2
)
681 { return _Base::_M_compare(__f1
, __l1
, __f2
._M_iterator
, __l2
._M_iterator
); }
682 static int _STLP_CALL
_M_compare(const_iterator __f1
, const_iterator __l1
,
683 const_iterator __f2
, const_iterator __l2
)
684 { return _Base::_M_compare(__f1
._M_iterator
, __l1
._M_iterator
, __f2
._M_iterator
, __l2
._M_iterator
); }
686 const _CharT
* c_str() const { return _M_non_dbg_impl
.c_str(); }
687 const _CharT
* data() const { return _M_non_dbg_impl
.data(); }
689 size_type
copy(_CharT
* __s
, size_type __n
, size_type __pos
= 0) const
690 { return _M_non_dbg_impl
.copy(__s
, __n
, __pos
); }
693 size_type
find(const _Self
& __s
, size_type __pos
= 0) const
694 { return _M_non_dbg_impl
.find(__s
._M_non_dbg_impl
, __pos
); }
695 size_type
find(const _CharT
* __s
, size_type __pos
= 0) const {
696 _STLP_FIX_LITERAL_BUG(__s
)
697 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
698 return _M_non_dbg_impl
.find(__s
, __pos
);
700 size_type
find(const _CharT
* __s
, size_type __pos
, size_type __n
) const {
701 _STLP_FIX_LITERAL_BUG(__s
)
702 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
703 return _M_non_dbg_impl
.find(__s
, __pos
, __n
);
705 // WIE: Versant schema compiler 5.2.2 ICE workaround
706 size_type
find(_CharT __c
) const { return find(__c
, 0); }
707 size_type
find(_CharT __c
, size_type __pos
/* = 0 */) const
708 { return _M_non_dbg_impl
.find(__c
, __pos
); }
711 size_type
rfind(const _Self
& __s
, size_type __pos
= npos
) const
712 { return _M_non_dbg_impl
.rfind(__s
._M_non_dbg_impl
, __pos
); }
713 size_type
rfind(const _CharT
* __s
, size_type __pos
= npos
) const {
714 _STLP_FIX_LITERAL_BUG(__s
)
715 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
716 return _M_non_dbg_impl
.rfind(__s
, __pos
);
718 size_type
rfind(const _CharT
* __s
, size_type __pos
, size_type __n
) const {
719 _STLP_FIX_LITERAL_BUG(__s
)
720 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
721 return _M_non_dbg_impl
.rfind(__s
, __pos
, __n
);
723 size_type
rfind(_CharT __c
, size_type __pos
= npos
) const
724 { return _M_non_dbg_impl
.rfind(__c
, __pos
); }
727 size_type
find_first_of(const _Self
& __s
, size_type __pos
= 0) const
728 { return _M_non_dbg_impl
.find_first_of(__s
._M_non_dbg_impl
, __pos
); }
729 size_type
find_first_of(const _CharT
* __s
, size_type __pos
= 0) const {
730 _STLP_FIX_LITERAL_BUG(__s
)
731 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
732 return _M_non_dbg_impl
.find_first_of(__s
, __pos
);
734 size_type
find_first_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const {
735 _STLP_FIX_LITERAL_BUG(__s
)
736 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
737 return _M_non_dbg_impl
.find_first_of(__s
, __pos
, __n
);
739 size_type
find_first_of(_CharT __c
, size_type __pos
= 0) const
740 { return _M_non_dbg_impl
.find_first_of(__c
, __pos
); }
743 size_type
find_last_of(const _Self
& __s
, size_type __pos
= npos
) const
744 { return _M_non_dbg_impl
.find_last_of(__s
._M_non_dbg_impl
, __pos
); }
745 size_type
find_last_of(const _CharT
* __s
, size_type __pos
= npos
) const {
746 _STLP_FIX_LITERAL_BUG(__s
)
747 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
748 return _M_non_dbg_impl
.find_last_of(__s
, __pos
);
750 size_type
find_last_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const {
751 _STLP_FIX_LITERAL_BUG(__s
)
752 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
753 return _M_non_dbg_impl
.find_last_of(__s
, __pos
, __n
);
755 size_type
find_last_of(_CharT __c
, size_type __pos
= npos
) const
756 { return _M_non_dbg_impl
.rfind(__c
, __pos
); }
759 size_type
find_first_not_of(const _Self
& __s
, size_type __pos
= 0) const
760 { return _M_non_dbg_impl
.find_first_not_of(__s
._M_non_dbg_impl
, __pos
); }
761 size_type
find_first_not_of(const _CharT
* __s
, size_type __pos
= 0) const {
762 _STLP_FIX_LITERAL_BUG(__s
)
763 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
764 return _M_non_dbg_impl
.find_first_not_of(__s
, __pos
);
766 size_type
find_first_not_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const {
767 _STLP_FIX_LITERAL_BUG(__s
)
768 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
769 return _M_non_dbg_impl
.find_first_not_of(__s
, __pos
, __n
);
771 size_type
find_first_not_of(_CharT __c
, size_type __pos
= 0) const
772 { return _M_non_dbg_impl
.find_first_not_of(__c
, __pos
); }
775 size_type
find_last_not_of(const _Self
& __s
, size_type __pos
= npos
) const
776 { return _M_non_dbg_impl
.find_last_not_of(__s
._M_non_dbg_impl
, __pos
); }
777 size_type
find_last_not_of(const _CharT
* __s
, size_type __pos
= npos
) const {
778 _STLP_FIX_LITERAL_BUG(__s
)
779 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
780 return _M_non_dbg_impl
.find_last_not_of(__s
, __pos
);
782 size_type
find_last_not_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const {
783 _STLP_FIX_LITERAL_BUG(__s
)
784 _STLP_VERBOSE_ASSERT((__s
!= 0), _StlMsg_INVALID_ARGUMENT
)
785 return _M_non_dbg_impl
.find_last_not_of(__s
, __pos
, __n
);
787 size_type
find_last_not_of(_CharT __c
, size_type __pos
= npos
) const
788 { return _M_non_dbg_impl
.find_last_not_of(__c
, __pos
); }
790 #if defined (_STLP_USE_TEMPLATE_EXPRESSION)
791 # include <stl/debug/_string_sum_methods.h>
795 // This is a hook to instantiate STLport exports in a designated DLL
796 #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
797 _STLP_MOVE_TO_PRIV_NAMESPACE
798 _STLP_EXPORT_TEMPLATE_CLASS __construct_checker
<_STLP_NON_DBG_STRING_NAME
<char, char_traits
<char>, allocator
<char> > >;
799 _STLP_MOVE_TO_STD_NAMESPACE
800 _STLP_EXPORT_TEMPLATE_CLASS basic_string
<char, char_traits
<char>, allocator
<char> >;
801 # if defined (_STLP_HAS_WCHAR_T)
802 _STLP_MOVE_TO_PRIV_NAMESPACE
803 _STLP_EXPORT_TEMPLATE_CLASS __construct_checker
<_STLP_NON_DBG_STRING_NAME
<wchar_t, char_traits
<wchar_t>, allocator
<wchar_t> > >;
804 _STLP_MOVE_TO_STD_NAMESPACE
805 _STLP_EXPORT_TEMPLATE_CLASS basic_string
<wchar_t, char_traits
<wchar_t>, allocator
<wchar_t> >;
809 #undef _STLP_NON_DBG_STRING
810 #undef _STLP_NON_DBG_STRING_NAME
812 #if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)
813 template <class _CharT
, class _Traits
, class _Alloc
>
814 const size_t basic_string
<_CharT
, _Traits
, _Alloc
>::npos
= ~(size_t) 0;
817 #if defined (basic_string)
818 _STLP_MOVE_TO_STD_NAMESPACE
824 #endif /* _STLP_DBG_STRING */