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 _STLP_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 _STLP_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 basic_string(__move_source<_Self> src)
121 : _M_non_dbg_impl(__move_source<_Base >(src.get()._M_non_dbg_impl)),
122 _M_iter_list(&_M_non_dbg_impl) {
123 #if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
124 src.get()._M_iter_list._Invalidate_all();
126 src.get()._M_iter_list._Set_owner(_M_iter_list);
130 #if !defined (_STLP_MEMBER_TEMPLATES) || defined(__MRC__) || defined(__SC__)
131 basic_string(const _CharT* __f, const _CharT* __l,
132 const allocator_type& __a = allocator_type())
133 : _ConstructCheck(__f, __l),
134 _M_non_dbg_impl(__f, __l, __a), _M_iter_list(&_M_non_dbg_impl) {
136 basic_string(const_iterator __f, const_iterator __l,
137 const allocator_type & __a = allocator_type())
138 : _ConstructCheck(__f, __l),
139 _M_non_dbg_impl(__f._M_iterator, __l._M_iterator, __a), _M_iter_list(&_M_non_dbg_impl) {
142 template <class _InputIterator>
143 basic_string(_InputIterator __f, _InputIterator __l,
144 const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)
145 : _ConstructCheck(__f, __l),
146 _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l), __a),
147 _M_iter_list(&_M_non_dbg_impl) {}
148 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
149 template <class _InputIterator>
150 basic_string(_InputIterator __f, _InputIterator __l)
151 : _ConstructCheck(__f, __l),
152 _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l)),
153 _M_iter_list(&_M_non_dbg_impl) {}
158 // constructor from non-debug version for substr
159 basic_string (const _Base& __x)
160 : _M_non_dbg_impl(__x), _M_iter_list(&_M_non_dbg_impl) {}
163 _Self& operator=(const _Self& __s) {
170 _Self& operator=(const _CharT* __s) {
171 _STLP_FIX_LITERAL_BUG(__s)
172 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
176 _Self& operator=(_CharT __c) {
177 return assign(1, __c);
181 iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
182 const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
183 iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
184 const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
186 reverse_iterator rbegin() { return reverse_iterator(end()); }
187 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
188 reverse_iterator rend() { return reverse_iterator(begin()); }
189 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
191 // Size, capacity, etc.
192 size_type size() const { return _M_non_dbg_impl.size(); }
193 size_type length() const { return _M_non_dbg_impl.length(); }
194 size_t max_size() const { return _M_non_dbg_impl.max_size(); }
196 void resize(size_type __n, _CharT __c) {
197 if (__n > capacity())
199 else if (__n < size())
200 _Invalidate_iterators(begin() + __n, end());
201 _M_non_dbg_impl.resize(__n, __c);
203 void resize(size_type __n) { resize(__n, _STLP_DEFAULT_CONSTRUCTED(_CharT)); }
204 size_type capacity() const { return _M_non_dbg_impl.capacity(); }
206 void reserve(size_type __s = 0) {
207 if (__s > capacity()) _Invalidate_all();
208 _M_non_dbg_impl.reserve(__s);
213 _M_non_dbg_impl.clear();
216 bool empty() const { return _M_non_dbg_impl.empty(); }
218 const_reference operator[](size_type __n) const {
219 _STLP_VERBOSE_ASSERT(__n <= this->size(), _StlMsg_OUT_OF_BOUNDS);
220 return _M_non_dbg_impl[__n];
223 reference operator[](size_type __n) {
224 _STLP_VERBOSE_ASSERT(__n < this->size(), _StlMsg_OUT_OF_BOUNDS)
225 return _M_non_dbg_impl[__n];
228 const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); }
229 reference at(size_type __n) { return _M_non_dbg_impl.at(__n); }
231 // Append, operator+=, push_back.
232 _Self& operator+=(const _Self& __s) { return append(__s); }
233 _Self& operator+=(const _CharT* __s) {
234 _STLP_FIX_LITERAL_BUG(__s)
235 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
238 _Self& operator+=(_CharT __c) { return append(1, __c); }
240 #if defined (_STLP_MEMBER_TEMPLATES)
241 template <class _InputIter>
242 _Self& append(_InputIter __first, _InputIter __last) {
243 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
244 size_type __old_capacity = capacity();
245 _M_non_dbg_impl.append(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
246 _Compare_Capacity(__old_capacity);
251 #if !defined (_STLP_MEMBER_TEMPLATES) || \
252 !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
253 _Self& append(const _CharT* __f, const _CharT* __l) {
254 _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
255 _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
256 size_type __old_capacity = capacity();
257 _M_non_dbg_impl.append(__f, __l);
258 _Compare_Capacity(__old_capacity);
262 _Self& append(const_iterator __f, const_iterator __l) {
263 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
264 size_type __old_capacity = capacity();
265 _M_non_dbg_impl.append(__f._M_iterator, __l._M_iterator);
266 _Compare_Capacity(__old_capacity);
271 _Self& append(const _Self& __s) {
272 size_type __old_capacity = capacity();
273 _M_non_dbg_impl.append(__s._M_non_dbg_impl);
274 _Compare_Capacity(__old_capacity);
278 _Self& append(const _Self& __s, size_type __pos, size_type __n) {
279 size_type __old_capacity = capacity();
280 _M_non_dbg_impl.append(__s._M_non_dbg_impl, __pos, __n);
281 _Compare_Capacity(__old_capacity);
285 _Self& append(const _CharT* __s, size_type __n) {
286 _STLP_FIX_LITERAL_BUG(__s)
287 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
288 size_type __old_capacity = capacity();
289 _M_non_dbg_impl.append(__s, __n);
290 _Compare_Capacity(__old_capacity);
294 _Self& append(const _CharT* __s) {
295 _STLP_FIX_LITERAL_BUG(__s)
296 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
297 size_type __old_capacity = capacity();
298 _M_non_dbg_impl.append(__s);
299 _Compare_Capacity(__old_capacity);
303 _Self& append(size_type __n, _CharT __c) {
304 size_type __old_capacity = this->capacity();
305 _M_non_dbg_impl.append(__n, __c);
306 _Compare_Capacity(__old_capacity);
310 void push_back(_CharT __c) {
311 size_type __old_capacity = this->capacity();
312 _M_non_dbg_impl.push_back(__c);
313 _Compare_Capacity(__old_capacity);
317 _Invalidate_iterator(this->end());
318 _M_non_dbg_impl.pop_back();
323 void _M_check_assign(size_type __n) {
324 if (__n > capacity()) {
327 else if (__n < size()) {
328 _Invalidate_iterators(begin() + __n, end());
333 _Self& assign(const _Self& __s) {
334 _M_check_assign(__s.size());
335 _M_non_dbg_impl.assign(__s._M_non_dbg_impl);
339 _Self& assign(const _Self& __s, size_type __pos, size_type __n) {
340 if (__pos < __s.size()) {
341 _M_check_assign((min) (__n, __s.size() - __pos));
343 _M_non_dbg_impl.assign(__s._M_non_dbg_impl, __pos, __n);
347 _Self& assign(const _CharT* __s, size_type __n) {
348 _STLP_FIX_LITERAL_BUG(__s)
349 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
350 _M_check_assign((min) (_Traits::length(__s), __n));
351 _M_non_dbg_impl.assign(__s, __s + __n);
355 _Self& assign(const _CharT* __s) {
356 _STLP_FIX_LITERAL_BUG(__s)
357 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
358 _M_check_assign(_Traits::length(__s));
359 _M_non_dbg_impl.assign(__s);
363 _Self& assign(size_type __n, _CharT __c) {
364 _M_check_assign(__n);
365 _M_non_dbg_impl.assign(__n, __c);
369 #if defined(_STLP_MEMBER_TEMPLATES)
371 template <class _Integer>
372 void _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) {
373 _M_check_assign(__n);
374 _M_non_dbg_impl.assign((size_type)__n, (_CharT)__x);
377 template <class _InputIter>
378 void _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {
379 _M_check_assign(distance(__f, __l));
380 _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
383 template <class _InputIter>
384 inline _Self& assign(_InputIter __first, _InputIter __last) {
385 _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
386 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
387 typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
388 _M_assign_dispatch(__first, __last, _Integral());
393 #if !defined (_STLP_MEMBER_TEMPLATES) || \
394 !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
395 _Self& assign(const _CharT* __f, const _CharT* __l) {
396 _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
397 _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
398 _M_check_assign(distance(__f, __l));
399 _M_non_dbg_impl.assign(__f, __l);
402 _Self& assign(const_iterator __f, const_iterator __l) {
403 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
404 _M_check_assign(distance(__f, __l));
405 _M_non_dbg_impl.assign(__f._M_iterator, __l._M_iterator);
411 _Self& insert(size_type __pos, const _Self& __s) {
412 size_type __old_capacity = capacity();
413 _M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl);
414 _Compare_Capacity(__old_capacity);
418 _Self& insert(size_type __pos, const _Self& __s,
419 size_type __beg, size_type __n) {
420 size_type __old_capacity = capacity();
421 _M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl, __beg, __n);
422 _Compare_Capacity(__old_capacity);
426 _Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
427 _STLP_FIX_LITERAL_BUG(__s)
428 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
429 size_type __old_capacity = capacity();
430 _M_non_dbg_impl.insert(__pos, __s, __n);
431 _Compare_Capacity(__old_capacity);
435 _Self& insert(size_type __pos, const _CharT* __s) {
436 _STLP_FIX_LITERAL_BUG(__s)
437 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
438 return insert(__pos, __s, _Traits::length(__s));
441 _Self& insert(size_type __pos, size_type __n, _CharT __c) {
442 size_type __old_capacity = capacity();
443 _M_non_dbg_impl.insert(__pos, __n, __c);
444 _Compare_Capacity(__old_capacity);
448 iterator insert(iterator __p, _CharT __c) {
449 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
450 size_type __old_capacity = capacity();
451 typename _Base::iterator __ret = _M_non_dbg_impl.insert(__p._M_iterator, __c);
452 _Compare_Capacity(__old_capacity);
453 return iterator(&_M_iter_list, __ret);
456 void insert(iterator __p, size_t __n, _CharT __c) {
457 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
458 size_type __old_capacity = capacity();
459 _M_non_dbg_impl.insert(__p._M_iterator, __n, __c);
460 _Compare_Capacity(__old_capacity);
463 #if defined (_STLP_MEMBER_TEMPLATES)
465 template <class _RandomIter>
466 void _M_insert_aux (iterator __p, _RandomIter __first, _RandomIter __last,
467 const __true_type& /*_IsIterator*/)
468 { _M_non_dbg_impl.insert(__p._M_iterator, __first._M_iterator, __last._M_iterator); }
470 template<class _InputIter>
471 void _M_insert_aux (iterator __p, _InputIter __first, _InputIter __last,
472 const __false_type& /*_IsIterator*/) {
473 _M_non_dbg_impl.insert(__p._M_iterator,
474 _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
478 template <class _InputIter>
479 void insert(iterator __p, _InputIter __first, _InputIter __last) {
480 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
481 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
483 /* In debug mode we are encapsulating non debug string iterators in debug one.
484 * Doing so the non debug implementation will not check for self insertion
485 * (x.insert(x.begin(), x.begin(), x.end()). To avoid this problem we try to
486 * guess when _InputIter is iterator or const_iterator and in this case call
487 * the non debug insert method with non debug string iterator.
489 typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsNonConstIterator;
490 typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
491 typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _IsIterator;
493 size_type __old_capacity = this->capacity();
494 _M_insert_aux(__p, __first, __last, _IsIterator());
495 _Compare_Capacity(__old_capacity);
499 #if !defined (_STLP_MEMBER_TEMPLATES) || \
500 !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
501 void insert(iterator __p, const_iterator __f, const_iterator __l) {
502 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
503 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f,__l))
504 size_type __old_capacity = capacity();
505 _M_non_dbg_impl.insert(__p._M_iterator, __f._M_iterator, __l._M_iterator);
506 _Compare_Capacity(__old_capacity);
508 void insert(iterator __p, const _CharT* __f, const _CharT* __l) {
509 _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
510 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
511 _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f,__l))
512 size_type __old_capacity = capacity();
513 _M_non_dbg_impl.insert(__p._M_iterator, __f, __l);
514 _Compare_Capacity(__old_capacity);
519 _Self& erase(size_type __pos = 0, size_type __n = npos) {
520 if (__pos < size()) {
521 _Invalidate_iterators(begin() + __pos, end());
523 _M_non_dbg_impl.erase(__pos, __n);
526 iterator erase(iterator __pos) {
527 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
528 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
529 _Invalidate_iterators(__pos, end());
530 return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
532 iterator erase(iterator __f, iterator __l) {
533 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
534 _Invalidate_iterators(__f, end());
535 return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__f._M_iterator, __l._M_iterator));
539 _Self substr(size_type __pos = 0, size_type __n = npos) const
540 { return _M_non_dbg_impl.substr(__pos, __n); }
542 // Replace. (Conceptually equivalent to erase followed by insert.)
543 _Self& replace(size_type __pos, size_type __n, const _Self& __s) {
544 size_type __old_capacity = capacity();
545 _M_non_dbg_impl.replace(__pos, __n, __s._M_non_dbg_impl);
546 _Compare_Capacity(__old_capacity);
550 _Self& replace(size_type __pos1, size_type __n1, const _Self& __s,
551 size_type __pos2, size_type __n2) {
552 size_type __old_capacity = capacity();
553 _M_non_dbg_impl.replace(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2);
554 _Compare_Capacity(__old_capacity);
558 _Self& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) {
559 _STLP_FIX_LITERAL_BUG(__s)
560 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
561 size_type __old_capacity = capacity();
562 _M_non_dbg_impl.replace(__pos, __n1, __s, __n2);
563 _Compare_Capacity(__old_capacity);
567 _Self& replace(size_type __pos, size_type __n1, const _CharT* __s) {
568 _STLP_FIX_LITERAL_BUG(__s)
569 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
570 size_type __old_capacity = capacity();
571 _M_non_dbg_impl.replace(__pos, __n1, __s);
572 _Compare_Capacity(__old_capacity);
576 _Self& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) {
577 size_type __old_capacity = capacity();
578 _M_non_dbg_impl.replace(__pos, __n1, __n2, __c);
579 _Compare_Capacity(__old_capacity);
583 _Self& replace(iterator __f, iterator __l, const _Self& __s) {
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, __s._M_non_dbg_impl);
587 _Compare_Capacity(__old_capacity);
591 _Self& replace(iterator __f, iterator __l, const _CharT* __s, size_type __n) {
592 _STLP_FIX_LITERAL_BUG(__s)
593 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
594 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
595 size_type __old_capacity = capacity();
596 _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s, __n);
597 _Compare_Capacity(__old_capacity);
601 _Self& replace(iterator __f, iterator __l, const _CharT* __s) {
602 _STLP_FIX_LITERAL_BUG(__s)
603 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
604 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
605 size_type __old_capacity = capacity();
606 _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s);
607 _Compare_Capacity(__old_capacity);
611 _Self& replace(iterator __f, iterator __l, size_type __n, _CharT __c) {
612 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
613 size_type __old_capacity = capacity();
614 _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __n, __c);
615 _Compare_Capacity(__old_capacity);
619 #if defined (_STLP_MEMBER_TEMPLATES)
621 template <class _RandomIter>
622 void _M_replace_aux(iterator __first, iterator __last,
623 _RandomIter __f, _RandomIter __l, __true_type const& /*_IsIterator*/)
624 { _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f._M_iterator, __l._M_iterator); }
626 template <class _InputIter>
627 void _M_replace_aux(iterator __first, iterator __last,
628 _InputIter __f, _InputIter __l, __false_type const& /*_IsIterator*/) {
629 _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
630 _STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
634 template <class _InputIter>
635 _Self& replace(iterator __first, iterator __last,
636 _InputIter __f, _InputIter __l) {
637 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
638 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
640 /* See insert comment for reson of iterator detection.
642 typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsNonConstIterator;
643 typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
644 typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _IsIterator;
646 size_type __old_capacity = capacity();
647 _M_replace_aux(__first, __last, __f, __l, _IsIterator());
648 _Compare_Capacity(__old_capacity);
653 #if !defined (_STLP_MEMBER_TEMPLATES) || \
654 !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
655 _Self& replace(iterator __first, iterator __last,
656 const_iterator __f, const_iterator __l) {
657 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
658 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
659 size_type __old_capacity = capacity();
660 _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
661 __f._M_iterator, __l._M_iterator);
662 _Compare_Capacity(__old_capacity);
666 _Self& replace(iterator __first, iterator __last,
667 const _CharT* __f, const _CharT* __l) {
668 _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
669 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
670 _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
671 size_type __old_capacity = capacity();
672 _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f, __l);
673 _Compare_Capacity(__old_capacity);
678 // Other modifier member functions.
679 void swap(_Self& __s) {
680 _M_iter_list._Swap_owners(__s._M_iter_list);
681 _M_non_dbg_impl.swap(__s._M_non_dbg_impl);
684 int compare(const _Self& __s) const
685 { return _M_non_dbg_impl.compare(__s._M_non_dbg_impl); }
686 int compare(size_type __pos, size_type __n, const _Self& __s) const
687 { return _M_non_dbg_impl.compare(__pos, __n, __s._M_non_dbg_impl); }
688 int compare(size_type __pos1, size_type __n1, const _Self& __s,
689 size_type __pos2, size_type __n2) const
690 { return _M_non_dbg_impl.compare(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2); }
691 int compare(const _CharT* __s) const {
692 _STLP_FIX_LITERAL_BUG(__s)
693 return _M_non_dbg_impl.compare(__s);
695 int compare(size_type __pos, size_type __n, const _CharT* __s) const {
696 _STLP_FIX_LITERAL_BUG(__s)
697 return _M_non_dbg_impl.compare(__pos, __n, __s);
699 int compare(size_type __pos1, size_type __n1, const _CharT* __s,
700 size_type __n2) const {
701 _STLP_FIX_LITERAL_BUG(__s)
702 return _M_non_dbg_impl.compare(__pos1, __n1, __s, __n2);
705 // Helper functions for compare.
706 static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
707 const _CharT* __f2, const _CharT* __l2)
708 { return _Base::_M_compare(__f1, __l1, __f2, __l2); }
709 static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
710 const _CharT* __f2, const _CharT* __l2)
711 { return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2, __l2); }
712 static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
713 const_iterator __f2, const_iterator __l2)
714 { return _Base::_M_compare(__f1, __l1, __f2._M_iterator, __l2._M_iterator); }
715 static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
716 const_iterator __f2, const_iterator __l2)
717 { return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2._M_iterator, __l2._M_iterator); }
719 const _CharT* c_str() const { return _M_non_dbg_impl.c_str(); }
720 const _CharT* data() const { return _M_non_dbg_impl.data(); }
722 size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
723 { return _M_non_dbg_impl.copy(__s, __n, __pos); }
726 size_type find(const _Self& __s, size_type __pos = 0) const
727 { return _M_non_dbg_impl.find(__s._M_non_dbg_impl, __pos); }
728 size_type find(const _CharT* __s, size_type __pos = 0) const {
729 _STLP_FIX_LITERAL_BUG(__s)
730 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
731 return _M_non_dbg_impl.find(__s, __pos);
733 size_type find(const _CharT* __s, size_type __pos, size_type __n) const {
734 _STLP_FIX_LITERAL_BUG(__s)
735 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
736 return _M_non_dbg_impl.find(__s, __pos, __n);
738 // WIE: Versant schema compiler 5.2.2 ICE workaround
739 size_type find(_CharT __c) const { return find(__c, 0); }
740 size_type find(_CharT __c, size_type __pos /* = 0 */) const
741 { return _M_non_dbg_impl.find(__c, __pos); }
744 size_type rfind(const _Self& __s, size_type __pos = npos) const
745 { return _M_non_dbg_impl.rfind(__s._M_non_dbg_impl, __pos); }
746 size_type rfind(const _CharT* __s, size_type __pos = npos) const {
747 _STLP_FIX_LITERAL_BUG(__s)
748 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
749 return _M_non_dbg_impl.rfind(__s, __pos);
751 size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const {
752 _STLP_FIX_LITERAL_BUG(__s)
753 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
754 return _M_non_dbg_impl.rfind(__s, __pos, __n);
756 size_type rfind(_CharT __c, size_type __pos = npos) const
757 { return _M_non_dbg_impl.rfind(__c, __pos); }
760 size_type find_first_of(const _Self& __s, size_type __pos = 0) const
761 { return _M_non_dbg_impl.find_first_of(__s._M_non_dbg_impl, __pos); }
762 size_type find_first_of(const _CharT* __s, size_type __pos = 0) const {
763 _STLP_FIX_LITERAL_BUG(__s)
764 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
765 return _M_non_dbg_impl.find_first_of(__s, __pos);
767 size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const {
768 _STLP_FIX_LITERAL_BUG(__s)
769 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
770 return _M_non_dbg_impl.find_first_of(__s, __pos, __n);
772 size_type find_first_of(_CharT __c, size_type __pos = 0) const
773 { return _M_non_dbg_impl.find_first_of(__c, __pos); }
776 size_type find_last_of(const _Self& __s, size_type __pos = npos) const
777 { return _M_non_dbg_impl.find_last_of(__s._M_non_dbg_impl, __pos); }
778 size_type find_last_of(const _CharT* __s, size_type __pos = npos) const {
779 _STLP_FIX_LITERAL_BUG(__s)
780 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
781 return _M_non_dbg_impl.find_last_of(__s, __pos);
783 size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const {
784 _STLP_FIX_LITERAL_BUG(__s)
785 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
786 return _M_non_dbg_impl.find_last_of(__s, __pos, __n);
788 size_type find_last_of(_CharT __c, size_type __pos = npos) const
789 { return _M_non_dbg_impl.rfind(__c, __pos); }
792 size_type find_first_not_of(const _Self& __s, size_type __pos = 0) const
793 { return _M_non_dbg_impl.find_first_not_of(__s._M_non_dbg_impl, __pos); }
794 size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const {
795 _STLP_FIX_LITERAL_BUG(__s)
796 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
797 return _M_non_dbg_impl.find_first_not_of(__s, __pos);
799 size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
800 _STLP_FIX_LITERAL_BUG(__s)
801 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
802 return _M_non_dbg_impl.find_first_not_of(__s, __pos, __n);
804 size_type find_first_not_of(_CharT __c, size_type __pos = 0) const
805 { return _M_non_dbg_impl.find_first_not_of(__c, __pos); }
808 size_type find_last_not_of(const _Self& __s, size_type __pos = npos) const
809 { return _M_non_dbg_impl.find_last_not_of(__s._M_non_dbg_impl, __pos); }
810 size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const {
811 _STLP_FIX_LITERAL_BUG(__s)
812 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
813 return _M_non_dbg_impl.find_last_not_of(__s, __pos);
815 size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
816 _STLP_FIX_LITERAL_BUG(__s)
817 _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
818 return _M_non_dbg_impl.find_last_not_of(__s, __pos, __n);
820 size_type find_last_not_of(_CharT __c, size_type __pos = npos) const
821 { return _M_non_dbg_impl.find_last_not_of(__c, __pos); }
823 #if defined (_STLP_USE_TEMPLATE_EXPRESSION)
824 # include <stl/debug/_string_sum_methods.h>
825 #endif /* _STLP_USE_TEMPLATE_EXPRESSION */
828 // This is a hook to instantiate STLport exports in a designated DLL
829 #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
830 _STLP_MOVE_TO_PRIV_NAMESPACE
831 _STLP_EXPORT_TEMPLATE_CLASS _STLP_CONSTRUCT_CHECKER<_STLP_NON_DBG_STRING_NAME <char, char_traits<char>, allocator<char> > >;
832 _STLP_MOVE_TO_STD_NAMESPACE
833 _STLP_EXPORT_TEMPLATE_CLASS basic_string<char, char_traits<char>, allocator<char> >;
834 # if defined (_STLP_HAS_WCHAR_T)
835 _STLP_MOVE_TO_PRIV_NAMESPACE
836 _STLP_EXPORT_TEMPLATE_CLASS _STLP_CONSTRUCT_CHECKER<_STLP_NON_DBG_STRING_NAME <wchar_t, char_traits<wchar_t>, allocator<wchar_t> > >;
837 _STLP_MOVE_TO_STD_NAMESPACE
838 _STLP_EXPORT_TEMPLATE_CLASS basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
840 #endif /* _STLP_USE_TEMPLATE_EXPORT */
842 #undef _STLP_NON_DBG_STRING
843 #undef _STLP_NON_DBG_STRING_NAME
845 #if !defined (_STLP_STATIC_CONST_INIT_BUG)
846 # if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)
847 template <class _CharT, class _Traits, class _Alloc>
848 const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0;
850 template <class _CharT, class _Traits, class _Alloc>
851 const size_t basic_string<_CharT, _Traits, _Alloc>::npos;
855 #if defined (basic_string)
856 _STLP_MOVE_TO_STD_NAMESPACE
862 #endif /* _STLP_DBG_STRING */