00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _VSTRING_H
00031 #define _VSTRING_H 1
00032
00033 #pragma GCC system_header
00034
00035 #include <initializer_list>
00036 #include <ext/vstring_util.h>
00037 #include <ext/rc_string_base.h>
00038 #include <ext/sso_string_base.h>
00039
00040 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
00041 {
00042 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 template<typename _CharT, typename _Traits, typename _Alloc,
00053 template <typename, typename, typename> class _Base>
00054 class __versa_string
00055 : private _Base<_CharT, _Traits, _Alloc>
00056 {
00057 typedef _Base<_CharT, _Traits, _Alloc> __vstring_base;
00058 typedef typename __vstring_base::_CharT_alloc_type _CharT_alloc_type;
00059
00060
00061 public:
00062 typedef _Traits traits_type;
00063 typedef typename _Traits::char_type value_type;
00064 typedef _Alloc allocator_type;
00065 typedef typename _CharT_alloc_type::size_type size_type;
00066 typedef typename _CharT_alloc_type::difference_type difference_type;
00067 typedef value_type& reference;
00068 typedef const value_type& const_reference;
00069 typedef typename _CharT_alloc_type::pointer pointer;
00070 typedef typename _CharT_alloc_type::const_pointer const_pointer;
00071 typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator;
00072 typedef __gnu_cxx::__normal_iterator<const_pointer, __versa_string>
00073 const_iterator;
00074 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00075 typedef std::reverse_iterator<iterator> reverse_iterator;
00076
00077
00078
00079 static const size_type npos = static_cast<size_type>(-1);
00080
00081 private:
00082 size_type
00083 _M_check(size_type __pos, const char* __s) const
00084 {
00085 if (__pos > this->size())
00086 std::__throw_out_of_range(__N(__s));
00087 return __pos;
00088 }
00089
00090 void
00091 _M_check_length(size_type __n1, size_type __n2, const char* __s) const
00092 {
00093 if (this->max_size() - (this->size() - __n1) < __n2)
00094 std::__throw_length_error(__N(__s));
00095 }
00096
00097
00098 size_type
00099 _M_limit(size_type __pos, size_type __off) const
00100 {
00101 const bool __testoff = __off < this->size() - __pos;
00102 return __testoff ? __off : this->size() - __pos;
00103 }
00104
00105
00106 bool
00107 _M_disjunct(const _CharT* __s) const
00108 {
00109 return (std::less<const _CharT*>()(__s, this->_M_data())
00110 || std::less<const _CharT*>()(this->_M_data()
00111 + this->size(), __s));
00112 }
00113
00114
00115
00116 iterator
00117 _M_ibegin() const
00118 { return iterator(this->_M_data()); }
00119
00120 iterator
00121 _M_iend() const
00122 { return iterator(this->_M_data() + this->_M_length()); }
00123
00124 public:
00125
00126
00127
00128
00129
00130
00131
00132 __versa_string()
00133 : __vstring_base() { }
00134
00135
00136
00137
00138 explicit
00139 __versa_string(const _Alloc& __a)
00140 : __vstring_base(__a) { }
00141
00142
00143
00144
00145
00146
00147 __versa_string(const __versa_string& __str)
00148 : __vstring_base(__str) { }
00149
00150 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00151
00152
00153
00154
00155
00156
00157
00158
00159 __versa_string(__versa_string&& __str)
00160 : __vstring_base(std::move(__str)) { }
00161
00162
00163
00164
00165
00166
00167 __versa_string(std::initializer_list<_CharT> __l,
00168 const _Alloc& __a = _Alloc())
00169 : __vstring_base(__l.begin(), __l.end(), __a) { }
00170 #endif
00171
00172
00173
00174
00175
00176
00177
00178 __versa_string(const __versa_string& __str, size_type __pos,
00179 size_type __n = npos)
00180 : __vstring_base(__str._M_data()
00181 + __str._M_check(__pos,
00182 "__versa_string::__versa_string"),
00183 __str._M_data() + __str._M_limit(__pos, __n)
00184 + __pos, _Alloc()) { }
00185
00186
00187
00188
00189
00190
00191
00192
00193 __versa_string(const __versa_string& __str, size_type __pos,
00194 size_type __n, const _Alloc& __a)
00195 : __vstring_base(__str._M_data()
00196 + __str._M_check(__pos,
00197 "__versa_string::__versa_string"),
00198 __str._M_data() + __str._M_limit(__pos, __n)
00199 + __pos, __a) { }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 __versa_string(const _CharT* __s, size_type __n,
00211 const _Alloc& __a = _Alloc())
00212 : __vstring_base(__s, __s + __n, __a) { }
00213
00214
00215
00216
00217
00218
00219 __versa_string(const _CharT* __s, const _Alloc& __a = _Alloc())
00220 : __vstring_base(__s, __s ? __s + traits_type::length(__s) :
00221 __s + npos, __a) { }
00222
00223
00224
00225
00226
00227
00228
00229 __versa_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
00230 : __vstring_base(__n, __c, __a) { }
00231
00232
00233
00234
00235
00236
00237
00238 template<class _InputIterator>
00239 __versa_string(_InputIterator __beg, _InputIterator __end,
00240 const _Alloc& __a = _Alloc())
00241 : __vstring_base(__beg, __end, __a) { }
00242
00243
00244
00245
00246 ~__versa_string() { }
00247
00248
00249
00250
00251
00252 __versa_string&
00253 operator=(const __versa_string& __str)
00254 { return this->assign(__str); }
00255
00256 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00257
00258
00259
00260
00261
00262
00263
00264 __versa_string&
00265 operator=(__versa_string&& __str)
00266 {
00267
00268 this->swap(__str);
00269 return *this;
00270 }
00271
00272
00273
00274
00275
00276 __versa_string&
00277 operator=(std::initializer_list<_CharT> __l)
00278 {
00279 this->assign(__l.begin(), __l.end());
00280 return *this;
00281 }
00282 #endif
00283
00284
00285
00286
00287
00288 __versa_string&
00289 operator=(const _CharT* __s)
00290 { return this->assign(__s); }
00291
00292
00293
00294
00295
00296
00297
00298
00299 __versa_string&
00300 operator=(_CharT __c)
00301 {
00302 this->assign(1, __c);
00303 return *this;
00304 }
00305
00306
00307
00308
00309
00310
00311 iterator
00312 begin()
00313 {
00314 this->_M_leak();
00315 return iterator(this->_M_data());
00316 }
00317
00318
00319
00320
00321
00322 const_iterator
00323 begin() const
00324 { return const_iterator(this->_M_data()); }
00325
00326
00327
00328
00329
00330 iterator
00331 end()
00332 {
00333 this->_M_leak();
00334 return iterator(this->_M_data() + this->size());
00335 }
00336
00337
00338
00339
00340
00341 const_iterator
00342 end() const
00343 { return const_iterator(this->_M_data() + this->size()); }
00344
00345
00346
00347
00348
00349
00350 reverse_iterator
00351 rbegin()
00352 { return reverse_iterator(this->end()); }
00353
00354
00355
00356
00357
00358
00359 const_reverse_iterator
00360 rbegin() const
00361 { return const_reverse_iterator(this->end()); }
00362
00363
00364
00365
00366
00367
00368 reverse_iterator
00369 rend()
00370 { return reverse_iterator(this->begin()); }
00371
00372
00373
00374
00375
00376
00377 const_reverse_iterator
00378 rend() const
00379 { return const_reverse_iterator(this->begin()); }
00380
00381 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00382
00383
00384
00385
00386 const_iterator
00387 cbegin() const
00388 { return const_iterator(this->_M_data()); }
00389
00390
00391
00392
00393
00394 const_iterator
00395 cend() const
00396 { return const_iterator(this->_M_data() + this->size()); }
00397
00398
00399
00400
00401
00402
00403 const_reverse_iterator
00404 crbegin() const
00405 { return const_reverse_iterator(this->end()); }
00406
00407
00408
00409
00410
00411
00412 const_reverse_iterator
00413 crend() const
00414 { return const_reverse_iterator(this->begin()); }
00415 #endif
00416
00417 public:
00418
00419
00420
00421 size_type
00422 size() const
00423 { return this->_M_length(); }
00424
00425
00426
00427 size_type
00428 length() const
00429 { return this->_M_length(); }
00430
00431
00432 size_type
00433 max_size() const
00434 { return this->_M_max_size(); }
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 void
00447 resize(size_type __n, _CharT __c);
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459 void
00460 resize(size_type __n)
00461 { this->resize(__n, _CharT()); }
00462
00463 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00464
00465 void
00466 shrink_to_fit()
00467 {
00468 __try
00469 { this->reserve(0); }
00470 __catch(...)
00471 { }
00472 }
00473 #endif
00474
00475
00476
00477
00478
00479 size_type
00480 capacity() const
00481 { return this->_M_capacity(); }
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500 void
00501 reserve(size_type __res_arg = 0)
00502 { this->_M_reserve(__res_arg); }
00503
00504
00505
00506
00507 void
00508 clear()
00509 { this->_M_clear(); }
00510
00511
00512
00513
00514
00515 bool
00516 empty() const
00517 { return this->size() == 0; }
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530 const_reference
00531 operator[] (size_type __pos) const
00532 {
00533 _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
00534 return this->_M_data()[__pos];
00535 }
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 reference
00548 operator[](size_type __pos)
00549 {
00550
00551 _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
00552
00553 _GLIBCXX_DEBUG_PEDASSERT(__pos < this->size());
00554 this->_M_leak();
00555 return this->_M_data()[__pos];
00556 }
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568 const_reference
00569 at(size_type __n) const
00570 {
00571 if (__n >= this->size())
00572 std::__throw_out_of_range(__N("__versa_string::at"));
00573 return this->_M_data()[__n];
00574 }
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587 reference
00588 at(size_type __n)
00589 {
00590 if (__n >= this->size())
00591 std::__throw_out_of_range(__N("__versa_string::at"));
00592 this->_M_leak();
00593 return this->_M_data()[__n];
00594 }
00595
00596 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00597
00598
00599
00600
00601 reference
00602 front()
00603 { return operator[](0); }
00604
00605
00606
00607
00608
00609 const_reference
00610 front() const
00611 { return operator[](0); }
00612
00613
00614
00615
00616
00617 reference
00618 back()
00619 { return operator[](this->size() - 1); }
00620
00621
00622
00623
00624
00625 const_reference
00626 back() const
00627 { return operator[](this->size() - 1); }
00628 #endif
00629
00630
00631
00632
00633
00634
00635
00636 __versa_string&
00637 operator+=(const __versa_string& __str)
00638 { return this->append(__str); }
00639
00640
00641
00642
00643
00644
00645 __versa_string&
00646 operator+=(const _CharT* __s)
00647 { return this->append(__s); }
00648
00649
00650
00651
00652
00653
00654 __versa_string&
00655 operator+=(_CharT __c)
00656 {
00657 this->push_back(__c);
00658 return *this;
00659 }
00660
00661 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00662
00663
00664
00665
00666
00667 __versa_string&
00668 operator+=(std::initializer_list<_CharT> __l)
00669 { return this->append(__l.begin(), __l.end()); }
00670 #endif // __GXX_EXPERIMENTAL_CXX0X__
00671
00672
00673
00674
00675
00676
00677 __versa_string&
00678 append(const __versa_string& __str)
00679 { return _M_append(__str._M_data(), __str.size()); }
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694 __versa_string&
00695 append(const __versa_string& __str, size_type __pos, size_type __n)
00696 { return _M_append(__str._M_data()
00697 + __str._M_check(__pos, "__versa_string::append"),
00698 __str._M_limit(__pos, __n)); }
00699
00700
00701
00702
00703
00704
00705
00706 __versa_string&
00707 append(const _CharT* __s, size_type __n)
00708 {
00709 __glibcxx_requires_string_len(__s, __n);
00710 _M_check_length(size_type(0), __n, "__versa_string::append");
00711 return _M_append(__s, __n);
00712 }
00713
00714
00715
00716
00717
00718
00719 __versa_string&
00720 append(const _CharT* __s)
00721 {
00722 __glibcxx_requires_string(__s);
00723 const size_type __n = traits_type::length(__s);
00724 _M_check_length(size_type(0), __n, "__versa_string::append");
00725 return _M_append(__s, __n);
00726 }
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736 __versa_string&
00737 append(size_type __n, _CharT __c)
00738 { return _M_replace_aux(this->size(), size_type(0), __n, __c); }
00739
00740 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00741
00742
00743
00744
00745
00746 __versa_string&
00747 append(std::initializer_list<_CharT> __l)
00748 { return this->append(__l.begin(), __l.end()); }
00749 #endif // __GXX_EXPERIMENTAL_CXX0X__
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759 template<class _InputIterator>
00760 __versa_string&
00761 append(_InputIterator __first, _InputIterator __last)
00762 { return this->replace(_M_iend(), _M_iend(), __first, __last); }
00763
00764
00765
00766
00767
00768 void
00769 push_back(_CharT __c)
00770 {
00771 const size_type __size = this->size();
00772 if (__size + 1 > this->capacity() || this->_M_is_shared())
00773 this->_M_mutate(__size, size_type(0), 0, size_type(1));
00774 traits_type::assign(this->_M_data()[__size], __c);
00775 this->_M_set_length(__size + 1);
00776 }
00777
00778
00779
00780
00781
00782
00783 __versa_string&
00784 assign(const __versa_string& __str)
00785 {
00786 this->_M_assign(__str);
00787 return *this;
00788 }
00789
00790 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00791
00792
00793
00794
00795
00796
00797
00798
00799 __versa_string&
00800 assign(__versa_string&& __str)
00801 {
00802 this->swap(__str);
00803 return *this;
00804 }
00805 #endif // __GXX_EXPERIMENTAL_CXX0X__
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820 __versa_string&
00821 assign(const __versa_string& __str, size_type __pos, size_type __n)
00822 { return _M_replace(size_type(0), this->size(), __str._M_data()
00823 + __str._M_check(__pos, "__versa_string::assign"),
00824 __str._M_limit(__pos, __n)); }
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837 __versa_string&
00838 assign(const _CharT* __s, size_type __n)
00839 {
00840 __glibcxx_requires_string_len(__s, __n);
00841 return _M_replace(size_type(0), this->size(), __s, __n);
00842 }
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853 __versa_string&
00854 assign(const _CharT* __s)
00855 {
00856 __glibcxx_requires_string(__s);
00857 return _M_replace(size_type(0), this->size(), __s,
00858 traits_type::length(__s));
00859 }
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870 __versa_string&
00871 assign(size_type __n, _CharT __c)
00872 { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883 template<class _InputIterator>
00884 __versa_string&
00885 assign(_InputIterator __first, _InputIterator __last)
00886 { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
00887
00888 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00889
00890
00891
00892
00893
00894 __versa_string&
00895 assign(std::initializer_list<_CharT> __l)
00896 { return this->assign(__l.begin(), __l.end()); }
00897 #endif // __GXX_EXPERIMENTAL_CXX0X__
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912 void
00913 insert(iterator __p, size_type __n, _CharT __c)
00914 { this->replace(__p, __p, __n, __c); }
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928 template<class _InputIterator>
00929 void
00930 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
00931 { this->replace(__p, __p, __beg, __end); }
00932
00933 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00934
00935
00936
00937
00938
00939
00940 void
00941 insert(iterator __p, std::initializer_list<_CharT> __l)
00942 { this->insert(__p, __l.begin(), __l.end()); }
00943 #endif // __GXX_EXPERIMENTAL_CXX0X__
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957 __versa_string&
00958 insert(size_type __pos1, const __versa_string& __str)
00959 { return this->replace(__pos1, size_type(0),
00960 __str._M_data(), __str.size()); }
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980 __versa_string&
00981 insert(size_type __pos1, const __versa_string& __str,
00982 size_type __pos2, size_type __n)
00983 { return this->replace(__pos1, size_type(0), __str._M_data()
00984 + __str._M_check(__pos2, "__versa_string::insert"),
00985 __str._M_limit(__pos2, __n)); }
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003 __versa_string&
01004 insert(size_type __pos, const _CharT* __s, size_type __n)
01005 { return this->replace(__pos, size_type(0), __s, __n); }
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022 __versa_string&
01023 insert(size_type __pos, const _CharT* __s)
01024 {
01025 __glibcxx_requires_string(__s);
01026 return this->replace(__pos, size_type(0), __s,
01027 traits_type::length(__s));
01028 }
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046 __versa_string&
01047 insert(size_type __pos, size_type __n, _CharT __c)
01048 { return _M_replace_aux(_M_check(__pos, "__versa_string::insert"),
01049 size_type(0), __n, __c); }
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064 iterator
01065 insert(iterator __p, _CharT __c)
01066 {
01067 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
01068 const size_type __pos = __p - _M_ibegin();
01069 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
01070 this->_M_set_leaked();
01071 return iterator(this->_M_data() + __pos);
01072 }
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089 __versa_string&
01090 erase(size_type __pos = 0, size_type __n = npos)
01091 {
01092 this->_M_erase(_M_check(__pos, "__versa_string::erase"),
01093 _M_limit(__pos, __n));
01094 return *this;
01095 }
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105 iterator
01106 erase(iterator __position)
01107 {
01108 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
01109 && __position < _M_iend());
01110 const size_type __pos = __position - _M_ibegin();
01111 this->_M_erase(__pos, size_type(1));
01112 this->_M_set_leaked();
01113 return iterator(this->_M_data() + __pos);
01114 }
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126 iterator
01127 erase(iterator __first, iterator __last)
01128 {
01129 _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
01130 && __last <= _M_iend());
01131 const size_type __pos = __first - _M_ibegin();
01132 this->_M_erase(__pos, __last - __first);
01133 this->_M_set_leaked();
01134 return iterator(this->_M_data() + __pos);
01135 }
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154 __versa_string&
01155 replace(size_type __pos, size_type __n, const __versa_string& __str)
01156 { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177 __versa_string&
01178 replace(size_type __pos1, size_type __n1, const __versa_string& __str,
01179 size_type __pos2, size_type __n2)
01180 {
01181 return this->replace(__pos1, __n1, __str._M_data()
01182 + __str._M_check(__pos2,
01183 "__versa_string::replace"),
01184 __str._M_limit(__pos2, __n2));
01185 }
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205 __versa_string&
01206 replace(size_type __pos, size_type __n1, const _CharT* __s,
01207 size_type __n2)
01208 {
01209 __glibcxx_requires_string_len(__s, __n2);
01210 return _M_replace(_M_check(__pos, "__versa_string::replace"),
01211 _M_limit(__pos, __n1), __s, __n2);
01212 }
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229 __versa_string&
01230 replace(size_type __pos, size_type __n1, const _CharT* __s)
01231 {
01232 __glibcxx_requires_string(__s);
01233 return this->replace(__pos, __n1, __s, traits_type::length(__s));
01234 }
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253 __versa_string&
01254 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
01255 { return _M_replace_aux(_M_check(__pos, "__versa_string::replace"),
01256 _M_limit(__pos, __n1), __n2, __c); }
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271 __versa_string&
01272 replace(iterator __i1, iterator __i2, const __versa_string& __str)
01273 { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289 __versa_string&
01290 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
01291 {
01292 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01293 && __i2 <= _M_iend());
01294 return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
01295 }
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310 __versa_string&
01311 replace(iterator __i1, iterator __i2, const _CharT* __s)
01312 {
01313 __glibcxx_requires_string(__s);
01314 return this->replace(__i1, __i2, __s, traits_type::length(__s));
01315 }
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331 __versa_string&
01332 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
01333 {
01334 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01335 && __i2 <= _M_iend());
01336 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
01337 }
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353 template<class _InputIterator>
01354 __versa_string&
01355 replace(iterator __i1, iterator __i2,
01356 _InputIterator __k1, _InputIterator __k2)
01357 {
01358 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01359 && __i2 <= _M_iend());
01360 __glibcxx_requires_valid_range(__k1, __k2);
01361 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
01362 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
01363 }
01364
01365
01366
01367 __versa_string&
01368 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
01369 {
01370 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01371 && __i2 <= _M_iend());
01372 __glibcxx_requires_valid_range(__k1, __k2);
01373 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01374 __k1, __k2 - __k1);
01375 }
01376
01377 __versa_string&
01378 replace(iterator __i1, iterator __i2,
01379 const _CharT* __k1, const _CharT* __k2)
01380 {
01381 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01382 && __i2 <= _M_iend());
01383 __glibcxx_requires_valid_range(__k1, __k2);
01384 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01385 __k1, __k2 - __k1);
01386 }
01387
01388 __versa_string&
01389 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
01390 {
01391 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01392 && __i2 <= _M_iend());
01393 __glibcxx_requires_valid_range(__k1, __k2);
01394 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01395 __k1.base(), __k2 - __k1);
01396 }
01397
01398 __versa_string&
01399 replace(iterator __i1, iterator __i2,
01400 const_iterator __k1, const_iterator __k2)
01401 {
01402 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01403 && __i2 <= _M_iend());
01404 __glibcxx_requires_valid_range(__k1, __k2);
01405 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01406 __k1.base(), __k2 - __k1);
01407 }
01408
01409 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423 __versa_string& replace(iterator __i1, iterator __i2,
01424 std::initializer_list<_CharT> __l)
01425 { return this->replace(__i1, __i2, __l.begin(), __l.end()); }
01426 #endif // __GXX_EXPERIMENTAL_CXX0X__
01427
01428 private:
01429 template<class _Integer>
01430 __versa_string&
01431 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
01432 _Integer __val, std::__true_type)
01433 { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
01434
01435 template<class _InputIterator>
01436 __versa_string&
01437 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
01438 _InputIterator __k2, std::__false_type);
01439
01440 __versa_string&
01441 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
01442 _CharT __c);
01443
01444 __versa_string&
01445 _M_replace(size_type __pos, size_type __len1, const _CharT* __s,
01446 const size_type __len2);
01447
01448 __versa_string&
01449 _M_append(const _CharT* __s, size_type __n);
01450
01451 public:
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465 size_type
01466 copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
01467
01468
01469
01470
01471
01472
01473
01474
01475 void
01476 swap(__versa_string& __s)
01477 { this->_M_swap(__s); }
01478
01479
01480
01481
01482
01483
01484
01485
01486 const _CharT*
01487 c_str() const
01488 { return this->_M_data(); }
01489
01490
01491
01492
01493
01494
01495
01496 const _CharT*
01497 data() const
01498 { return this->_M_data(); }
01499
01500
01501
01502
01503 allocator_type
01504 get_allocator() const
01505 { return allocator_type(this->_M_get_allocator()); }
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519 size_type
01520 find(const _CharT* __s, size_type __pos, size_type __n) const;
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532 size_type
01533 find(const __versa_string& __str, size_type __pos = 0) const
01534 { return this->find(__str.data(), __pos, __str.size()); }
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546 size_type
01547 find(const _CharT* __s, size_type __pos = 0) const
01548 {
01549 __glibcxx_requires_string(__s);
01550 return this->find(__s, __pos, traits_type::length(__s));
01551 }
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563 size_type
01564 find(_CharT __c, size_type __pos = 0) const;
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576 size_type
01577 rfind(const __versa_string& __str, size_type __pos = npos) const
01578 { return this->rfind(__str.data(), __pos, __str.size()); }
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592 size_type
01593 rfind(const _CharT* __s, size_type __pos, size_type __n) const;
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605 size_type
01606 rfind(const _CharT* __s, size_type __pos = npos) const
01607 {
01608 __glibcxx_requires_string(__s);
01609 return this->rfind(__s, __pos, traits_type::length(__s));
01610 }
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622 size_type
01623 rfind(_CharT __c, size_type __pos = npos) const;
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635 size_type
01636 find_first_of(const __versa_string& __str, size_type __pos = 0) const
01637 { return this->find_first_of(__str.data(), __pos, __str.size()); }
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651 size_type
01652 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664 size_type
01665 find_first_of(const _CharT* __s, size_type __pos = 0) const
01666 {
01667 __glibcxx_requires_string(__s);
01668 return this->find_first_of(__s, __pos, traits_type::length(__s));
01669 }
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683 size_type
01684 find_first_of(_CharT __c, size_type __pos = 0) const
01685 { return this->find(__c, __pos); }
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698 size_type
01699 find_last_of(const __versa_string& __str, size_type __pos = npos) const
01700 { return this->find_last_of(__str.data(), __pos, __str.size()); }
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714 size_type
01715 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727 size_type
01728 find_last_of(const _CharT* __s, size_type __pos = npos) const
01729 {
01730 __glibcxx_requires_string(__s);
01731 return this->find_last_of(__s, __pos, traits_type::length(__s));
01732 }
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746 size_type
01747 find_last_of(_CharT __c, size_type __pos = npos) const
01748 { return this->rfind(__c, __pos); }
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760 size_type
01761 find_first_not_of(const __versa_string& __str, size_type __pos = 0) const
01762 { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776 size_type
01777 find_first_not_of(const _CharT* __s, size_type __pos,
01778 size_type __n) const;
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790 size_type
01791 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
01792 {
01793 __glibcxx_requires_string(__s);
01794 return this->find_first_not_of(__s, __pos, traits_type::length(__s));
01795 }
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807 size_type
01808 find_first_not_of(_CharT __c, size_type __pos = 0) const;
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821 size_type
01822 find_last_not_of(const __versa_string& __str,
01823 size_type __pos = npos) const
01824 { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838 size_type
01839 find_last_not_of(const _CharT* __s, size_type __pos,
01840 size_type __n) const;
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852 size_type
01853 find_last_not_of(const _CharT* __s, size_type __pos = npos) const
01854 {
01855 __glibcxx_requires_string(__s);
01856 return this->find_last_not_of(__s, __pos, traits_type::length(__s));
01857 }
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869 size_type
01870 find_last_not_of(_CharT __c, size_type __pos = npos) const;
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884 __versa_string
01885 substr(size_type __pos = 0, size_type __n = npos) const
01886 {
01887 return __versa_string(*this, _M_check(__pos, "__versa_string::substr"),
01888 __n);
01889 }
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905 int
01906 compare(const __versa_string& __str) const
01907 {
01908 if (this->_M_compare(__str))
01909 return 0;
01910
01911 const size_type __size = this->size();
01912 const size_type __osize = __str.size();
01913 const size_type __len = std::min(__size, __osize);
01914
01915 int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
01916 if (!__r)
01917 __r = _S_compare(__size, __osize);
01918 return __r;
01919 }
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940 int
01941 compare(size_type __pos, size_type __n,
01942 const __versa_string& __str) const;
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967 int
01968 compare(size_type __pos1, size_type __n1, const __versa_string& __str,
01969 size_type __pos2, size_type __n2) const;
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986 int
01987 compare(const _CharT* __s) const;
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010 int
02011 compare(size_type __pos, size_type __n1, const _CharT* __s) const;
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037 int
02038 compare(size_type __pos, size_type __n1, const _CharT* __s,
02039 size_type __n2) const;
02040 };
02041
02042
02043
02044
02045
02046
02047
02048
02049 template<typename _CharT, typename _Traits, typename _Alloc,
02050 template <typename, typename, typename> class _Base>
02051 __versa_string<_CharT, _Traits, _Alloc, _Base>
02052 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02053 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
02054
02055
02056
02057
02058
02059
02060
02061 template<typename _CharT, typename _Traits, typename _Alloc,
02062 template <typename, typename, typename> class _Base>
02063 __versa_string<_CharT, _Traits, _Alloc, _Base>
02064 operator+(const _CharT* __lhs,
02065 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
02066
02067
02068
02069
02070
02071
02072
02073 template<typename _CharT, typename _Traits, typename _Alloc,
02074 template <typename, typename, typename> class _Base>
02075 __versa_string<_CharT, _Traits, _Alloc, _Base>
02076 operator+(_CharT __lhs,
02077 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
02078
02079
02080
02081
02082
02083
02084
02085 template<typename _CharT, typename _Traits, typename _Alloc,
02086 template <typename, typename, typename> class _Base>
02087 __versa_string<_CharT, _Traits, _Alloc, _Base>
02088 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02089 const _CharT* __rhs);
02090
02091
02092
02093
02094
02095
02096
02097 template<typename _CharT, typename _Traits, typename _Alloc,
02098 template <typename, typename, typename> class _Base>
02099 __versa_string<_CharT, _Traits, _Alloc, _Base>
02100 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02101 _CharT __rhs);
02102
02103 #ifdef __GXX_EXPERIMENTAL_CXX0X__
02104 template<typename _CharT, typename _Traits, typename _Alloc,
02105 template <typename, typename, typename> class _Base>
02106 inline __versa_string<_CharT, _Traits, _Alloc, _Base>
02107 operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
02108 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02109 { return std::move(__lhs.append(__rhs)); }
02110
02111 template<typename _CharT, typename _Traits, typename _Alloc,
02112 template <typename, typename, typename> class _Base>
02113 inline __versa_string<_CharT, _Traits, _Alloc, _Base>
02114 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02115 __versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
02116 { return std::move(__rhs.insert(0, __lhs)); }
02117
02118 template<typename _CharT, typename _Traits, typename _Alloc,
02119 template <typename, typename, typename> class _Base>
02120 inline __versa_string<_CharT, _Traits, _Alloc, _Base>
02121 operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
02122 __versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
02123 {
02124 const auto __size = __lhs.size() + __rhs.size();
02125 const bool __cond = (__size > __lhs.capacity()
02126 && __size <= __rhs.capacity());
02127 return __cond ? std::move(__rhs.insert(0, __lhs))
02128 : std::move(__lhs.append(__rhs));
02129 }
02130
02131 template<typename _CharT, typename _Traits, typename _Alloc,
02132 template <typename, typename, typename> class _Base>
02133 inline __versa_string<_CharT, _Traits, _Alloc, _Base>
02134 operator+(const _CharT* __lhs,
02135 __versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
02136 { return std::move(__rhs.insert(0, __lhs)); }
02137
02138 template<typename _CharT, typename _Traits, typename _Alloc,
02139 template <typename, typename, typename> class _Base>
02140 inline __versa_string<_CharT, _Traits, _Alloc, _Base>
02141 operator+(_CharT __lhs,
02142 __versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
02143 { return std::move(__rhs.insert(0, 1, __lhs)); }
02144
02145 template<typename _CharT, typename _Traits, typename _Alloc,
02146 template <typename, typename, typename> class _Base>
02147 inline __versa_string<_CharT, _Traits, _Alloc, _Base>
02148 operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
02149 const _CharT* __rhs)
02150 { return std::move(__lhs.append(__rhs)); }
02151
02152 template<typename _CharT, typename _Traits, typename _Alloc,
02153 template <typename, typename, typename> class _Base>
02154 inline __versa_string<_CharT, _Traits, _Alloc, _Base>
02155 operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
02156 _CharT __rhs)
02157 { return std::move(__lhs.append(1, __rhs)); }
02158 #endif
02159
02160
02161
02162
02163
02164
02165
02166
02167 template<typename _CharT, typename _Traits, typename _Alloc,
02168 template <typename, typename, typename> class _Base>
02169 inline bool
02170 operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02171 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02172 { return __lhs.compare(__rhs) == 0; }
02173
02174 template<typename _CharT,
02175 template <typename, typename, typename> class _Base>
02176 inline typename __enable_if<std::__is_char<_CharT>::__value, bool>::__type
02177 operator==(const __versa_string<_CharT, std::char_traits<_CharT>,
02178 std::allocator<_CharT>, _Base>& __lhs,
02179 const __versa_string<_CharT, std::char_traits<_CharT>,
02180 std::allocator<_CharT>, _Base>& __rhs)
02181 { return (__lhs.size() == __rhs.size()
02182 && !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(),
02183 __lhs.size())); }
02184
02185
02186
02187
02188
02189
02190
02191 template<typename _CharT, typename _Traits, typename _Alloc,
02192 template <typename, typename, typename> class _Base>
02193 inline bool
02194 operator==(const _CharT* __lhs,
02195 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02196 { return __rhs.compare(__lhs) == 0; }
02197
02198
02199
02200
02201
02202
02203
02204 template<typename _CharT, typename _Traits, typename _Alloc,
02205 template <typename, typename, typename> class _Base>
02206 inline bool
02207 operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02208 const _CharT* __rhs)
02209 { return __lhs.compare(__rhs) == 0; }
02210
02211
02212
02213
02214
02215
02216
02217
02218 template<typename _CharT, typename _Traits, typename _Alloc,
02219 template <typename, typename, typename> class _Base>
02220 inline bool
02221 operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02222 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02223 { return !(__lhs == __rhs); }
02224
02225
02226
02227
02228
02229
02230
02231 template<typename _CharT, typename _Traits, typename _Alloc,
02232 template <typename, typename, typename> class _Base>
02233 inline bool
02234 operator!=(const _CharT* __lhs,
02235 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02236 { return !(__lhs == __rhs); }
02237
02238
02239
02240
02241
02242
02243
02244 template<typename _CharT, typename _Traits, typename _Alloc,
02245 template <typename, typename, typename> class _Base>
02246 inline bool
02247 operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02248 const _CharT* __rhs)
02249 { return !(__lhs == __rhs); }
02250
02251
02252
02253
02254
02255
02256
02257
02258 template<typename _CharT, typename _Traits, typename _Alloc,
02259 template <typename, typename, typename> class _Base>
02260 inline bool
02261 operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02262 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02263 { return __lhs.compare(__rhs) < 0; }
02264
02265
02266
02267
02268
02269
02270
02271 template<typename _CharT, typename _Traits, typename _Alloc,
02272 template <typename, typename, typename> class _Base>
02273 inline bool
02274 operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02275 const _CharT* __rhs)
02276 { return __lhs.compare(__rhs) < 0; }
02277
02278
02279
02280
02281
02282
02283
02284 template<typename _CharT, typename _Traits, typename _Alloc,
02285 template <typename, typename, typename> class _Base>
02286 inline bool
02287 operator<(const _CharT* __lhs,
02288 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02289 { return __rhs.compare(__lhs) > 0; }
02290
02291
02292
02293
02294
02295
02296
02297
02298 template<typename _CharT, typename _Traits, typename _Alloc,
02299 template <typename, typename, typename> class _Base>
02300 inline bool
02301 operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02302 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02303 { return __lhs.compare(__rhs) > 0; }
02304
02305
02306
02307
02308
02309
02310
02311 template<typename _CharT, typename _Traits, typename _Alloc,
02312 template <typename, typename, typename> class _Base>
02313 inline bool
02314 operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02315 const _CharT* __rhs)
02316 { return __lhs.compare(__rhs) > 0; }
02317
02318
02319
02320
02321
02322
02323
02324 template<typename _CharT, typename _Traits, typename _Alloc,
02325 template <typename, typename, typename> class _Base>
02326 inline bool
02327 operator>(const _CharT* __lhs,
02328 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02329 { return __rhs.compare(__lhs) < 0; }
02330
02331
02332
02333
02334
02335
02336
02337
02338 template<typename _CharT, typename _Traits, typename _Alloc,
02339 template <typename, typename, typename> class _Base>
02340 inline bool
02341 operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02342 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02343 { return __lhs.compare(__rhs) <= 0; }
02344
02345
02346
02347
02348
02349
02350
02351 template<typename _CharT, typename _Traits, typename _Alloc,
02352 template <typename, typename, typename> class _Base>
02353 inline bool
02354 operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02355 const _CharT* __rhs)
02356 { return __lhs.compare(__rhs) <= 0; }
02357
02358
02359
02360
02361
02362
02363
02364 template<typename _CharT, typename _Traits, typename _Alloc,
02365 template <typename, typename, typename> class _Base>
02366 inline bool
02367 operator<=(const _CharT* __lhs,
02368 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02369 { return __rhs.compare(__lhs) >= 0; }
02370
02371
02372
02373
02374
02375
02376
02377
02378 template<typename _CharT, typename _Traits, typename _Alloc,
02379 template <typename, typename, typename> class _Base>
02380 inline bool
02381 operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02382 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02383 { return __lhs.compare(__rhs) >= 0; }
02384
02385
02386
02387
02388
02389
02390
02391 template<typename _CharT, typename _Traits, typename _Alloc,
02392 template <typename, typename, typename> class _Base>
02393 inline bool
02394 operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02395 const _CharT* __rhs)
02396 { return __lhs.compare(__rhs) >= 0; }
02397
02398
02399
02400
02401
02402
02403
02404 template<typename _CharT, typename _Traits, typename _Alloc,
02405 template <typename, typename, typename> class _Base>
02406 inline bool
02407 operator>=(const _CharT* __lhs,
02408 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02409 { return __rhs.compare(__lhs) <= 0; }
02410
02411
02412
02413
02414
02415
02416
02417
02418 template<typename _CharT, typename _Traits, typename _Alloc,
02419 template <typename, typename, typename> class _Base>
02420 inline void
02421 swap(__versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02422 __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02423 { __lhs.swap(__rhs); }
02424
02425 _GLIBCXX_END_NAMESPACE_VERSION
02426 }
02427
02428 namespace std _GLIBCXX_VISIBILITY(default)
02429 {
02430 _GLIBCXX_BEGIN_NAMESPACE_VERSION
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441
02442
02443
02444 template<typename _CharT, typename _Traits, typename _Alloc,
02445 template <typename, typename, typename> class _Base>
02446 basic_istream<_CharT, _Traits>&
02447 operator>>(basic_istream<_CharT, _Traits>& __is,
02448 __gnu_cxx::__versa_string<_CharT, _Traits,
02449 _Alloc, _Base>& __str);
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460 template<typename _CharT, typename _Traits, typename _Alloc,
02461 template <typename, typename, typename> class _Base>
02462 inline basic_ostream<_CharT, _Traits>&
02463 operator<<(basic_ostream<_CharT, _Traits>& __os,
02464 const __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
02465 _Base>& __str)
02466 {
02467
02468
02469 return __ostream_insert(__os, __str.data(), __str.size());
02470 }
02471
02472
02473
02474
02475
02476
02477
02478
02479
02480
02481
02482
02483
02484
02485
02486 template<typename _CharT, typename _Traits, typename _Alloc,
02487 template <typename, typename, typename> class _Base>
02488 basic_istream<_CharT, _Traits>&
02489 getline(basic_istream<_CharT, _Traits>& __is,
02490 __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str,
02491 _CharT __delim);
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506 template<typename _CharT, typename _Traits, typename _Alloc,
02507 template <typename, typename, typename> class _Base>
02508 inline basic_istream<_CharT, _Traits>&
02509 getline(basic_istream<_CharT, _Traits>& __is,
02510 __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str)
02511 { return getline(__is, __str, __is.widen('\n')); }
02512
02513 _GLIBCXX_END_NAMESPACE_VERSION
02514 }
02515
02516 #if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99))
02517
02518 #include <ext/string_conversions.h>
02519
02520 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
02521 {
02522 _GLIBCXX_BEGIN_NAMESPACE_VERSION
02523
02524
02525 inline int
02526 stoi(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
02527 { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi", __str.c_str(),
02528 __idx, __base); }
02529
02530 inline long
02531 stol(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
02532 { return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(),
02533 __idx, __base); }
02534
02535 inline unsigned long
02536 stoul(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
02537 { return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(),
02538 __idx, __base); }
02539
02540 inline long long
02541 stoll(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
02542 { return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(),
02543 __idx, __base); }
02544
02545 inline unsigned long long
02546 stoull(const __vstring& __str, std::size_t* __idx, int __base = 10)
02547 { return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(),
02548 __idx, __base); }
02549
02550
02551 inline float
02552 stof(const __vstring& __str, std::size_t* __idx = 0)
02553 { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); }
02554
02555 inline double
02556 stod(const __vstring& __str, std::size_t* __idx = 0)
02557 { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); }
02558
02559 inline long double
02560 stold(const __vstring& __str, std::size_t* __idx = 0)
02561 { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
02562
02563
02564
02565
02566 inline __vstring
02567 to_string(int __val)
02568 { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, 4 * sizeof(int),
02569 "%d", __val); }
02570
02571 inline __vstring
02572 to_string(unsigned __val)
02573 { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
02574 4 * sizeof(unsigned),
02575 "%u", __val); }
02576
02577 inline __vstring
02578 to_string(long __val)
02579 { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
02580 4 * sizeof(long),
02581 "%ld", __val); }
02582
02583 inline __vstring
02584 to_string(unsigned long __val)
02585 { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
02586 4 * sizeof(unsigned long),
02587 "%lu", __val); }
02588
02589
02590 inline __vstring
02591 to_string(long long __val)
02592 { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
02593 4 * sizeof(long long),
02594 "%lld", __val); }
02595
02596 inline __vstring
02597 to_string(unsigned long long __val)
02598 { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
02599 4 * sizeof(unsigned long long),
02600 "%llu", __val); }
02601
02602 inline __vstring
02603 to_string(float __val)
02604 {
02605 const int __n = __numeric_traits<float>::__max_exponent10 + 20;
02606 return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
02607 "%f", __val);
02608 }
02609
02610 inline __vstring
02611 to_string(double __val)
02612 {
02613 const int __n = __numeric_traits<double>::__max_exponent10 + 20;
02614 return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
02615 "%f", __val);
02616 }
02617
02618 inline __vstring
02619 to_string(long double __val)
02620 {
02621 const int __n = __numeric_traits<long double>::__max_exponent10 + 20;
02622 return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
02623 "%Lf", __val);
02624 }
02625
02626 #ifdef _GLIBCXX_USE_WCHAR_T
02627 inline int
02628 stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
02629 { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
02630 __idx, __base); }
02631
02632 inline long
02633 stol(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
02634 { return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(),
02635 __idx, __base); }
02636
02637 inline unsigned long
02638 stoul(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
02639 { return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(),
02640 __idx, __base); }
02641
02642 inline long long
02643 stoll(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
02644 { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
02645 __idx, __base); }
02646
02647 inline unsigned long long
02648 stoull(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
02649 { return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(),
02650 __idx, __base); }
02651
02652
02653 inline float
02654 stof(const __wvstring& __str, std::size_t* __idx = 0)
02655 { return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); }
02656
02657 inline double
02658 stod(const __wvstring& __str, std::size_t* __idx = 0)
02659 { return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); }
02660
02661 inline long double
02662 stold(const __wvstring& __str, std::size_t* __idx = 0)
02663 { return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); }
02664
02665 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
02666
02667 inline __wvstring
02668 to_wstring(int __val)
02669 { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
02670 4 * sizeof(int),
02671 L"%d", __val); }
02672
02673 inline __wvstring
02674 to_wstring(unsigned __val)
02675 { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
02676 4 * sizeof(unsigned),
02677 L"%u", __val); }
02678
02679 inline __wvstring
02680 to_wstring(long __val)
02681 { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
02682 4 * sizeof(long),
02683 L"%ld", __val); }
02684
02685 inline __wvstring
02686 to_wstring(unsigned long __val)
02687 { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
02688 4 * sizeof(unsigned long),
02689 L"%lu", __val); }
02690
02691 inline __wvstring
02692 to_wstring(long long __val)
02693 { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
02694 4 * sizeof(long long),
02695 L"%lld", __val); }
02696
02697 inline __wvstring
02698 to_wstring(unsigned long long __val)
02699 { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
02700 4 * sizeof(unsigned long long),
02701 L"%llu", __val); }
02702
02703 inline __wvstring
02704 to_wstring(float __val)
02705 {
02706 const int __n = __numeric_traits<float>::__max_exponent10 + 20;
02707 return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
02708 L"%f", __val);
02709 }
02710
02711 inline __wvstring
02712 to_wstring(double __val)
02713 {
02714 const int __n = __numeric_traits<double>::__max_exponent10 + 20;
02715 return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
02716 L"%f", __val);
02717 }
02718
02719 inline __wvstring
02720 to_wstring(long double __val)
02721 {
02722 const int __n = __numeric_traits<long double>::__max_exponent10 + 20;
02723 return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
02724 L"%Lf", __val);
02725 }
02726 #endif
02727 #endif
02728
02729 _GLIBCXX_END_NAMESPACE_VERSION
02730 }
02731
02732 #endif
02733
02734 #ifdef __GXX_EXPERIMENTAL_CXX0X__
02735
02736 #include <bits/functional_hash.h>
02737
02738 namespace std _GLIBCXX_VISIBILITY(default)
02739 {
02740 _GLIBCXX_BEGIN_NAMESPACE_VERSION
02741
02742
02743 template<>
02744 struct hash<__gnu_cxx::__vstring>
02745 : public __hash_base<size_t, __gnu_cxx::__vstring>
02746 {
02747 size_t
02748 operator()(const __gnu_cxx::__vstring& __s) const
02749 { return std::_Hash_impl::hash(__s.data(), __s.length()); }
02750 };
02751
02752 #ifdef _GLIBCXX_USE_WCHAR_T
02753
02754 template<>
02755 struct hash<__gnu_cxx::__wvstring>
02756 : public __hash_base<size_t, __gnu_cxx::__wvstring>
02757 {
02758 size_t
02759 operator()(const __gnu_cxx::__wvstring& __s) const
02760 { return std::_Hash_impl::hash(__s.data(),
02761 __s.length() * sizeof(wchar_t)); }
02762 };
02763 #endif
02764
02765 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
02766
02767 template<>
02768 struct hash<__gnu_cxx::__u16vstring>
02769 : public __hash_base<size_t, __gnu_cxx::__u16vstring>
02770 {
02771 size_t
02772 operator()(const __gnu_cxx::__u16vstring& __s) const
02773 { return std::_Hash_impl::hash(__s.data(),
02774 __s.length() * sizeof(char16_t)); }
02775 };
02776
02777
02778 template<>
02779 struct hash<__gnu_cxx::__u32vstring>
02780 : public __hash_base<size_t, __gnu_cxx::__u32vstring>
02781 {
02782 size_t
02783 operator()(const __gnu_cxx::__u32vstring& __s) const
02784 { return std::_Hash_impl::hash(__s.data(),
02785 __s.length() * sizeof(char32_t)); }
02786 };
02787 #endif
02788
02789 _GLIBCXX_END_NAMESPACE_VERSION
02790 }
02791
02792 #endif
02793
02794 #include "vstring.tcc"
02795
02796 #endif