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