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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _STL_VECTOR_H
00058 #define _STL_VECTOR_H 1
00059
00060 #include <bits/stl_iterator_base_funcs.h>
00061 #include <bits/functexcept.h>
00062 #include <bits/concept_check.h>
00063 #include <initializer_list>
00064
00065 namespace std _GLIBCXX_VISIBILITY(default)
00066 {
00067 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
00068
00069
00070 template<typename _Tp, typename _Alloc>
00071 struct _Vector_base
00072 {
00073 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
00074
00075 struct _Vector_impl
00076 : public _Tp_alloc_type
00077 {
00078 typename _Tp_alloc_type::pointer _M_start;
00079 typename _Tp_alloc_type::pointer _M_finish;
00080 typename _Tp_alloc_type::pointer _M_end_of_storage;
00081
00082 _Vector_impl()
00083 : _Tp_alloc_type(), _M_start(0), _M_finish(0), _M_end_of_storage(0)
00084 { }
00085
00086 _Vector_impl(_Tp_alloc_type const& __a)
00087 : _Tp_alloc_type(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
00088 { }
00089 };
00090
00091 public:
00092 typedef _Alloc allocator_type;
00093
00094 _Tp_alloc_type&
00095 _M_get_Tp_allocator()
00096 { return *static_cast<_Tp_alloc_type*>(&this->_M_impl); }
00097
00098 const _Tp_alloc_type&
00099 _M_get_Tp_allocator() const
00100 { return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); }
00101
00102 allocator_type
00103 get_allocator() const
00104 { return allocator_type(_M_get_Tp_allocator()); }
00105
00106 _Vector_base()
00107 : _M_impl() { }
00108
00109 _Vector_base(const allocator_type& __a)
00110 : _M_impl(__a) { }
00111
00112 _Vector_base(size_t __n)
00113 : _M_impl()
00114 {
00115 this->_M_impl._M_start = this->_M_allocate(__n);
00116 this->_M_impl._M_finish = this->_M_impl._M_start;
00117 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
00118 }
00119
00120 _Vector_base(size_t __n, const allocator_type& __a)
00121 : _M_impl(__a)
00122 {
00123 this->_M_impl._M_start = this->_M_allocate(__n);
00124 this->_M_impl._M_finish = this->_M_impl._M_start;
00125 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
00126 }
00127
00128 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00129 _Vector_base(_Vector_base&& __x)
00130 : _M_impl(__x._M_get_Tp_allocator())
00131 {
00132 this->_M_impl._M_start = __x._M_impl._M_start;
00133 this->_M_impl._M_finish = __x._M_impl._M_finish;
00134 this->_M_impl._M_end_of_storage = __x._M_impl._M_end_of_storage;
00135 __x._M_impl._M_start = 0;
00136 __x._M_impl._M_finish = 0;
00137 __x._M_impl._M_end_of_storage = 0;
00138 }
00139 #endif
00140
00141 ~_Vector_base()
00142 { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
00143 - this->_M_impl._M_start); }
00144
00145 public:
00146 _Vector_impl _M_impl;
00147
00148 typename _Tp_alloc_type::pointer
00149 _M_allocate(size_t __n)
00150 { return __n != 0 ? _M_impl.allocate(__n) : 0; }
00151
00152 void
00153 _M_deallocate(typename _Tp_alloc_type::pointer __p, size_t __n)
00154 {
00155 if (__p)
00156 _M_impl.deallocate(__p, __n);
00157 }
00158 };
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
00180 class vector : protected _Vector_base<_Tp, _Alloc>
00181 {
00182
00183 typedef typename _Alloc::value_type _Alloc_value_type;
00184 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
00185 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
00186
00187 typedef _Vector_base<_Tp, _Alloc> _Base;
00188 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
00189
00190 public:
00191 typedef _Tp value_type;
00192 typedef typename _Tp_alloc_type::pointer pointer;
00193 typedef typename _Tp_alloc_type::const_pointer const_pointer;
00194 typedef typename _Tp_alloc_type::reference reference;
00195 typedef typename _Tp_alloc_type::const_reference const_reference;
00196 typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
00197 typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
00198 const_iterator;
00199 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00200 typedef std::reverse_iterator<iterator> reverse_iterator;
00201 typedef size_t size_type;
00202 typedef ptrdiff_t difference_type;
00203 typedef _Alloc allocator_type;
00204
00205 protected:
00206 using _Base::_M_allocate;
00207 using _Base::_M_deallocate;
00208 using _Base::_M_impl;
00209 using _Base::_M_get_Tp_allocator;
00210
00211 public:
00212
00213
00214
00215
00216
00217 vector()
00218 : _Base() { }
00219
00220
00221
00222
00223
00224 explicit
00225 vector(const allocator_type& __a)
00226 : _Base(__a) { }
00227
00228 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00229
00230
00231
00232
00233
00234
00235
00236 explicit
00237 vector(size_type __n)
00238 : _Base(__n)
00239 { _M_default_initialize(__n); }
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 vector(size_type __n, const value_type& __value,
00250 const allocator_type& __a = allocator_type())
00251 : _Base(__n, __a)
00252 { _M_fill_initialize(__n, __value); }
00253 #else
00254
00255
00256
00257
00258
00259
00260
00261
00262 explicit
00263 vector(size_type __n, const value_type& __value = value_type(),
00264 const allocator_type& __a = allocator_type())
00265 : _Base(__n, __a)
00266 { _M_fill_initialize(__n, __value); }
00267 #endif
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 vector(const vector& __x)
00279 : _Base(__x.size(), __x._M_get_Tp_allocator())
00280 { this->_M_impl._M_finish =
00281 std::__uninitialized_copy_a(__x.begin(), __x.end(),
00282 this->_M_impl._M_start,
00283 _M_get_Tp_allocator());
00284 }
00285
00286 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00287
00288
00289
00290
00291
00292
00293
00294 vector(vector&& __x)
00295 : _Base(std::move(__x)) { }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308 vector(initializer_list<value_type> __l,
00309 const allocator_type& __a = allocator_type())
00310 : _Base(__a)
00311 {
00312 _M_range_initialize(__l.begin(), __l.end(),
00313 random_access_iterator_tag());
00314 }
00315 #endif
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 template<typename _InputIterator>
00334 vector(_InputIterator __first, _InputIterator __last,
00335 const allocator_type& __a = allocator_type())
00336 : _Base(__a)
00337 {
00338
00339 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
00340 _M_initialize_dispatch(__first, __last, _Integral());
00341 }
00342
00343
00344
00345
00346
00347
00348
00349 ~vector()
00350 { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
00351 _M_get_Tp_allocator()); }
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 vector&
00362 operator=(const vector& __x);
00363
00364 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00365
00366
00367
00368
00369
00370
00371
00372 vector&
00373 operator=(vector&& __x)
00374 {
00375
00376
00377 this->clear();
00378 this->swap(__x);
00379 return *this;
00380 }
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393 vector&
00394 operator=(initializer_list<value_type> __l)
00395 {
00396 this->assign(__l.begin(), __l.end());
00397 return *this;
00398 }
00399 #endif
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411 void
00412 assign(size_type __n, const value_type& __val)
00413 { _M_fill_assign(__n, __val); }
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427 template<typename _InputIterator>
00428 void
00429 assign(_InputIterator __first, _InputIterator __last)
00430 {
00431
00432 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
00433 _M_assign_dispatch(__first, __last, _Integral());
00434 }
00435
00436 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448 void
00449 assign(initializer_list<value_type> __l)
00450 { this->assign(__l.begin(), __l.end()); }
00451 #endif
00452
00453
00454 using _Base::get_allocator;
00455
00456
00457
00458
00459
00460
00461
00462 iterator
00463 begin()
00464 { return iterator(this->_M_impl._M_start); }
00465
00466
00467
00468
00469
00470
00471 const_iterator
00472 begin() const
00473 { return const_iterator(this->_M_impl._M_start); }
00474
00475
00476
00477
00478
00479
00480 iterator
00481 end()
00482 { return iterator(this->_M_impl._M_finish); }
00483
00484
00485
00486
00487
00488
00489 const_iterator
00490 end() const
00491 { return const_iterator(this->_M_impl._M_finish); }
00492
00493
00494
00495
00496
00497
00498 reverse_iterator
00499 rbegin()
00500 { return reverse_iterator(end()); }
00501
00502
00503
00504
00505
00506
00507 const_reverse_iterator
00508 rbegin() const
00509 { return const_reverse_iterator(end()); }
00510
00511
00512
00513
00514
00515
00516 reverse_iterator
00517 rend()
00518 { return reverse_iterator(begin()); }
00519
00520
00521
00522
00523
00524
00525 const_reverse_iterator
00526 rend() const
00527 { return const_reverse_iterator(begin()); }
00528
00529 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00530
00531
00532
00533
00534
00535 const_iterator
00536 cbegin() const
00537 { return const_iterator(this->_M_impl._M_start); }
00538
00539
00540
00541
00542
00543
00544 const_iterator
00545 cend() const
00546 { return const_iterator(this->_M_impl._M_finish); }
00547
00548
00549
00550
00551
00552
00553 const_reverse_iterator
00554 crbegin() const
00555 { return const_reverse_iterator(end()); }
00556
00557
00558
00559
00560
00561
00562 const_reverse_iterator
00563 crend() const
00564 { return const_reverse_iterator(begin()); }
00565 #endif
00566
00567
00568
00569 size_type
00570 size() const
00571 { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
00572
00573
00574 size_type
00575 max_size() const
00576 { return _M_get_Tp_allocator().max_size(); }
00577
00578 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588 void
00589 resize(size_type __new_size)
00590 {
00591 if (__new_size > size())
00592 _M_default_append(__new_size - size());
00593 else if (__new_size < size())
00594 _M_erase_at_end(this->_M_impl._M_start + __new_size);
00595 }
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608 void
00609 resize(size_type __new_size, const value_type& __x)
00610 {
00611 if (__new_size > size())
00612 insert(end(), __new_size - size(), __x);
00613 else if (__new_size < size())
00614 _M_erase_at_end(this->_M_impl._M_start + __new_size);
00615 }
00616 #else
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628 void
00629 resize(size_type __new_size, value_type __x = value_type())
00630 {
00631 if (__new_size > size())
00632 insert(end(), __new_size - size(), __x);
00633 else if (__new_size < size())
00634 _M_erase_at_end(this->_M_impl._M_start + __new_size);
00635 }
00636 #endif
00637
00638 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00639
00640 void
00641 shrink_to_fit()
00642 { std::__shrink_to_fit<vector>::_S_do_it(*this); }
00643 #endif
00644
00645
00646
00647
00648
00649 size_type
00650 capacity() const
00651 { return size_type(this->_M_impl._M_end_of_storage
00652 - this->_M_impl._M_start); }
00653
00654
00655
00656
00657
00658 bool
00659 empty() const
00660 { return begin() == end(); }
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679 void
00680 reserve(size_type __n);
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694 reference
00695 operator[](size_type __n)
00696 { return *(this->_M_impl._M_start + __n); }
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709 const_reference
00710 operator[](size_type __n) const
00711 { return *(this->_M_impl._M_start + __n); }
00712
00713 protected:
00714
00715 void
00716 _M_range_check(size_type __n) const
00717 {
00718 if (__n >= this->size())
00719 __throw_out_of_range(__N("vector::_M_range_check"));
00720 }
00721
00722 public:
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734 reference
00735 at(size_type __n)
00736 {
00737 _M_range_check(__n);
00738 return (*this)[__n];
00739 }
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752 const_reference
00753 at(size_type __n) const
00754 {
00755 _M_range_check(__n);
00756 return (*this)[__n];
00757 }
00758
00759
00760
00761
00762
00763 reference
00764 front()
00765 { return *begin(); }
00766
00767
00768
00769
00770
00771 const_reference
00772 front() const
00773 { return *begin(); }
00774
00775
00776
00777
00778
00779 reference
00780 back()
00781 { return *(end() - 1); }
00782
00783
00784
00785
00786
00787 const_reference
00788 back() const
00789 { return *(end() - 1); }
00790
00791
00792
00793
00794
00795
00796
00797
00798 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00799 _Tp*
00800 #else
00801 pointer
00802 #endif
00803 data()
00804 { return std::__addressof(front()); }
00805
00806 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00807 const _Tp*
00808 #else
00809 const_pointer
00810 #endif
00811 data() const
00812 { return std::__addressof(front()); }
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825 void
00826 push_back(const value_type& __x)
00827 {
00828 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
00829 {
00830 this->_M_impl.construct(this->_M_impl._M_finish, __x);
00831 ++this->_M_impl._M_finish;
00832 }
00833 else
00834 _M_insert_aux(end(), __x);
00835 }
00836
00837 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00838 void
00839 push_back(value_type&& __x)
00840 { emplace_back(std::move(__x)); }
00841
00842 template<typename... _Args>
00843 void
00844 emplace_back(_Args&&... __args);
00845 #endif
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856 void
00857 pop_back()
00858 {
00859 --this->_M_impl._M_finish;
00860 this->_M_impl.destroy(this->_M_impl._M_finish);
00861 }
00862
00863 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876 template<typename... _Args>
00877 iterator
00878 emplace(iterator __position, _Args&&... __args);
00879 #endif
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892 iterator
00893 insert(iterator __position, const value_type& __x);
00894
00895 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907 iterator
00908 insert(iterator __position, value_type&& __x)
00909 { return emplace(__position, std::move(__x)); }
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924 void
00925 insert(iterator __position, initializer_list<value_type> __l)
00926 { this->insert(__position, __l.begin(), __l.end()); }
00927 #endif
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942 void
00943 insert(iterator __position, size_type __n, const value_type& __x)
00944 { _M_fill_insert(__position, __n, __x); }
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960 template<typename _InputIterator>
00961 void
00962 insert(iterator __position, _InputIterator __first,
00963 _InputIterator __last)
00964 {
00965
00966 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
00967 _M_insert_dispatch(__position, __first, __last, _Integral());
00968 }
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985 iterator
00986 erase(iterator __position);
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006 iterator
01007 erase(iterator __first, iterator __last);
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018 void
01019 swap(vector& __x)
01020 {
01021 std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
01022 std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
01023 std::swap(this->_M_impl._M_end_of_storage,
01024 __x._M_impl._M_end_of_storage);
01025
01026
01027
01028 std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(),
01029 __x._M_get_Tp_allocator());
01030 }
01031
01032
01033
01034
01035
01036
01037
01038 void
01039 clear()
01040 { _M_erase_at_end(this->_M_impl._M_start); }
01041
01042 protected:
01043
01044
01045
01046
01047 template<typename _ForwardIterator>
01048 pointer
01049 _M_allocate_and_copy(size_type __n,
01050 _ForwardIterator __first, _ForwardIterator __last)
01051 {
01052 pointer __result = this->_M_allocate(__n);
01053 __try
01054 {
01055 std::__uninitialized_copy_a(__first, __last, __result,
01056 _M_get_Tp_allocator());
01057 return __result;
01058 }
01059 __catch(...)
01060 {
01061 _M_deallocate(__result, __n);
01062 __throw_exception_again;
01063 }
01064 }
01065
01066
01067
01068
01069
01070
01071
01072
01073 template<typename _Integer>
01074 void
01075 _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
01076 {
01077 this->_M_impl._M_start = _M_allocate(static_cast<size_type>(__n));
01078 this->_M_impl._M_end_of_storage =
01079 this->_M_impl._M_start + static_cast<size_type>(__n);
01080 _M_fill_initialize(static_cast<size_type>(__n), __value);
01081 }
01082
01083
01084 template<typename _InputIterator>
01085 void
01086 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
01087 __false_type)
01088 {
01089 typedef typename std::iterator_traits<_InputIterator>::
01090 iterator_category _IterCategory;
01091 _M_range_initialize(__first, __last, _IterCategory());
01092 }
01093
01094
01095 template<typename _InputIterator>
01096 void
01097 _M_range_initialize(_InputIterator __first,
01098 _InputIterator __last, std::input_iterator_tag)
01099 {
01100 for (; __first != __last; ++__first)
01101 push_back(*__first);
01102 }
01103
01104
01105 template<typename _ForwardIterator>
01106 void
01107 _M_range_initialize(_ForwardIterator __first,
01108 _ForwardIterator __last, std::forward_iterator_tag)
01109 {
01110 const size_type __n = std::distance(__first, __last);
01111 this->_M_impl._M_start = this->_M_allocate(__n);
01112 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
01113 this->_M_impl._M_finish =
01114 std::__uninitialized_copy_a(__first, __last,
01115 this->_M_impl._M_start,
01116 _M_get_Tp_allocator());
01117 }
01118
01119
01120
01121 void
01122 _M_fill_initialize(size_type __n, const value_type& __value)
01123 {
01124 std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
01125 _M_get_Tp_allocator());
01126 this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
01127 }
01128
01129 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01130
01131 void
01132 _M_default_initialize(size_type __n)
01133 {
01134 std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
01135 _M_get_Tp_allocator());
01136 this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
01137 }
01138 #endif
01139
01140
01141
01142
01143
01144
01145
01146
01147 template<typename _Integer>
01148 void
01149 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
01150 { _M_fill_assign(__n, __val); }
01151
01152
01153 template<typename _InputIterator>
01154 void
01155 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
01156 __false_type)
01157 {
01158 typedef typename std::iterator_traits<_InputIterator>::
01159 iterator_category _IterCategory;
01160 _M_assign_aux(__first, __last, _IterCategory());
01161 }
01162
01163
01164 template<typename _InputIterator>
01165 void
01166 _M_assign_aux(_InputIterator __first, _InputIterator __last,
01167 std::input_iterator_tag);
01168
01169
01170 template<typename _ForwardIterator>
01171 void
01172 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
01173 std::forward_iterator_tag);
01174
01175
01176
01177 void
01178 _M_fill_assign(size_type __n, const value_type& __val);
01179
01180
01181
01182
01183
01184
01185
01186
01187 template<typename _Integer>
01188 void
01189 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
01190 __true_type)
01191 { _M_fill_insert(__pos, __n, __val); }
01192
01193
01194 template<typename _InputIterator>
01195 void
01196 _M_insert_dispatch(iterator __pos, _InputIterator __first,
01197 _InputIterator __last, __false_type)
01198 {
01199 typedef typename std::iterator_traits<_InputIterator>::
01200 iterator_category _IterCategory;
01201 _M_range_insert(__pos, __first, __last, _IterCategory());
01202 }
01203
01204
01205 template<typename _InputIterator>
01206 void
01207 _M_range_insert(iterator __pos, _InputIterator __first,
01208 _InputIterator __last, std::input_iterator_tag);
01209
01210
01211 template<typename _ForwardIterator>
01212 void
01213 _M_range_insert(iterator __pos, _ForwardIterator __first,
01214 _ForwardIterator __last, std::forward_iterator_tag);
01215
01216
01217
01218 void
01219 _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
01220
01221 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01222
01223 void
01224 _M_default_append(size_type __n);
01225 #endif
01226
01227
01228 #ifndef __GXX_EXPERIMENTAL_CXX0X__
01229 void
01230 _M_insert_aux(iterator __position, const value_type& __x);
01231 #else
01232 template<typename... _Args>
01233 void
01234 _M_insert_aux(iterator __position, _Args&&... __args);
01235 #endif
01236
01237
01238 size_type
01239 _M_check_len(size_type __n, const char* __s) const
01240 {
01241 if (max_size() - size() < __n)
01242 __throw_length_error(__N(__s));
01243
01244 const size_type __len = size() + std::max(size(), __n);
01245 return (__len < size() || __len > max_size()) ? max_size() : __len;
01246 }
01247
01248
01249
01250
01251
01252 void
01253 _M_erase_at_end(pointer __pos)
01254 {
01255 std::_Destroy(__pos, this->_M_impl._M_finish, _M_get_Tp_allocator());
01256 this->_M_impl._M_finish = __pos;
01257 }
01258 };
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271 template<typename _Tp, typename _Alloc>
01272 inline bool
01273 operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
01274 { return (__x.size() == __y.size()
01275 && std::equal(__x.begin(), __x.end(), __y.begin())); }
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288 template<typename _Tp, typename _Alloc>
01289 inline bool
01290 operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
01291 { return std::lexicographical_compare(__x.begin(), __x.end(),
01292 __y.begin(), __y.end()); }
01293
01294
01295 template<typename _Tp, typename _Alloc>
01296 inline bool
01297 operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
01298 { return !(__x == __y); }
01299
01300
01301 template<typename _Tp, typename _Alloc>
01302 inline bool
01303 operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
01304 { return __y < __x; }
01305
01306
01307 template<typename _Tp, typename _Alloc>
01308 inline bool
01309 operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
01310 { return !(__y < __x); }
01311
01312
01313 template<typename _Tp, typename _Alloc>
01314 inline bool
01315 operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
01316 { return !(__x < __y); }
01317
01318
01319 template<typename _Tp, typename _Alloc>
01320 inline void
01321 swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
01322 { __x.swap(__y); }
01323
01324 _GLIBCXX_END_NAMESPACE_CONTAINER
01325 }
01326
01327 #endif