_list.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. /*
  2. *
  3. * Copyright (c) 1994
  4. * Hewlett-Packard Company
  5. *
  6. * Copyright (c) 1996,1997
  7. * Silicon Graphics Computer Systems, Inc.
  8. *
  9. * Copyright (c) 1997
  10. * Moscow Center for SPARC Technology
  11. *
  12. * Copyright (c) 1999
  13. * Boris Fomitchev
  14. *
  15. * This material is provided "as is", with absolutely no warranty expressed
  16. * or implied. Any use is at your own risk.
  17. *
  18. * Permission to use or copy this software for any purpose is hereby granted
  19. * without fee, provided the above notices are retained on all copies.
  20. * Permission to modify the code and to distribute modified code is granted,
  21. * provided the above notices are retained, and a notice that the code was
  22. * modified is included with the above copyright notice.
  23. *
  24. */
  25. /* NOTE: This is an internal header file, included by other STL headers.
  26. * You should not attempt to use it directly.
  27. */
  28. #ifndef _STLP_INTERNAL_DBG_LIST_H
  29. #define _STLP_INTERNAL_DBG_LIST_H
  30. #ifndef _STLP_INTERNAL_ALGO_H
  31. # include <stl/_algo.h>
  32. #endif
  33. #ifndef _STLP_DBG_ITERATOR_H
  34. # include <stl/debug/_iterator.h>
  35. #endif
  36. #define _STLP_NON_DBG_LIST _STLP_PRIV _STLP_NON_DBG_NAME(list) <_Tp, _Alloc>
  37. _STLP_BEGIN_NAMESPACE
  38. #if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
  39. template <class _Tp, class _Alloc>
  40. inline _Tp*
  41. value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_LIST >&)
  42. { return (_Tp*)0; }
  43. template <class _Tp, class _Alloc>
  44. inline bidirectional_iterator_tag
  45. iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_LIST >&)
  46. { return bidirectional_iterator_tag(); }
  47. #endif
  48. template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
  49. class list :
  50. #if !defined (__DMC__)
  51. private
  52. #endif
  53. _STLP_PRIV __construct_checker<_STLP_NON_DBG_LIST >
  54. #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
  55. , public __stlport_class<list<_Tp, _Alloc> >
  56. #endif
  57. {
  58. typedef _STLP_NON_DBG_LIST _Base;
  59. typedef list<_Tp, _Alloc> _Self;
  60. typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_LIST > _ConstructCheck;
  61. public:
  62. __IMPORT_CONTAINER_TYPEDEFS(_Base)
  63. public:
  64. typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator;
  65. typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > > const_iterator;
  66. _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
  67. private:
  68. _Base _M_non_dbg_impl;
  69. _STLP_PRIV __owned_list _M_iter_list;
  70. void _Invalidate_iterator(const iterator& __it)
  71. { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
  72. void _Invalidate_iterators(const iterator& __first, const iterator& __last)
  73. { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
  74. typedef typename _Base::iterator _Base_iterator;
  75. public:
  76. explicit list(const allocator_type& __a = allocator_type()) :
  77. _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
  78. #if !defined(_STLP_DONT_SUP_DFLT_PARAM)
  79. explicit list(size_type __n, const _Tp& __x = _Tp(),
  80. #else
  81. list(size_type __n, const _Tp& __x,
  82. #endif /*!_STLP_DONT_SUP_DFLT_PARAM*/
  83. const allocator_type& __a = allocator_type())
  84. : _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {}
  85. #if defined(_STLP_DONT_SUP_DFLT_PARAM)
  86. explicit list(size_type __n)
  87. : _M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {}
  88. #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
  89. #if !defined (_STLP_NO_MOVE_SEMANTIC)
  90. list(__move_source<_Self> src)
  91. : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
  92. _M_iter_list(&_M_non_dbg_impl) {
  93. # if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
  94. src.get()._M_iter_list._Invalidate_all();
  95. # else
  96. src.get()._M_iter_list._Set_owner(_M_iter_list);
  97. # endif
  98. }
  99. #endif
  100. #if defined (_STLP_MEMBER_TEMPLATES)
  101. template <class _InputIterator>
  102. list(_InputIterator __first, _InputIterator __last,
  103. const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
  104. : _ConstructCheck(__first, __last),
  105. _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a),
  106. _M_iter_list(&_M_non_dbg_impl) {}
  107. # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
  108. template <class _InputIterator>
  109. list(_InputIterator __first, _InputIterator __last)
  110. : _ConstructCheck(__first, __last),
  111. _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)),
  112. _M_iter_list(&_M_non_dbg_impl) {}
  113. # endif
  114. #else
  115. list(const value_type* __first, const value_type* __last,
  116. const allocator_type& __a = allocator_type())
  117. : _ConstructCheck(__first, __last),
  118. _M_non_dbg_impl(__first, __last, __a),
  119. _M_iter_list(&_M_non_dbg_impl) {}
  120. list(const_iterator __first, const_iterator __last,
  121. const allocator_type& __a = allocator_type())
  122. : _ConstructCheck(__first, __last),
  123. _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a),
  124. _M_iter_list(&_M_non_dbg_impl) {}
  125. #endif
  126. list(const _Self& __x) :
  127. _ConstructCheck(__x),
  128. _M_non_dbg_impl(__x._M_non_dbg_impl) , _M_iter_list(&_M_non_dbg_impl) {}
  129. _Self& operator=(const _Self& __x) {
  130. if (this != &__x) {
  131. //Should not invalidate end iterator
  132. _Invalidate_iterators(begin(), end());
  133. _M_non_dbg_impl = __x._M_non_dbg_impl;
  134. }
  135. return *this;
  136. }
  137. allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
  138. iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
  139. const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
  140. iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
  141. const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
  142. reverse_iterator rbegin() { return reverse_iterator(end()); }
  143. reverse_iterator rend() { return reverse_iterator(begin()); }
  144. const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
  145. const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
  146. size_type size() const { return _M_non_dbg_impl.size(); }
  147. size_type max_size() const { return _M_non_dbg_impl.max_size(); }
  148. bool empty() const { return _M_non_dbg_impl.empty(); }
  149. // those are here to enforce checking
  150. reference front() {
  151. _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
  152. return *begin();
  153. }
  154. const_reference front() const {
  155. _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
  156. return *begin();
  157. }
  158. reference back() {
  159. _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
  160. return *(--end());
  161. }
  162. const_reference back() const {
  163. _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
  164. return *(--end());
  165. }
  166. void swap(_Self& __x) {
  167. _M_iter_list._Swap_owners(__x._M_iter_list);
  168. _M_non_dbg_impl.swap(__x._M_non_dbg_impl);
  169. }
  170. #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
  171. void _M_swap_workaround(_Self& __x) { swap(__x); }
  172. #endif
  173. #if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
  174. iterator insert(iterator __pos, const _Tp& __x = _Tp()) {
  175. #else
  176. iterator insert(iterator __pos, const _Tp& __x) {
  177. #endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
  178. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
  179. return iterator(&_M_iter_list,_M_non_dbg_impl.insert(__pos._M_iterator, __x) );
  180. }
  181. #if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
  182. iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
  183. #endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
  184. #if defined (_STLP_MEMBER_TEMPLATES)
  185. template <class _InputIterator>
  186. void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
  187. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
  188. _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
  189. _M_non_dbg_impl.insert(__pos._M_iterator,
  190. _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
  191. }
  192. #endif
  193. #if !defined (_STLP_MEMBER_TEMPLATES)
  194. void insert(iterator __pos, const _Tp* __first, const _Tp* __last) {
  195. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
  196. _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
  197. _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last);
  198. }
  199. #endif
  200. #if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
  201. void insert(iterator __pos,
  202. const_iterator __first, const_iterator __last) {
  203. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
  204. _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
  205. # if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
  206. _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __first))
  207. # endif
  208. _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
  209. }
  210. void insert(iterator __pos,
  211. iterator __first, iterator __last) {
  212. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
  213. _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
  214. # if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
  215. _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __first))
  216. # endif
  217. _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
  218. }
  219. #endif
  220. void insert(iterator __pos, size_type __n, const _Tp& __x) {
  221. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
  222. _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x);
  223. }
  224. void push_back(const_reference __x) { _M_non_dbg_impl.push_back(__x); }
  225. void pop_back() {
  226. _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
  227. _Invalidate_iterator(end());
  228. _M_non_dbg_impl.pop_back();
  229. }
  230. void push_front(const_reference __x) { _M_non_dbg_impl.push_front(__x); }
  231. void pop_front() {
  232. _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
  233. _Invalidate_iterator(begin());
  234. _M_non_dbg_impl.pop_front();
  235. }
  236. iterator erase(iterator __pos) {
  237. _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
  238. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
  239. _Invalidate_iterator(__pos);
  240. return iterator(&_M_iter_list,_M_non_dbg_impl.erase(__pos._M_iterator));
  241. }
  242. iterator erase(iterator __first, iterator __last) {
  243. _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
  244. _Invalidate_iterators(__first, __last);
  245. return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator));
  246. }
  247. #if !defined(_STLP_DONT_SUP_DFLT_PARAM)
  248. void resize(size_type __new_size, const _Tp& __x = _Tp()) {
  249. #else
  250. void resize(size_type __new_size, const _Tp& __x) {
  251. #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
  252. _Base_iterator __i = _M_non_dbg_impl.begin();
  253. size_type __len = 0;
  254. for ( ; __i != _M_non_dbg_impl.end() && __len < __new_size; ++__i, ++__len);
  255. if (__len == __new_size)
  256. erase(iterator(&_M_iter_list, __i), end());
  257. else // __i == end()
  258. _M_non_dbg_impl.insert(_M_non_dbg_impl.end(), __new_size - __len, __x);
  259. }
  260. #if defined(_STLP_DONT_SUP_DFLT_PARAM)
  261. void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
  262. #endif
  263. #if defined (_STLP_MEMBER_TEMPLATES)
  264. template <class _InputIterator>
  265. void assign(_InputIterator __first, _InputIterator __last) {
  266. _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
  267. _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
  268. _Invalidate_iterators(begin(), end());
  269. }
  270. #else
  271. void assign(const _Tp* __first, const _Tp* __last) {
  272. _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
  273. _M_non_dbg_impl.assign(__first, __last);
  274. _Invalidate_iterators(begin(), end());
  275. }
  276. void assign(iterator __first, iterator __last) {
  277. _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
  278. _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
  279. _Invalidate_iterators(begin(), end());
  280. }
  281. void assign(const_iterator __first, const_iterator __last) {
  282. _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
  283. _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
  284. _Invalidate_iterators(begin(), end());
  285. }
  286. #endif
  287. void assign(size_type __n, const _Tp& __val) {
  288. _Invalidate_iterators(begin(), end());
  289. _M_non_dbg_impl.assign(__n, __val);
  290. }
  291. void remove(const _Tp& __x) {
  292. _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
  293. while (__first != __last) {
  294. _Base_iterator __next = __first;
  295. ++__next;
  296. if (__x == *__first) {
  297. _Invalidate_iterator(iterator(&_M_iter_list, __first));
  298. _M_non_dbg_impl.erase(__first);
  299. }
  300. __first = __next;
  301. }
  302. }
  303. void clear() {
  304. _Invalidate_iterators(begin(), end());
  305. _M_non_dbg_impl.clear();
  306. }
  307. public:
  308. void splice(iterator __pos, _Self& __x) {
  309. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
  310. _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl);
  311. #if (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL)
  312. if (get_allocator() == __x.get_allocator())
  313. __x._M_iter_list._Set_owner(_M_iter_list);
  314. else
  315. #endif
  316. // Std: 23.2.2.4:4
  317. // end iterator is not invalidated:
  318. __x._Invalidate_iterators(__x.begin(), __x.end());
  319. }
  320. void splice(iterator __pos, _Self& __x, iterator __i) {
  321. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
  322. _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__i))
  323. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&(__x._M_iter_list),__i))
  324. _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __i._M_iterator);
  325. #if (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL)
  326. if (get_allocator() == __x.get_allocator())
  327. _STLP_PRIV __change_ite_owner(__i, &_M_iter_list);
  328. else
  329. #endif
  330. // Std: 23.2.2.4:7
  331. __x._Invalidate_iterator(__i);
  332. }
  333. void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) {
  334. _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
  335. _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, __x.begin(), __x.end()))
  336. _STLP_DEBUG_CHECK(this == &__x ? !_STLP_PRIV __check_range(__pos, __first, __last) : true)
  337. #if (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL)
  338. if (this->get_allocator() == __x.get_allocator())
  339. _STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list);
  340. else
  341. #endif
  342. // Std: 23.2.2.4:12
  343. __x._Invalidate_iterators(__first, __last);
  344. _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __first._M_iterator, __last._M_iterator);
  345. }
  346. void merge(_Self& __x) {
  347. #if !defined (_STLP_NO_EXTENSIONS)
  348. _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(begin()._M_iterator, end()._M_iterator))
  349. _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator))
  350. #endif
  351. _M_non_dbg_impl.merge(__x._M_non_dbg_impl);
  352. if (this->get_allocator() == __x.get_allocator()) {
  353. __x._M_iter_list._Set_owner(_M_iter_list);
  354. }
  355. else {
  356. __x._Invalidate_iterators(__x.begin(), __x.end());
  357. }
  358. }
  359. void reverse() {
  360. _M_non_dbg_impl.reverse();
  361. }
  362. void unique() {
  363. _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
  364. if (__first == __last) return;
  365. _Base_iterator __next = __first;
  366. while (++__next != __last) {
  367. if (*__first == *__next) {
  368. _Invalidate_iterator(iterator(&_M_iter_list, __next));
  369. _M_non_dbg_impl.erase(__next);
  370. }
  371. else
  372. __first = __next;
  373. __next = __first;
  374. }
  375. }
  376. void sort() {
  377. _M_non_dbg_impl.sort();
  378. }
  379. #if defined (_STLP_MEMBER_TEMPLATES)
  380. template <class _Predicate>
  381. void remove_if(_Predicate __pred) {
  382. _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
  383. while (__first != __last) {
  384. _Base_iterator __next = __first;
  385. ++__next;
  386. if (__pred(*__first)) {
  387. _Invalidate_iterator(iterator(&_M_iter_list, __first));
  388. _M_non_dbg_impl.erase(__first);
  389. }
  390. __first = __next;
  391. }
  392. }
  393. template <class _BinaryPredicate>
  394. void unique(_BinaryPredicate __binary_pred) {
  395. _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
  396. if (__first == __last) return;
  397. _Base_iterator __next = __first;
  398. while (++__next != __last) {
  399. if (__binary_pred(*__first, *__next)) {
  400. _Invalidate_iterator(iterator(&_M_iter_list, __next));
  401. _M_non_dbg_impl.erase(__next);
  402. }
  403. else
  404. __first = __next;
  405. __next = __first;
  406. }
  407. }
  408. template <class _StrictWeakOrdering>
  409. void merge(_Self& __x, _StrictWeakOrdering __comp) {
  410. #if !defined (_STLP_NO_EXTENSIONS)
  411. _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end(), __comp))
  412. _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator, __comp))
  413. #endif
  414. _M_non_dbg_impl.merge(__x._M_non_dbg_impl, __comp);
  415. if (this->get_allocator() == __x.get_allocator()) {
  416. __x._M_iter_list._Set_owner(_M_iter_list);
  417. }
  418. else {
  419. __x._Invalidate_iterators(__x.begin(), __x.end());
  420. }
  421. }
  422. template <class _StrictWeakOrdering>
  423. void sort(_StrictWeakOrdering __comp) {
  424. _M_non_dbg_impl.sort(__comp);
  425. }
  426. #endif
  427. };
  428. _STLP_END_NAMESPACE
  429. #undef _STLP_NON_DBG_LIST
  430. #endif /* _STLP_INTERNAL_LIST_H */
  431. // Local Variables:
  432. // mode:C++
  433. // End: