1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
|
/*
* Copyright (c) 1997-1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
#ifndef _STLP_DBG_STRING_H
#define _STLP_DBG_STRING_H
#ifndef _STLP_DBG_ITERATOR_H
# include <stl/debug/_iterator.h>
#endif
_STLP_BEGIN_NAMESPACE
#define _STLP_NON_DBG_STRING_NAME _STLP_NON_DBG_NAME(str)
#define _STLP_NON_DBG_STRING _STLP_PRIV _STLP_NON_DBG_STRING_NAME <_CharT, _Traits, _Alloc>
#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
template <class _CharT,class _Traits, class _Alloc>
inline _CharT*
value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&)
{ return (_CharT*)0; }
template <class _CharT, class _Traits, class _Alloc>
inline random_access_iterator_tag
iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&)
{ return random_access_iterator_tag(); }
#endif
template <class _CharT, class _Traits, class _Alloc>
class basic_string :
#if !defined (__DMC__)
private
#else
public
#endif
_STLP_PRIV __construct_checker<_STLP_NON_DBG_STRING >
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string)
, public __stlport_class<basic_string<_CharT, _Traits, _Alloc> >
#endif
{
protected:
typedef _STLP_NON_DBG_STRING _Base;
typedef basic_string<_CharT, _Traits, _Alloc> _Self;
typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_STRING > _ConstructCheck;
typedef typename _IsPOD<_CharT>::_Type _Char_Is_POD;
public:
__IMPORT_CONTAINER_TYPEDEFS(_Base)
typedef typename _Base::traits_type traits_type;
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator;
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > > const_iterator;
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
public: // Constructor, destructor, assignment.
typedef typename _Base::_Reserve_t _Reserve_t;
private:
_Base _M_non_dbg_impl;
_STLP_PRIV __owned_list _M_iter_list;
void _Invalidate_all()
{ _M_iter_list._Invalidate_all(); }
void _Compare_Capacity (size_type __old_capacity) {
if (this->capacity() > __old_capacity) {
_Invalidate_all();
}
}
void _Invalidate_iterator(const iterator& __it)
{ _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
void _Invalidate_iterators(const iterator& __f, const iterator& __l)
{ _STLP_PRIV __invalidate_range(&_M_iter_list, __f, __l); }
public:
#include <stl/_string_npos.h>
allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
explicit basic_string(const allocator_type& __a = allocator_type())
: _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
basic_string(_Reserve_t __r, size_t __n,
const allocator_type& __a = allocator_type())
: _M_non_dbg_impl(__r, __n, __a), _M_iter_list(&_M_non_dbg_impl) {}
basic_string(const _Self& __s)
: _ConstructCheck(__s),
_M_non_dbg_impl(__s._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
basic_string(const _Self& __s, size_type __pos, size_type __n = npos,
const allocator_type& __a = allocator_type())
: _M_non_dbg_impl(__s._M_non_dbg_impl, __pos, __n, __a),
_M_iter_list(&_M_non_dbg_impl) {}
basic_string(const _CharT* __s, size_type __n,
const allocator_type& __a = allocator_type())
: _ConstructCheck(__s), _M_non_dbg_impl(__s, __n, __a),
_M_iter_list(&_M_non_dbg_impl) {}
basic_string(const _CharT* __s,
const allocator_type& __a = allocator_type())
: _ConstructCheck(__s),
_M_non_dbg_impl(__s, __a), _M_iter_list(&_M_non_dbg_impl) {}
basic_string(size_type __n, _CharT __c,
const allocator_type& __a = allocator_type())
: _M_non_dbg_impl(__n, __c, __a), _M_iter_list(&_M_non_dbg_impl) {}
basic_string(__move_source<_Self> src)
: _M_non_dbg_impl(__move_source<_Base >(src.get()._M_non_dbg_impl)),
_M_iter_list(&_M_non_dbg_impl) {
#if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
src.get()._M_iter_list._Invalidate_all();
#else
src.get()._M_iter_list._Set_owner(_M_iter_list);
#endif
}
#if !defined (_STLP_MEMBER_TEMPLATES) || defined(__MRC__) || defined(__SC__)
basic_string(const _CharT* __f, const _CharT* __l,
const allocator_type& __a = allocator_type())
: _ConstructCheck(__f, __l),
_M_non_dbg_impl(__f, __l, __a), _M_iter_list(&_M_non_dbg_impl) {
}
basic_string(const_iterator __f, const_iterator __l,
const allocator_type & __a = allocator_type())
: _ConstructCheck(__f, __l),
_M_non_dbg_impl(__f._M_iterator, __l._M_iterator, __a), _M_iter_list(&_M_non_dbg_impl) {
}
#else
template <class _InputIterator>
basic_string(_InputIterator __f, _InputIterator __l,
const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)
: _ConstructCheck(__f, __l),
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l), __a),
_M_iter_list(&_M_non_dbg_impl) {}
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
template <class _InputIterator>
basic_string(_InputIterator __f, _InputIterator __l)
: _ConstructCheck(__f, __l),
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l)),
_M_iter_list(&_M_non_dbg_impl) {}
# endif
#endif
private:
// constructor from non-debug version for substr
basic_string (const _Base& __x)
: _M_non_dbg_impl(__x), _M_iter_list(&_M_non_dbg_impl) {}
public:
_Self& operator=(const _Self& __s) {
if (this != &__s) {
assign(__s);
}
return *this;
}
_Self& operator=(const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return assign(__s);
}
_Self& operator=(_CharT __c) {
return assign(1, __c);
}
// Iterators.
iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
reverse_iterator rbegin() { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
// Size, capacity, etc.
size_type size() const { return _M_non_dbg_impl.size(); }
size_type length() const { return _M_non_dbg_impl.length(); }
size_t max_size() const { return _M_non_dbg_impl.max_size(); }
void resize(size_type __n, _CharT __c) {
if (__n > capacity())
_Invalidate_all();
else if (__n < size())
_Invalidate_iterators(begin() + __n, end());
_M_non_dbg_impl.resize(__n, __c);
}
void resize(size_type __n) { resize(__n, _STLP_DEFAULT_CONSTRUCTED(_CharT)); }
size_type capacity() const { return _M_non_dbg_impl.capacity(); }
void reserve(size_type __s = 0) {
if (__s > capacity()) _Invalidate_all();
_M_non_dbg_impl.reserve(__s);
}
void clear() {
_Invalidate_all();
_M_non_dbg_impl.clear();
}
bool empty() const { return _M_non_dbg_impl.empty(); }
const_reference operator[](size_type __n) const {
_STLP_VERBOSE_ASSERT(__n <= this->size(), _StlMsg_OUT_OF_BOUNDS);
return _M_non_dbg_impl[__n];
}
reference operator[](size_type __n) {
_STLP_VERBOSE_ASSERT(__n < this->size(), _StlMsg_OUT_OF_BOUNDS)
return _M_non_dbg_impl[__n];
}
const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); }
reference at(size_type __n) { return _M_non_dbg_impl.at(__n); }
// Append, operator+=, push_back.
_Self& operator+=(const _Self& __s) { return append(__s); }
_Self& operator+=(const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return append(__s);
}
_Self& operator+=(_CharT __c) { return append(1, __c); }
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIter>
_Self& append(_InputIter __first, _InputIter __last) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
size_type __old_capacity = capacity();
_M_non_dbg_impl.append(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
_Compare_Capacity(__old_capacity);
return *this;
}
#endif
#if !defined (_STLP_MEMBER_TEMPLATES) || \
!defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
_Self& append(const _CharT* __f, const _CharT* __l) {
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
size_type __old_capacity = capacity();
_M_non_dbg_impl.append(__f, __l);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& append(const_iterator __f, const_iterator __l) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
size_type __old_capacity = capacity();
_M_non_dbg_impl.append(__f._M_iterator, __l._M_iterator);
_Compare_Capacity(__old_capacity);
return *this;
}
#endif
_Self& append(const _Self& __s) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.append(__s._M_non_dbg_impl);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& append(const _Self& __s, size_type __pos, size_type __n) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.append(__s._M_non_dbg_impl, __pos, __n);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& append(const _CharT* __s, size_type __n) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.append(__s, __n);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& append(const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.append(__s);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& append(size_type __n, _CharT __c) {
size_type __old_capacity = this->capacity();
_M_non_dbg_impl.append(__n, __c);
_Compare_Capacity(__old_capacity);
return *this;
}
void push_back(_CharT __c) {
size_type __old_capacity = this->capacity();
_M_non_dbg_impl.push_back(__c);
_Compare_Capacity(__old_capacity);
}
void pop_back() {
_Invalidate_iterator(this->end());
_M_non_dbg_impl.pop_back();
}
// Assign
private:
void _M_check_assign(size_type __n) {
if (__n > capacity()) {
_Invalidate_all();
}
else if (__n < size()) {
_Invalidate_iterators(begin() + __n, end());
}
}
public:
_Self& assign(const _Self& __s) {
_M_check_assign(__s.size());
_M_non_dbg_impl.assign(__s._M_non_dbg_impl);
return *this;
}
_Self& assign(const _Self& __s, size_type __pos, size_type __n) {
if (__pos < __s.size()) {
_M_check_assign((min) (__n, __s.size() - __pos));
}
_M_non_dbg_impl.assign(__s._M_non_dbg_impl, __pos, __n);
return *this;
}
_Self& assign(const _CharT* __s, size_type __n) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
_M_check_assign((min) (_Traits::length(__s), __n));
_M_non_dbg_impl.assign(__s, __s + __n);
return *this;
}
_Self& assign(const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
_M_check_assign(_Traits::length(__s));
_M_non_dbg_impl.assign(__s);
return *this;
}
_Self& assign(size_type __n, _CharT __c) {
_M_check_assign(__n);
_M_non_dbg_impl.assign(__n, __c);
return *this;
}
#if defined(_STLP_MEMBER_TEMPLATES)
private:
template <class _Integer>
void _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) {
_M_check_assign(__n);
_M_non_dbg_impl.assign((size_type)__n, (_CharT)__x);
}
template <class _InputIter>
void _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {
_M_check_assign(distance(__f, __l));
_M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
}
public:
template <class _InputIter>
inline _Self& assign(_InputIter __first, _InputIter __last) {
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
_M_assign_dispatch(__first, __last, _Integral());
return *this;
}
#endif
#if !defined (_STLP_MEMBER_TEMPLATES) || \
!defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
_Self& assign(const _CharT* __f, const _CharT* __l) {
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
_M_check_assign(distance(__f, __l));
_M_non_dbg_impl.assign(__f, __l);
return *this;
}
_Self& assign(const_iterator __f, const_iterator __l) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
_M_check_assign(distance(__f, __l));
_M_non_dbg_impl.assign(__f._M_iterator, __l._M_iterator);
return *this;
}
#endif
// Insert
_Self& insert(size_type __pos, const _Self& __s) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& insert(size_type __pos, const _Self& __s,
size_type __beg, size_type __n) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl, __beg, __n);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__pos, __s, __n);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& insert(size_type __pos, const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return insert(__pos, __s, _Traits::length(__s));
}
_Self& insert(size_type __pos, size_type __n, _CharT __c) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__pos, __n, __c);
_Compare_Capacity(__old_capacity);
return *this;
}
iterator insert(iterator __p, _CharT __c) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
size_type __old_capacity = capacity();
typename _Base::iterator __ret = _M_non_dbg_impl.insert(__p._M_iterator, __c);
_Compare_Capacity(__old_capacity);
return iterator(&_M_iter_list, __ret);
}
void insert(iterator __p, size_t __n, _CharT __c) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__p._M_iterator, __n, __c);
_Compare_Capacity(__old_capacity);
}
#if defined (_STLP_MEMBER_TEMPLATES)
private:
template <class _RandomIter>
void _M_insert_aux (iterator __p, _RandomIter __first, _RandomIter __last,
const __true_type& /*_IsIterator*/)
{ _M_non_dbg_impl.insert(__p._M_iterator, __first._M_iterator, __last._M_iterator); }
template<class _InputIter>
void _M_insert_aux (iterator __p, _InputIter __first, _InputIter __last,
const __false_type& /*_IsIterator*/) {
_M_non_dbg_impl.insert(__p._M_iterator,
_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
}
public:
template <class _InputIter>
void insert(iterator __p, _InputIter __first, _InputIter __last) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
/* In debug mode we are encapsulating non debug string iterators in debug one.
* Doing so the non debug implementation will not check for self insertion
* (x.insert(x.begin(), x.begin(), x.end()). To avoid this problem we try to
* guess when _InputIter is iterator or const_iterator and in this case call
* the non debug insert method with non debug string iterator.
*/
typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsNonConstIterator;
typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _IsIterator;
size_type __old_capacity = this->capacity();
_M_insert_aux(__p, __first, __last, _IsIterator());
_Compare_Capacity(__old_capacity);
}
#endif
#if !defined (_STLP_MEMBER_TEMPLATES) || \
!defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
void insert(iterator __p, const_iterator __f, const_iterator __l) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f,__l))
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__p._M_iterator, __f._M_iterator, __l._M_iterator);
_Compare_Capacity(__old_capacity);
}
void insert(iterator __p, const _CharT* __f, const _CharT* __l) {
_STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f,__l))
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__p._M_iterator, __f, __l);
_Compare_Capacity(__old_capacity);
}
#endif
// Erase.
_Self& erase(size_type __pos = 0, size_type __n = npos) {
if (__pos < size()) {
_Invalidate_iterators(begin() + __pos, end());
}
_M_non_dbg_impl.erase(__pos, __n);
return *this;
}
iterator erase(iterator __pos) {
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
_Invalidate_iterators(__pos, end());
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
}
iterator erase(iterator __f, iterator __l) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
_Invalidate_iterators(__f, end());
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__f._M_iterator, __l._M_iterator));
}
// Substring.
_Self substr(size_type __pos = 0, size_type __n = npos) const
{ return _M_non_dbg_impl.substr(__pos, __n); }
// Replace. (Conceptually equivalent to erase followed by insert.)
_Self& replace(size_type __pos, size_type __n, const _Self& __s) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos, __n, __s._M_non_dbg_impl);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(size_type __pos1, size_type __n1, const _Self& __s,
size_type __pos2, size_type __n2) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos, __n1, __s, __n2);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(size_type __pos, size_type __n1, const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos, __n1, __s);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos, __n1, __n2, __c);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(iterator __f, iterator __l, const _Self& __s) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s._M_non_dbg_impl);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(iterator __f, iterator __l, const _CharT* __s, size_type __n) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s, __n);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(iterator __f, iterator __l, const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(iterator __f, iterator __l, size_type __n, _CharT __c) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __n, __c);
_Compare_Capacity(__old_capacity);
return *this;
}
#if defined (_STLP_MEMBER_TEMPLATES)
private:
template <class _RandomIter>
void _M_replace_aux(iterator __first, iterator __last,
_RandomIter __f, _RandomIter __l, __true_type const& /*_IsIterator*/)
{ _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f._M_iterator, __l._M_iterator); }
template <class _InputIter>
void _M_replace_aux(iterator __first, iterator __last,
_InputIter __f, _InputIter __l, __false_type const& /*_IsIterator*/) {
_M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
}
public:
template <class _InputIter>
_Self& replace(iterator __first, iterator __last,
_InputIter __f, _InputIter __l) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
/* See insert comment for reson of iterator detection.
*/
typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsNonConstIterator;
typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _IsIterator;
size_type __old_capacity = capacity();
_M_replace_aux(__first, __last, __f, __l, _IsIterator());
_Compare_Capacity(__old_capacity);
return *this;
}
#endif
#if !defined (_STLP_MEMBER_TEMPLATES) || \
!defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
_Self& replace(iterator __first, iterator __last,
const_iterator __f, const_iterator __l) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
__f._M_iterator, __l._M_iterator);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(iterator __first, iterator __last,
const _CharT* __f, const _CharT* __l) {
_STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f, __l);
_Compare_Capacity(__old_capacity);
return *this;
}
#endif
// Other modifier member functions.
void swap(_Self& __s) {
_M_iter_list._Swap_owners(__s._M_iter_list);
_M_non_dbg_impl.swap(__s._M_non_dbg_impl);
}
int compare(const _Self& __s) const
{ return _M_non_dbg_impl.compare(__s._M_non_dbg_impl); }
int compare(size_type __pos, size_type __n, const _Self& __s) const
{ return _M_non_dbg_impl.compare(__pos, __n, __s._M_non_dbg_impl); }
int compare(size_type __pos1, size_type __n1, const _Self& __s,
size_type __pos2, size_type __n2) const
{ return _M_non_dbg_impl.compare(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2); }
int compare(const _CharT* __s) const {
_STLP_FIX_LITERAL_BUG(__s)
return _M_non_dbg_impl.compare(__s);
}
int compare(size_type __pos, size_type __n, const _CharT* __s) const {
_STLP_FIX_LITERAL_BUG(__s)
return _M_non_dbg_impl.compare(__pos, __n, __s);
}
int compare(size_type __pos1, size_type __n1, const _CharT* __s,
size_type __n2) const {
_STLP_FIX_LITERAL_BUG(__s)
return _M_non_dbg_impl.compare(__pos1, __n1, __s, __n2);
}
// Helper functions for compare.
static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
const _CharT* __f2, const _CharT* __l2)
{ return _Base::_M_compare(__f1, __l1, __f2, __l2); }
static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
const _CharT* __f2, const _CharT* __l2)
{ return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2, __l2); }
static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
const_iterator __f2, const_iterator __l2)
{ return _Base::_M_compare(__f1, __l1, __f2._M_iterator, __l2._M_iterator); }
static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
const_iterator __f2, const_iterator __l2)
{ return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2._M_iterator, __l2._M_iterator); }
const _CharT* c_str() const { return _M_non_dbg_impl.c_str(); }
const _CharT* data() const { return _M_non_dbg_impl.data(); }
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
{ return _M_non_dbg_impl.copy(__s, __n, __pos); }
// find.
size_type find(const _Self& __s, size_type __pos = 0) const
{ return _M_non_dbg_impl.find(__s._M_non_dbg_impl, __pos); }
size_type find(const _CharT* __s, size_type __pos = 0) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find(__s, __pos);
}
size_type find(const _CharT* __s, size_type __pos, size_type __n) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find(__s, __pos, __n);
}
// WIE: Versant schema compiler 5.2.2 ICE workaround
size_type find(_CharT __c) const { return find(__c, 0); }
size_type find(_CharT __c, size_type __pos /* = 0 */) const
{ return _M_non_dbg_impl.find(__c, __pos); }
// rfind.
size_type rfind(const _Self& __s, size_type __pos = npos) const
{ return _M_non_dbg_impl.rfind(__s._M_non_dbg_impl, __pos); }
size_type rfind(const _CharT* __s, size_type __pos = npos) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.rfind(__s, __pos);
}
size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.rfind(__s, __pos, __n);
}
size_type rfind(_CharT __c, size_type __pos = npos) const
{ return _M_non_dbg_impl.rfind(__c, __pos); }
// find_first_of
size_type find_first_of(const _Self& __s, size_type __pos = 0) const
{ return _M_non_dbg_impl.find_first_of(__s._M_non_dbg_impl, __pos); }
size_type find_first_of(const _CharT* __s, size_type __pos = 0) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find_first_of(__s, __pos);
}
size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find_first_of(__s, __pos, __n);
}
size_type find_first_of(_CharT __c, size_type __pos = 0) const
{ return _M_non_dbg_impl.find_first_of(__c, __pos); }
// find_last_of
size_type find_last_of(const _Self& __s, size_type __pos = npos) const
{ return _M_non_dbg_impl.find_last_of(__s._M_non_dbg_impl, __pos); }
size_type find_last_of(const _CharT* __s, size_type __pos = npos) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find_last_of(__s, __pos);
}
size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find_last_of(__s, __pos, __n);
}
size_type find_last_of(_CharT __c, size_type __pos = npos) const
{ return _M_non_dbg_impl.rfind(__c, __pos); }
// find_first_not_of
size_type find_first_not_of(const _Self& __s, size_type __pos = 0) const
{ return _M_non_dbg_impl.find_first_not_of(__s._M_non_dbg_impl, __pos); }
size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find_first_not_of(__s, __pos);
}
size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find_first_not_of(__s, __pos, __n);
}
size_type find_first_not_of(_CharT __c, size_type __pos = 0) const
{ return _M_non_dbg_impl.find_first_not_of(__c, __pos); }
// find_last_not_of
size_type find_last_not_of(const _Self& __s, size_type __pos = npos) const
{ return _M_non_dbg_impl.find_last_not_of(__s._M_non_dbg_impl, __pos); }
size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find_last_not_of(__s, __pos);
}
size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return _M_non_dbg_impl.find_last_not_of(__s, __pos, __n);
}
size_type find_last_not_of(_CharT __c, size_type __pos = npos) const
{ return _M_non_dbg_impl.find_last_not_of(__c, __pos); }
#if defined (_STLP_USE_TEMPLATE_EXPRESSION)
# include <stl/debug/_string_sum_methods.h>
#endif /* _STLP_USE_TEMPLATE_EXPRESSION */
};
// This is a hook to instantiate STLport exports in a designated DLL
#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
_STLP_MOVE_TO_PRIV_NAMESPACE
_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_STRING_NAME <char, char_traits<char>, allocator<char> > >;
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_EXPORT_TEMPLATE_CLASS basic_string<char, char_traits<char>, allocator<char> >;
# if defined (_STLP_HAS_WCHAR_T)
_STLP_MOVE_TO_PRIV_NAMESPACE
_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_STRING_NAME <wchar_t, char_traits<wchar_t>, allocator<wchar_t> > >;
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_EXPORT_TEMPLATE_CLASS basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
# endif
#endif /* _STLP_USE_TEMPLATE_EXPORT */
#undef _STLP_NON_DBG_STRING
#undef _STLP_NON_DBG_STRING_NAME
#if !defined (_STLP_STATIC_CONST_INIT_BUG)
# if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)
template <class _CharT, class _Traits, class _Alloc>
const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0;
# else
template <class _CharT, class _Traits, class _Alloc>
const size_t basic_string<_CharT, _Traits, _Alloc>::npos;
# endif
#endif
#if defined (basic_string)
_STLP_MOVE_TO_STD_NAMESPACE
#undef basic_string
#endif
_STLP_END_NAMESPACE
#endif /* _STLP_DBG_STRING */
// Local Variables:
// mode:C++
// End:
|