deque 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. // Debugging deque implementation -*- C++ -*-
  2. // Copyright (C) 2003-2022 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file debug/deque
  21. * This file is a GNU debug extension to the Standard C++ Library.
  22. */
  23. #ifndef _GLIBCXX_DEBUG_DEQUE
  24. #define _GLIBCXX_DEBUG_DEQUE 1
  25. #pragma GCC system_header
  26. #include <bits/c++config.h>
  27. namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
  28. template<typename _Tp, typename _Allocator> class deque;
  29. } } // namespace std::__debug
  30. #include <deque>
  31. #include <debug/safe_sequence.h>
  32. #include <debug/safe_container.h>
  33. #include <debug/safe_iterator.h>
  34. namespace std _GLIBCXX_VISIBILITY(default)
  35. {
  36. namespace __debug
  37. {
  38. /// Class std::deque with safety/checking/debug instrumentation.
  39. template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
  40. class deque
  41. : public __gnu_debug::_Safe_container<
  42. deque<_Tp, _Allocator>, _Allocator,
  43. __gnu_debug::_Safe_sequence>,
  44. public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
  45. {
  46. typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base;
  47. typedef __gnu_debug::_Safe_container<
  48. deque, _Allocator, __gnu_debug::_Safe_sequence> _Safe;
  49. typedef typename _Base::const_iterator _Base_const_iterator;
  50. typedef typename _Base::iterator _Base_iterator;
  51. typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
  52. template<typename _ItT, typename _SeqT, typename _CatT>
  53. friend class ::__gnu_debug::_Safe_iterator;
  54. // Reference wrapper for base class. Disambiguates deque(const _Base&)
  55. // from copy constructor by requiring a user-defined conversion.
  56. // See PR libstdc++/90102.
  57. struct _Base_ref
  58. {
  59. _Base_ref(const _Base& __r) : _M_ref(__r) { }
  60. const _Base& _M_ref;
  61. };
  62. public:
  63. typedef typename _Base::reference reference;
  64. typedef typename _Base::const_reference const_reference;
  65. typedef __gnu_debug::_Safe_iterator<_Base_iterator, deque>
  66. iterator;
  67. typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, deque>
  68. const_iterator;
  69. typedef typename _Base::size_type size_type;
  70. typedef typename _Base::difference_type difference_type;
  71. typedef _Tp value_type;
  72. typedef _Allocator allocator_type;
  73. typedef typename _Base::pointer pointer;
  74. typedef typename _Base::const_pointer const_pointer;
  75. typedef std::reverse_iterator<iterator> reverse_iterator;
  76. typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
  77. // 23.2.1.1 construct/copy/destroy:
  78. #if __cplusplus < 201103L
  79. deque()
  80. : _Base() { }
  81. deque(const deque& __x)
  82. : _Base(__x) { }
  83. ~deque() { }
  84. #else
  85. deque() = default;
  86. deque(const deque&) = default;
  87. deque(deque&&) = default;
  88. deque(const deque& __d, const __type_identity_t<_Allocator>& __a)
  89. : _Base(__d, __a) { }
  90. deque(deque&& __d, const __type_identity_t<_Allocator>& __a)
  91. : _Safe(std::move(__d)), _Base(std::move(__d), __a) { }
  92. deque(initializer_list<value_type> __l,
  93. const allocator_type& __a = allocator_type())
  94. : _Base(__l, __a) { }
  95. ~deque() = default;
  96. #endif
  97. explicit
  98. deque(const _Allocator& __a)
  99. : _Base(__a) { }
  100. #if __cplusplus >= 201103L
  101. explicit
  102. deque(size_type __n, const _Allocator& __a = _Allocator())
  103. : _Base(__n, __a) { }
  104. deque(size_type __n, const __type_identity_t<_Tp>& __value,
  105. const _Allocator& __a = _Allocator())
  106. : _Base(__n, __value, __a) { }
  107. #else
  108. explicit
  109. deque(size_type __n, const _Tp& __value = _Tp(),
  110. const _Allocator& __a = _Allocator())
  111. : _Base(__n, __value, __a) { }
  112. #endif
  113. #if __cplusplus >= 201103L
  114. template<class _InputIterator,
  115. typename = std::_RequireInputIter<_InputIterator>>
  116. #else
  117. template<class _InputIterator>
  118. #endif
  119. deque(_InputIterator __first, _InputIterator __last,
  120. const _Allocator& __a = _Allocator())
  121. : _Base(__gnu_debug::__base(
  122. __glibcxx_check_valid_constructor_range(__first, __last)),
  123. __gnu_debug::__base(__last), __a)
  124. { }
  125. deque(_Base_ref __x)
  126. : _Base(__x._M_ref) { }
  127. #if __cplusplus >= 201103L
  128. deque&
  129. operator=(const deque&) = default;
  130. deque&
  131. operator=(deque&&) = default;
  132. deque&
  133. operator=(initializer_list<value_type> __l)
  134. {
  135. _Base::operator=(__l);
  136. this->_M_invalidate_all();
  137. return *this;
  138. }
  139. #endif
  140. #if __cplusplus >= 201103L
  141. template<class _InputIterator,
  142. typename = std::_RequireInputIter<_InputIterator>>
  143. #else
  144. template<class _InputIterator>
  145. #endif
  146. void
  147. assign(_InputIterator __first, _InputIterator __last)
  148. {
  149. typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
  150. __glibcxx_check_valid_range2(__first, __last, __dist);
  151. if (__dist.second >= __gnu_debug::__dp_sign)
  152. _Base::assign(__gnu_debug::__unsafe(__first),
  153. __gnu_debug::__unsafe(__last));
  154. else
  155. _Base::assign(__first, __last);
  156. this->_M_invalidate_all();
  157. }
  158. void
  159. assign(size_type __n, const _Tp& __t)
  160. {
  161. _Base::assign(__n, __t);
  162. this->_M_invalidate_all();
  163. }
  164. #if __cplusplus >= 201103L
  165. void
  166. assign(initializer_list<value_type> __l)
  167. {
  168. _Base::assign(__l);
  169. this->_M_invalidate_all();
  170. }
  171. #endif
  172. using _Base::get_allocator;
  173. // iterators:
  174. _GLIBCXX_NODISCARD
  175. iterator
  176. begin() _GLIBCXX_NOEXCEPT
  177. { return iterator(_Base::begin(), this); }
  178. _GLIBCXX_NODISCARD
  179. const_iterator
  180. begin() const _GLIBCXX_NOEXCEPT
  181. { return const_iterator(_Base::begin(), this); }
  182. _GLIBCXX_NODISCARD
  183. iterator
  184. end() _GLIBCXX_NOEXCEPT
  185. { return iterator(_Base::end(), this); }
  186. _GLIBCXX_NODISCARD
  187. const_iterator
  188. end() const _GLIBCXX_NOEXCEPT
  189. { return const_iterator(_Base::end(), this); }
  190. _GLIBCXX_NODISCARD
  191. reverse_iterator
  192. rbegin() _GLIBCXX_NOEXCEPT
  193. { return reverse_iterator(end()); }
  194. _GLIBCXX_NODISCARD
  195. const_reverse_iterator
  196. rbegin() const _GLIBCXX_NOEXCEPT
  197. { return const_reverse_iterator(end()); }
  198. _GLIBCXX_NODISCARD
  199. reverse_iterator
  200. rend() _GLIBCXX_NOEXCEPT
  201. { return reverse_iterator(begin()); }
  202. _GLIBCXX_NODISCARD
  203. const_reverse_iterator
  204. rend() const _GLIBCXX_NOEXCEPT
  205. { return const_reverse_iterator(begin()); }
  206. #if __cplusplus >= 201103L
  207. [[__nodiscard__]]
  208. const_iterator
  209. cbegin() const noexcept
  210. { return const_iterator(_Base::begin(), this); }
  211. [[__nodiscard__]]
  212. const_iterator
  213. cend() const noexcept
  214. { return const_iterator(_Base::end(), this); }
  215. [[__nodiscard__]]
  216. const_reverse_iterator
  217. crbegin() const noexcept
  218. { return const_reverse_iterator(end()); }
  219. [[__nodiscard__]]
  220. const_reverse_iterator
  221. crend() const noexcept
  222. { return const_reverse_iterator(begin()); }
  223. #endif
  224. private:
  225. void
  226. _M_invalidate_after_nth(difference_type __n)
  227. {
  228. typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
  229. this->_M_invalidate_if(_After_nth(__n, _Base::begin()));
  230. }
  231. public:
  232. // 23.2.1.2 capacity:
  233. using _Base::size;
  234. using _Base::max_size;
  235. #if __cplusplus >= 201103L
  236. void
  237. resize(size_type __sz)
  238. {
  239. bool __invalidate_all = __sz > this->size();
  240. if (__sz < this->size())
  241. this->_M_invalidate_after_nth(__sz);
  242. _Base::resize(__sz);
  243. if (__invalidate_all)
  244. this->_M_invalidate_all();
  245. }
  246. void
  247. resize(size_type __sz, const _Tp& __c)
  248. {
  249. bool __invalidate_all = __sz > this->size();
  250. if (__sz < this->size())
  251. this->_M_invalidate_after_nth(__sz);
  252. _Base::resize(__sz, __c);
  253. if (__invalidate_all)
  254. this->_M_invalidate_all();
  255. }
  256. #else
  257. void
  258. resize(size_type __sz, _Tp __c = _Tp())
  259. {
  260. bool __invalidate_all = __sz > this->size();
  261. if (__sz < this->size())
  262. this->_M_invalidate_after_nth(__sz);
  263. _Base::resize(__sz, __c);
  264. if (__invalidate_all)
  265. this->_M_invalidate_all();
  266. }
  267. #endif
  268. #if __cplusplus >= 201103L
  269. void
  270. shrink_to_fit() noexcept
  271. {
  272. if (_Base::_M_shrink_to_fit())
  273. this->_M_invalidate_all();
  274. }
  275. #endif
  276. using _Base::empty;
  277. // element access:
  278. _GLIBCXX_NODISCARD
  279. reference
  280. operator[](size_type __n) _GLIBCXX_NOEXCEPT
  281. {
  282. __glibcxx_check_subscript(__n);
  283. return _Base::operator[](__n);
  284. }
  285. _GLIBCXX_NODISCARD
  286. const_reference
  287. operator[](size_type __n) const _GLIBCXX_NOEXCEPT
  288. {
  289. __glibcxx_check_subscript(__n);
  290. return _Base::operator[](__n);
  291. }
  292. using _Base::at;
  293. _GLIBCXX_NODISCARD
  294. reference
  295. front() _GLIBCXX_NOEXCEPT
  296. {
  297. __glibcxx_check_nonempty();
  298. return _Base::front();
  299. }
  300. _GLIBCXX_NODISCARD
  301. const_reference
  302. front() const _GLIBCXX_NOEXCEPT
  303. {
  304. __glibcxx_check_nonempty();
  305. return _Base::front();
  306. }
  307. _GLIBCXX_NODISCARD
  308. reference
  309. back() _GLIBCXX_NOEXCEPT
  310. {
  311. __glibcxx_check_nonempty();
  312. return _Base::back();
  313. }
  314. _GLIBCXX_NODISCARD
  315. const_reference
  316. back() const _GLIBCXX_NOEXCEPT
  317. {
  318. __glibcxx_check_nonempty();
  319. return _Base::back();
  320. }
  321. // 23.2.1.3 modifiers:
  322. void
  323. push_front(const _Tp& __x)
  324. {
  325. _Base::push_front(__x);
  326. this->_M_invalidate_all();
  327. }
  328. void
  329. push_back(const _Tp& __x)
  330. {
  331. _Base::push_back(__x);
  332. this->_M_invalidate_all();
  333. }
  334. #if __cplusplus >= 201103L
  335. void
  336. push_front(_Tp&& __x)
  337. { emplace_front(std::move(__x)); }
  338. void
  339. push_back(_Tp&& __x)
  340. { emplace_back(std::move(__x)); }
  341. template<typename... _Args>
  342. #if __cplusplus > 201402L
  343. reference
  344. #else
  345. void
  346. #endif
  347. emplace_front(_Args&&... __args)
  348. {
  349. _Base::emplace_front(std::forward<_Args>(__args)...);
  350. this->_M_invalidate_all();
  351. #if __cplusplus > 201402L
  352. return front();
  353. #endif
  354. }
  355. template<typename... _Args>
  356. #if __cplusplus > 201402L
  357. reference
  358. #else
  359. void
  360. #endif
  361. emplace_back(_Args&&... __args)
  362. {
  363. _Base::emplace_back(std::forward<_Args>(__args)...);
  364. this->_M_invalidate_all();
  365. #if __cplusplus > 201402L
  366. return back();
  367. #endif
  368. }
  369. template<typename... _Args>
  370. iterator
  371. emplace(const_iterator __position, _Args&&... __args)
  372. {
  373. __glibcxx_check_insert(__position);
  374. _Base_iterator __res = _Base::emplace(__position.base(),
  375. std::forward<_Args>(__args)...);
  376. this->_M_invalidate_all();
  377. return iterator(__res, this);
  378. }
  379. #endif
  380. iterator
  381. #if __cplusplus >= 201103L
  382. insert(const_iterator __position, const _Tp& __x)
  383. #else
  384. insert(iterator __position, const _Tp& __x)
  385. #endif
  386. {
  387. __glibcxx_check_insert(__position);
  388. _Base_iterator __res = _Base::insert(__position.base(), __x);
  389. this->_M_invalidate_all();
  390. return iterator(__res, this);
  391. }
  392. #if __cplusplus >= 201103L
  393. iterator
  394. insert(const_iterator __position, _Tp&& __x)
  395. { return emplace(__position, std::move(__x)); }
  396. iterator
  397. insert(const_iterator __position, initializer_list<value_type> __l)
  398. {
  399. __glibcxx_check_insert(__position);
  400. _Base_iterator __res = _Base::insert(__position.base(), __l);
  401. this->_M_invalidate_all();
  402. return iterator(__res, this);
  403. }
  404. #endif
  405. #if __cplusplus >= 201103L
  406. iterator
  407. insert(const_iterator __position, size_type __n, const _Tp& __x)
  408. {
  409. __glibcxx_check_insert(__position);
  410. _Base_iterator __res = _Base::insert(__position.base(), __n, __x);
  411. this->_M_invalidate_all();
  412. return iterator(__res, this);
  413. }
  414. #else
  415. void
  416. insert(iterator __position, size_type __n, const _Tp& __x)
  417. {
  418. __glibcxx_check_insert(__position);
  419. _Base::insert(__position.base(), __n, __x);
  420. this->_M_invalidate_all();
  421. }
  422. #endif
  423. #if __cplusplus >= 201103L
  424. template<class _InputIterator,
  425. typename = std::_RequireInputIter<_InputIterator>>
  426. iterator
  427. insert(const_iterator __position,
  428. _InputIterator __first, _InputIterator __last)
  429. {
  430. typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
  431. __glibcxx_check_insert_range(__position, __first, __last, __dist);
  432. _Base_iterator __res;
  433. if (__dist.second >= __gnu_debug::__dp_sign)
  434. __res = _Base::insert(__position.base(),
  435. __gnu_debug::__unsafe(__first),
  436. __gnu_debug::__unsafe(__last));
  437. else
  438. __res = _Base::insert(__position.base(), __first, __last);
  439. this->_M_invalidate_all();
  440. return iterator(__res, this);
  441. }
  442. #else
  443. template<class _InputIterator>
  444. void
  445. insert(iterator __position,
  446. _InputIterator __first, _InputIterator __last)
  447. {
  448. typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
  449. __glibcxx_check_insert_range(__position, __first, __last, __dist);
  450. if (__dist.second >= __gnu_debug::__dp_sign)
  451. _Base::insert(__position.base(),
  452. __gnu_debug::__unsafe(__first),
  453. __gnu_debug::__unsafe(__last));
  454. else
  455. _Base::insert(__position.base(), __first, __last);
  456. this->_M_invalidate_all();
  457. }
  458. #endif
  459. void
  460. pop_front() _GLIBCXX_NOEXCEPT
  461. {
  462. __glibcxx_check_nonempty();
  463. this->_M_invalidate_if(_Equal(_Base::begin()));
  464. _Base::pop_front();
  465. }
  466. void
  467. pop_back() _GLIBCXX_NOEXCEPT
  468. {
  469. __glibcxx_check_nonempty();
  470. this->_M_invalidate_if(_Equal(--_Base::end()));
  471. _Base::pop_back();
  472. }
  473. iterator
  474. #if __cplusplus >= 201103L
  475. erase(const_iterator __position)
  476. #else
  477. erase(iterator __position)
  478. #endif
  479. {
  480. __glibcxx_check_erase(__position);
  481. #if __cplusplus >= 201103L
  482. _Base_const_iterator __victim = __position.base();
  483. #else
  484. _Base_iterator __victim = __position.base();
  485. #endif
  486. if (__victim == _Base::begin() || __victim == _Base::end() - 1)
  487. {
  488. this->_M_invalidate_if(_Equal(__victim));
  489. return iterator(_Base::erase(__victim), this);
  490. }
  491. else
  492. {
  493. _Base_iterator __res = _Base::erase(__victim);
  494. this->_M_invalidate_all();
  495. return iterator(__res, this);
  496. }
  497. }
  498. iterator
  499. #if __cplusplus >= 201103L
  500. erase(const_iterator __first, const_iterator __last)
  501. #else
  502. erase(iterator __first, iterator __last)
  503. #endif
  504. {
  505. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  506. // 151. can't currently clear() empty container
  507. __glibcxx_check_erase_range(__first, __last);
  508. if (__first.base() == __last.base())
  509. #if __cplusplus >= 201103L
  510. return iterator(__first.base()._M_const_cast(), this);
  511. #else
  512. return __first;
  513. #endif
  514. else if (__first.base() == _Base::begin()
  515. || __last.base() == _Base::end())
  516. {
  517. this->_M_detach_singular();
  518. for (_Base_const_iterator __position = __first.base();
  519. __position != __last.base(); ++__position)
  520. {
  521. this->_M_invalidate_if(_Equal(__position));
  522. }
  523. __try
  524. {
  525. return iterator(_Base::erase(__first.base(), __last.base()),
  526. this);
  527. }
  528. __catch(...)
  529. {
  530. this->_M_revalidate_singular();
  531. __throw_exception_again;
  532. }
  533. }
  534. else
  535. {
  536. _Base_iterator __res = _Base::erase(__first.base(),
  537. __last.base());
  538. this->_M_invalidate_all();
  539. return iterator(__res, this);
  540. }
  541. }
  542. void
  543. swap(deque& __x)
  544. _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
  545. {
  546. _Safe::_M_swap(__x);
  547. _Base::swap(__x);
  548. }
  549. void
  550. clear() _GLIBCXX_NOEXCEPT
  551. {
  552. _Base::clear();
  553. this->_M_invalidate_all();
  554. }
  555. _Base&
  556. _M_base() _GLIBCXX_NOEXCEPT { return *this; }
  557. const _Base&
  558. _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
  559. };
  560. #if __cpp_deduction_guides >= 201606
  561. template<typename _InputIterator, typename _ValT
  562. = typename iterator_traits<_InputIterator>::value_type,
  563. typename _Allocator = allocator<_ValT>,
  564. typename = _RequireInputIter<_InputIterator>,
  565. typename = _RequireAllocator<_Allocator>>
  566. deque(_InputIterator, _InputIterator, _Allocator = _Allocator())
  567. -> deque<_ValT, _Allocator>;
  568. template<typename _Tp, typename _Allocator = allocator<_Tp>,
  569. typename = _RequireAllocator<_Allocator>>
  570. deque(size_t, _Tp, _Allocator = _Allocator())
  571. -> deque<_Tp, _Allocator>;
  572. #endif
  573. template<typename _Tp, typename _Alloc>
  574. inline bool
  575. operator==(const deque<_Tp, _Alloc>& __lhs,
  576. const deque<_Tp, _Alloc>& __rhs)
  577. { return __lhs._M_base() == __rhs._M_base(); }
  578. #if __cpp_lib_three_way_comparison
  579. template<typename _Tp, typename _Alloc>
  580. constexpr __detail::__synth3way_t<_Tp>
  581. operator<=>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
  582. { return __x._M_base() <=> __y._M_base(); }
  583. #else
  584. template<typename _Tp, typename _Alloc>
  585. inline bool
  586. operator!=(const deque<_Tp, _Alloc>& __lhs,
  587. const deque<_Tp, _Alloc>& __rhs)
  588. { return __lhs._M_base() != __rhs._M_base(); }
  589. template<typename _Tp, typename _Alloc>
  590. inline bool
  591. operator<(const deque<_Tp, _Alloc>& __lhs,
  592. const deque<_Tp, _Alloc>& __rhs)
  593. { return __lhs._M_base() < __rhs._M_base(); }
  594. template<typename _Tp, typename _Alloc>
  595. inline bool
  596. operator<=(const deque<_Tp, _Alloc>& __lhs,
  597. const deque<_Tp, _Alloc>& __rhs)
  598. { return __lhs._M_base() <= __rhs._M_base(); }
  599. template<typename _Tp, typename _Alloc>
  600. inline bool
  601. operator>=(const deque<_Tp, _Alloc>& __lhs,
  602. const deque<_Tp, _Alloc>& __rhs)
  603. { return __lhs._M_base() >= __rhs._M_base(); }
  604. template<typename _Tp, typename _Alloc>
  605. inline bool
  606. operator>(const deque<_Tp, _Alloc>& __lhs,
  607. const deque<_Tp, _Alloc>& __rhs)
  608. { return __lhs._M_base() > __rhs._M_base(); }
  609. #endif // three-way comparison
  610. template<typename _Tp, typename _Alloc>
  611. inline void
  612. swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
  613. _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
  614. { __lhs.swap(__rhs); }
  615. } // namespace __debug
  616. } // namespace std
  617. #endif