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_LIST_H
00058 #define _STL_LIST_H 1
00059
00060 #include <bits/concept_check.h>
00061 #include <initializer_list>
00062
00063 _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
00064
00065
00066
00067
00068
00069
00070
00071 struct _List_node_base
00072 {
00073 _List_node_base* _M_next;
00074 _List_node_base* _M_prev;
00075
00076 static void
00077 swap(_List_node_base& __x, _List_node_base& __y) throw ();
00078
00079 void
00080 _M_transfer(_List_node_base * const __first,
00081 _List_node_base * const __last) throw ();
00082
00083 void
00084 _M_reverse() throw ();
00085
00086 void
00087 _M_hook(_List_node_base * const __position) throw ();
00088
00089 void
00090 _M_unhook() throw ();
00091 };
00092
00093
00094 template<typename _Tp>
00095 struct _List_node : public _List_node_base
00096 {
00097
00098 _Tp _M_data;
00099
00100 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00101 template<typename... _Args>
00102 _List_node(_Args&&... __args)
00103 : _List_node_base(), _M_data(std::forward<_Args>(__args)...) { }
00104 #endif
00105 };
00106
00107
00108
00109
00110
00111
00112 template<typename _Tp>
00113 struct _List_iterator
00114 {
00115 typedef _List_iterator<_Tp> _Self;
00116 typedef _List_node<_Tp> _Node;
00117
00118 typedef ptrdiff_t difference_type;
00119 typedef std::bidirectional_iterator_tag iterator_category;
00120 typedef _Tp value_type;
00121 typedef _Tp* pointer;
00122 typedef _Tp& reference;
00123
00124 _List_iterator()
00125 : _M_node() { }
00126
00127 explicit
00128 _List_iterator(_List_node_base* __x)
00129 : _M_node(__x) { }
00130
00131
00132 reference
00133 operator*() const
00134 { return static_cast<_Node*>(_M_node)->_M_data; }
00135
00136 pointer
00137 operator->() const
00138 { return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
00139
00140 _Self&
00141 operator++()
00142 {
00143 _M_node = _M_node->_M_next;
00144 return *this;
00145 }
00146
00147 _Self
00148 operator++(int)
00149 {
00150 _Self __tmp = *this;
00151 _M_node = _M_node->_M_next;
00152 return __tmp;
00153 }
00154
00155 _Self&
00156 operator--()
00157 {
00158 _M_node = _M_node->_M_prev;
00159 return *this;
00160 }
00161
00162 _Self
00163 operator--(int)
00164 {
00165 _Self __tmp = *this;
00166 _M_node = _M_node->_M_prev;
00167 return __tmp;
00168 }
00169
00170 bool
00171 operator==(const _Self& __x) const
00172 { return _M_node == __x._M_node; }
00173
00174 bool
00175 operator!=(const _Self& __x) const
00176 { return _M_node != __x._M_node; }
00177
00178
00179 _List_node_base* _M_node;
00180 };
00181
00182
00183
00184
00185
00186
00187 template<typename _Tp>
00188 struct _List_const_iterator
00189 {
00190 typedef _List_const_iterator<_Tp> _Self;
00191 typedef const _List_node<_Tp> _Node;
00192 typedef _List_iterator<_Tp> iterator;
00193
00194 typedef ptrdiff_t difference_type;
00195 typedef std::bidirectional_iterator_tag iterator_category;
00196 typedef _Tp value_type;
00197 typedef const _Tp* pointer;
00198 typedef const _Tp& reference;
00199
00200 _List_const_iterator()
00201 : _M_node() { }
00202
00203 explicit
00204 _List_const_iterator(const _List_node_base* __x)
00205 : _M_node(__x) { }
00206
00207 _List_const_iterator(const iterator& __x)
00208 : _M_node(__x._M_node) { }
00209
00210
00211
00212 reference
00213 operator*() const
00214 { return static_cast<_Node*>(_M_node)->_M_data; }
00215
00216 pointer
00217 operator->() const
00218 { return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
00219
00220 _Self&
00221 operator++()
00222 {
00223 _M_node = _M_node->_M_next;
00224 return *this;
00225 }
00226
00227 _Self
00228 operator++(int)
00229 {
00230 _Self __tmp = *this;
00231 _M_node = _M_node->_M_next;
00232 return __tmp;
00233 }
00234
00235 _Self&
00236 operator--()
00237 {
00238 _M_node = _M_node->_M_prev;
00239 return *this;
00240 }
00241
00242 _Self
00243 operator--(int)
00244 {
00245 _Self __tmp = *this;
00246 _M_node = _M_node->_M_prev;
00247 return __tmp;
00248 }
00249
00250 bool
00251 operator==(const _Self& __x) const
00252 { return _M_node == __x._M_node; }
00253
00254 bool
00255 operator!=(const _Self& __x) const
00256 { return _M_node != __x._M_node; }
00257
00258
00259 const _List_node_base* _M_node;
00260 };
00261
00262 template<typename _Val>
00263 inline bool
00264 operator==(const _List_iterator<_Val>& __x,
00265 const _List_const_iterator<_Val>& __y)
00266 { return __x._M_node == __y._M_node; }
00267
00268 template<typename _Val>
00269 inline bool
00270 operator!=(const _List_iterator<_Val>& __x,
00271 const _List_const_iterator<_Val>& __y)
00272 { return __x._M_node != __y._M_node; }
00273
00274
00275
00276 template<typename _Tp, typename _Alloc>
00277 class _List_base
00278 {
00279 protected:
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 typedef typename _Alloc::template rebind<_List_node<_Tp> >::other
00294 _Node_alloc_type;
00295
00296 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
00297
00298 struct _List_impl
00299 : public _Node_alloc_type
00300 {
00301 _List_node_base _M_node;
00302
00303 _List_impl()
00304 : _Node_alloc_type(), _M_node()
00305 { }
00306
00307 _List_impl(const _Node_alloc_type& __a)
00308 : _Node_alloc_type(__a), _M_node()
00309 { }
00310 };
00311
00312 _List_impl _M_impl;
00313
00314 _List_node<_Tp>*
00315 _M_get_node()
00316 { return _M_impl._Node_alloc_type::allocate(1); }
00317
00318 void
00319 _M_put_node(_List_node<_Tp>* __p)
00320 { _M_impl._Node_alloc_type::deallocate(__p, 1); }
00321
00322 public:
00323 typedef _Alloc allocator_type;
00324
00325 _Node_alloc_type&
00326 _M_get_Node_allocator()
00327 { return *static_cast<_Node_alloc_type*>(&this->_M_impl); }
00328
00329 const _Node_alloc_type&
00330 _M_get_Node_allocator() const
00331 { return *static_cast<const _Node_alloc_type*>(&this->_M_impl); }
00332
00333 _Tp_alloc_type
00334 _M_get_Tp_allocator() const
00335 { return _Tp_alloc_type(_M_get_Node_allocator()); }
00336
00337 allocator_type
00338 get_allocator() const
00339 { return allocator_type(_M_get_Node_allocator()); }
00340
00341 _List_base()
00342 : _M_impl()
00343 { _M_init(); }
00344
00345 _List_base(const allocator_type& __a)
00346 : _M_impl(__a)
00347 { _M_init(); }
00348
00349 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00350 _List_base(_List_base&& __x)
00351 : _M_impl(__x._M_get_Node_allocator())
00352 {
00353 _M_init();
00354 _List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node);
00355 }
00356 #endif
00357
00358
00359 ~_List_base()
00360 { _M_clear(); }
00361
00362 void
00363 _M_clear();
00364
00365 void
00366 _M_init()
00367 {
00368 this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
00369 this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
00370 }
00371 };
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416 template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
00417 class list : protected _List_base<_Tp, _Alloc>
00418 {
00419
00420 typedef typename _Alloc::value_type _Alloc_value_type;
00421 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
00422 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
00423
00424 typedef _List_base<_Tp, _Alloc> _Base;
00425 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
00426
00427 public:
00428 typedef _Tp value_type;
00429 typedef typename _Tp_alloc_type::pointer pointer;
00430 typedef typename _Tp_alloc_type::const_pointer const_pointer;
00431 typedef typename _Tp_alloc_type::reference reference;
00432 typedef typename _Tp_alloc_type::const_reference const_reference;
00433 typedef _List_iterator<_Tp> iterator;
00434 typedef _List_const_iterator<_Tp> const_iterator;
00435 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00436 typedef std::reverse_iterator<iterator> reverse_iterator;
00437 typedef size_t size_type;
00438 typedef ptrdiff_t difference_type;
00439 typedef _Alloc allocator_type;
00440
00441 protected:
00442
00443
00444 typedef _List_node<_Tp> _Node;
00445
00446 using _Base::_M_impl;
00447 using _Base::_M_put_node;
00448 using _Base::_M_get_node;
00449 using _Base::_M_get_Tp_allocator;
00450 using _Base::_M_get_Node_allocator;
00451
00452
00453
00454
00455
00456
00457 #ifndef __GXX_EXPERIMENTAL_CXX0X__
00458 _Node*
00459 _M_create_node(const value_type& __x)
00460 {
00461 _Node* __p = this->_M_get_node();
00462 __try
00463 {
00464 _M_get_Tp_allocator().construct
00465 (std::__addressof(__p->_M_data), __x);
00466 }
00467 __catch(...)
00468 {
00469 _M_put_node(__p);
00470 __throw_exception_again;
00471 }
00472 return __p;
00473 }
00474 #else
00475 template<typename... _Args>
00476 _Node*
00477 _M_create_node(_Args&&... __args)
00478 {
00479 _Node* __p = this->_M_get_node();
00480 __try
00481 {
00482 _M_get_Node_allocator().construct(__p,
00483 std::forward<_Args>(__args)...);
00484 }
00485 __catch(...)
00486 {
00487 _M_put_node(__p);
00488 __throw_exception_again;
00489 }
00490 return __p;
00491 }
00492 #endif
00493
00494 public:
00495
00496
00497
00498
00499
00500 list()
00501 : _Base() { }
00502
00503
00504
00505
00506
00507 explicit
00508 list(const allocator_type& __a)
00509 : _Base(__a) { }
00510
00511 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00512
00513
00514
00515
00516
00517
00518
00519 explicit
00520 list(size_type __n)
00521 : _Base()
00522 { _M_default_initialize(__n); }
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532 list(size_type __n, const value_type& __value,
00533 const allocator_type& __a = allocator_type())
00534 : _Base(__a)
00535 { _M_fill_initialize(__n, __value); }
00536 #else
00537
00538
00539
00540
00541
00542
00543
00544
00545 explicit
00546 list(size_type __n, const value_type& __value = value_type(),
00547 const allocator_type& __a = allocator_type())
00548 : _Base(__a)
00549 { _M_fill_initialize(__n, __value); }
00550 #endif
00551
00552
00553
00554
00555
00556
00557
00558
00559 list(const list& __x)
00560 : _Base(__x._M_get_Node_allocator())
00561 { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); }
00562
00563 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00564
00565
00566
00567
00568
00569
00570
00571 list(list&& __x)
00572 : _Base(std::forward<_Base>(__x)) { }
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582 list(initializer_list<value_type> __l,
00583 const allocator_type& __a = allocator_type())
00584 : _Base(__a)
00585 { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); }
00586 #endif
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598 template<typename _InputIterator>
00599 list(_InputIterator __first, _InputIterator __last,
00600 const allocator_type& __a = allocator_type())
00601 : _Base(__a)
00602 {
00603
00604 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
00605 _M_initialize_dispatch(__first, __last, _Integral());
00606 }
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623 list&
00624 operator=(const list& __x);
00625
00626 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00627
00628
00629
00630
00631
00632
00633
00634 list&
00635 operator=(list&& __x)
00636 {
00637
00638
00639 this->clear();
00640 this->swap(__x);
00641 return *this;
00642 }
00643
00644
00645
00646
00647
00648
00649
00650
00651 list&
00652 operator=(initializer_list<value_type> __l)
00653 {
00654 this->assign(__l.begin(), __l.end());
00655 return *this;
00656 }
00657 #endif
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669 void
00670 assign(size_type __n, const value_type& __val)
00671 { _M_fill_assign(__n, __val); }
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685 template<typename _InputIterator>
00686 void
00687 assign(_InputIterator __first, _InputIterator __last)
00688 {
00689
00690 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
00691 _M_assign_dispatch(__first, __last, _Integral());
00692 }
00693
00694 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00695
00696
00697
00698
00699
00700
00701
00702 void
00703 assign(initializer_list<value_type> __l)
00704 { this->assign(__l.begin(), __l.end()); }
00705 #endif
00706
00707
00708 allocator_type
00709 get_allocator() const
00710 { return _Base::get_allocator(); }
00711
00712
00713
00714
00715
00716
00717 iterator
00718 begin()
00719 { return iterator(this->_M_impl._M_node._M_next); }
00720
00721
00722
00723
00724
00725
00726 const_iterator
00727 begin() const
00728 { return const_iterator(this->_M_impl._M_node._M_next); }
00729
00730
00731
00732
00733
00734
00735 iterator
00736 end()
00737 { return iterator(&this->_M_impl._M_node); }
00738
00739
00740
00741
00742
00743
00744 const_iterator
00745 end() const
00746 { return const_iterator(&this->_M_impl._M_node); }
00747
00748
00749
00750
00751
00752
00753 reverse_iterator
00754 rbegin()
00755 { return reverse_iterator(end()); }
00756
00757
00758
00759
00760
00761
00762 const_reverse_iterator
00763 rbegin() const
00764 { return const_reverse_iterator(end()); }
00765
00766
00767
00768
00769
00770
00771 reverse_iterator
00772 rend()
00773 { return reverse_iterator(begin()); }
00774
00775
00776
00777
00778
00779
00780 const_reverse_iterator
00781 rend() const
00782 { return const_reverse_iterator(begin()); }
00783
00784 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00785
00786
00787
00788
00789
00790 const_iterator
00791 cbegin() const
00792 { return const_iterator(this->_M_impl._M_node._M_next); }
00793
00794
00795
00796
00797
00798
00799 const_iterator
00800 cend() const
00801 { return const_iterator(&this->_M_impl._M_node); }
00802
00803
00804
00805
00806
00807
00808 const_reverse_iterator
00809 crbegin() const
00810 { return const_reverse_iterator(end()); }
00811
00812
00813
00814
00815
00816
00817 const_reverse_iterator
00818 crend() const
00819 { return const_reverse_iterator(begin()); }
00820 #endif
00821
00822
00823
00824
00825
00826
00827 bool
00828 empty() const
00829 { return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
00830
00831
00832 size_type
00833 size() const
00834 { return std::distance(begin(), end()); }
00835
00836
00837 size_type
00838 max_size() const
00839 { return _M_get_Node_allocator().max_size(); }
00840
00841 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851 void
00852 resize(size_type __new_size);
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864 void
00865 resize(size_type __new_size, const value_type& __x);
00866 #else
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877 void
00878 resize(size_type __new_size, value_type __x = value_type());
00879 #endif
00880
00881
00882
00883
00884
00885
00886 reference
00887 front()
00888 { return *begin(); }
00889
00890
00891
00892
00893
00894 const_reference
00895 front() const
00896 { return *begin(); }
00897
00898
00899
00900
00901
00902 reference
00903 back()
00904 {
00905 iterator __tmp = end();
00906 --__tmp;
00907 return *__tmp;
00908 }
00909
00910
00911
00912
00913
00914 const_reference
00915 back() const
00916 {
00917 const_iterator __tmp = end();
00918 --__tmp;
00919 return *__tmp;
00920 }
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933 void
00934 push_front(const value_type& __x)
00935 { this->_M_insert(begin(), __x); }
00936
00937 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00938 void
00939 push_front(value_type&& __x)
00940 { this->_M_insert(begin(), std::move(__x)); }
00941
00942 template<typename... _Args>
00943 void
00944 emplace_front(_Args&&... __args)
00945 { this->_M_insert(begin(), std::forward<_Args>(__args)...); }
00946 #endif
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960 void
00961 pop_front()
00962 { this->_M_erase(begin()); }
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974 void
00975 push_back(const value_type& __x)
00976 { this->_M_insert(end(), __x); }
00977
00978 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00979 void
00980 push_back(value_type&& __x)
00981 { this->_M_insert(end(), std::move(__x)); }
00982
00983 template<typename... _Args>
00984 void
00985 emplace_back(_Args&&... __args)
00986 { this->_M_insert(end(), std::forward<_Args>(__args)...); }
00987 #endif
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000 void
01001 pop_back()
01002 { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
01003
01004 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017 template<typename... _Args>
01018 iterator
01019 emplace(iterator __position, _Args&&... __args);
01020 #endif
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033 iterator
01034 insert(iterator __position, const value_type& __x);
01035
01036 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048 iterator
01049 insert(iterator __position, value_type&& __x)
01050 { return emplace(__position, std::move(__x)); }
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065 void
01066 insert(iterator __p, initializer_list<value_type> __l)
01067 { this->insert(__p, __l.begin(), __l.end()); }
01068 #endif
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082 void
01083 insert(iterator __position, size_type __n, const value_type& __x)
01084 {
01085 list __tmp(__n, __x, _M_get_Node_allocator());
01086 splice(__position, __tmp);
01087 }
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102 template<typename _InputIterator>
01103 void
01104 insert(iterator __position, _InputIterator __first,
01105 _InputIterator __last)
01106 {
01107 list __tmp(__first, __last, _M_get_Node_allocator());
01108 splice(__position, __tmp);
01109 }
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126 iterator
01127 erase(iterator __position);
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147 iterator
01148 erase(iterator __first, iterator __last)
01149 {
01150 while (__first != __last)
01151 __first = erase(__first);
01152 return __last;
01153 }
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164 void
01165 swap(list& __x)
01166 {
01167 _List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node);
01168
01169
01170
01171 std::__alloc_swap<typename _Base::_Node_alloc_type>::
01172 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator());
01173 }
01174
01175
01176
01177
01178
01179
01180
01181 void
01182 clear()
01183 {
01184 _Base::_M_clear();
01185 _Base::_M_init();
01186 }
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200 void
01201 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01202 splice(iterator __position, list&& __x)
01203 #else
01204 splice(iterator __position, list& __x)
01205 #endif
01206 {
01207 if (!__x.empty())
01208 {
01209 _M_check_equal_allocators(__x);
01210
01211 this->_M_transfer(__position, __x.begin(), __x.end());
01212 }
01213 }
01214
01215 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01216 void
01217 splice(iterator __position, list& __x)
01218 { splice(__position, std::move(__x)); }
01219 #endif
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230 void
01231 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01232 splice(iterator __position, list&& __x, iterator __i)
01233 #else
01234 splice(iterator __position, list& __x, iterator __i)
01235 #endif
01236 {
01237 iterator __j = __i;
01238 ++__j;
01239 if (__position == __i || __position == __j)
01240 return;
01241
01242 if (this != &__x)
01243 _M_check_equal_allocators(__x);
01244
01245 this->_M_transfer(__position, __i, __j);
01246 }
01247
01248 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01249 void
01250 splice(iterator __position, list& __x, iterator __i)
01251 { splice(__position, std::move(__x), __i); }
01252 #endif
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266 void
01267 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01268 splice(iterator __position, list&& __x, iterator __first,
01269 iterator __last)
01270 #else
01271 splice(iterator __position, list& __x, iterator __first,
01272 iterator __last)
01273 #endif
01274 {
01275 if (__first != __last)
01276 {
01277 if (this != &__x)
01278 _M_check_equal_allocators(__x);
01279
01280 this->_M_transfer(__position, __first, __last);
01281 }
01282 }
01283
01284 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01285 void
01286 splice(iterator __position, list& __x, iterator __first, iterator __last)
01287 { splice(__position, std::move(__x), __first, __last); }
01288 #endif
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301 void
01302 remove(const _Tp& __value);
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315 template<typename _Predicate>
01316 void
01317 remove_if(_Predicate);
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329 void
01330 unique();
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344 template<typename _BinaryPredicate>
01345 void
01346 unique(_BinaryPredicate);
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01358 void
01359 merge(list&& __x);
01360
01361 void
01362 merge(list& __x)
01363 { merge(std::move(__x)); }
01364 #else
01365 void
01366 merge(list& __x);
01367 #endif
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01382 template<typename _StrictWeakOrdering>
01383 void
01384 merge(list&&, _StrictWeakOrdering);
01385
01386 template<typename _StrictWeakOrdering>
01387 void
01388 merge(list& __x, _StrictWeakOrdering __comp)
01389 { merge(std::move(__x), __comp); }
01390 #else
01391 template<typename _StrictWeakOrdering>
01392 void
01393 merge(list&, _StrictWeakOrdering);
01394 #endif
01395
01396
01397
01398
01399
01400
01401 void
01402 reverse()
01403 { this->_M_impl._M_node._M_reverse(); }
01404
01405
01406
01407
01408
01409
01410
01411 void
01412 sort();
01413
01414
01415
01416
01417
01418
01419
01420 template<typename _StrictWeakOrdering>
01421 void
01422 sort(_StrictWeakOrdering);
01423
01424 protected:
01425
01426
01427
01428
01429
01430
01431 template<typename _Integer>
01432 void
01433 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
01434 { _M_fill_initialize(static_cast<size_type>(__n), __x); }
01435
01436
01437 template<typename _InputIterator>
01438 void
01439 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
01440 __false_type)
01441 {
01442 for (; __first != __last; ++__first)
01443 push_back(*__first);
01444 }
01445
01446
01447
01448 void
01449 _M_fill_initialize(size_type __n, const value_type& __x)
01450 {
01451 for (; __n; --__n)
01452 push_back(__x);
01453 }
01454
01455 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01456
01457 void
01458 _M_default_initialize(size_type __n)
01459 {
01460 for (; __n; --__n)
01461 emplace_back();
01462 }
01463
01464
01465 void
01466 _M_default_append(size_type __n);
01467 #endif
01468
01469
01470
01471
01472
01473
01474
01475 template<typename _Integer>
01476 void
01477 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
01478 { _M_fill_assign(__n, __val); }
01479
01480
01481 template<typename _InputIterator>
01482 void
01483 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
01484 __false_type);
01485
01486
01487
01488 void
01489 _M_fill_assign(size_type __n, const value_type& __val);
01490
01491
01492
01493 void
01494 _M_transfer(iterator __position, iterator __first, iterator __last)
01495 { __position._M_node->_M_transfer(__first._M_node, __last._M_node); }
01496
01497
01498 #ifndef __GXX_EXPERIMENTAL_CXX0X__
01499 void
01500 _M_insert(iterator __position, const value_type& __x)
01501 {
01502 _Node* __tmp = _M_create_node(__x);
01503 __tmp->_M_hook(__position._M_node);
01504 }
01505 #else
01506 template<typename... _Args>
01507 void
01508 _M_insert(iterator __position, _Args&&... __args)
01509 {
01510 _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
01511 __tmp->_M_hook(__position._M_node);
01512 }
01513 #endif
01514
01515
01516 void
01517 _M_erase(iterator __position)
01518 {
01519 __position._M_node->_M_unhook();
01520 _Node* __n = static_cast<_Node*>(__position._M_node);
01521 #ifdef __GXX_EXPERIMENTAL_CXX0X__
01522 _M_get_Node_allocator().destroy(__n);
01523 #else
01524 _M_get_Tp_allocator().destroy(std::__addressof(__n->_M_data));
01525 #endif
01526 _M_put_node(__n);
01527 }
01528
01529
01530 void
01531 _M_check_equal_allocators(list& __x)
01532 {
01533 if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
01534 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
01535 __throw_runtime_error(__N("list::_M_check_equal_allocators"));
01536 }
01537 };
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549 template<typename _Tp, typename _Alloc>
01550 inline bool
01551 operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
01552 {
01553 typedef typename list<_Tp, _Alloc>::const_iterator const_iterator;
01554 const_iterator __end1 = __x.end();
01555 const_iterator __end2 = __y.end();
01556
01557 const_iterator __i1 = __x.begin();
01558 const_iterator __i2 = __y.begin();
01559 while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
01560 {
01561 ++__i1;
01562 ++__i2;
01563 }
01564 return __i1 == __end1 && __i2 == __end2;
01565 }
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578 template<typename _Tp, typename _Alloc>
01579 inline bool
01580 operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
01581 { return std::lexicographical_compare(__x.begin(), __x.end(),
01582 __y.begin(), __y.end()); }
01583
01584
01585 template<typename _Tp, typename _Alloc>
01586 inline bool
01587 operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
01588 { return !(__x == __y); }
01589
01590
01591 template<typename _Tp, typename _Alloc>
01592 inline bool
01593 operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
01594 { return __y < __x; }
01595
01596
01597 template<typename _Tp, typename _Alloc>
01598 inline bool
01599 operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
01600 { return !(__y < __x); }
01601
01602
01603 template<typename _Tp, typename _Alloc>
01604 inline bool
01605 operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
01606 { return !(__x < __y); }
01607
01608
01609 template<typename _Tp, typename _Alloc>
01610 inline void
01611 swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
01612 { __x.swap(__y); }
01613
01614 _GLIBCXX_END_NESTED_NAMESPACE
01615
01616 #endif