multimap.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. // Debugging multimap implementation -*- C++ -*-
  2. // Copyright (C) 2003-2018 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/multimap.h
  21. * This file is a GNU debug extension to the Standard C++ Library.
  22. */
  23. #ifndef _GLIBCXX_DEBUG_MULTIMAP_H
  24. #define _GLIBCXX_DEBUG_MULTIMAP_H 1
  25. #include <debug/safe_sequence.h>
  26. #include <debug/safe_container.h>
  27. #include <debug/safe_iterator.h>
  28. #include <utility>
  29. namespace std _GLIBCXX_VISIBILITY(default)
  30. {
  31. namespace __debug
  32. {
  33. /// Class std::multimap with safety/checking/debug instrumentation.
  34. template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
  35. typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
  36. class multimap
  37. : public __gnu_debug::_Safe_container<
  38. multimap<_Key, _Tp, _Compare, _Allocator>, _Allocator,
  39. __gnu_debug::_Safe_node_sequence>,
  40. public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>
  41. {
  42. typedef _GLIBCXX_STD_C::multimap<
  43. _Key, _Tp, _Compare, _Allocator> _Base;
  44. typedef __gnu_debug::_Safe_container<
  45. multimap, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe;
  46. typedef typename _Base::const_iterator _Base_const_iterator;
  47. typedef typename _Base::iterator _Base_iterator;
  48. typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
  49. public:
  50. // types:
  51. typedef _Key key_type;
  52. typedef _Tp mapped_type;
  53. typedef std::pair<const _Key, _Tp> value_type;
  54. typedef _Compare key_compare;
  55. typedef _Allocator allocator_type;
  56. typedef typename _Base::reference reference;
  57. typedef typename _Base::const_reference const_reference;
  58. typedef __gnu_debug::_Safe_iterator<_Base_iterator, multimap>
  59. iterator;
  60. typedef __gnu_debug::_Safe_iterator<_Base_const_iterator,
  61. multimap> const_iterator;
  62. typedef typename _Base::size_type size_type;
  63. typedef typename _Base::difference_type difference_type;
  64. typedef typename _Base::pointer pointer;
  65. typedef typename _Base::const_pointer const_pointer;
  66. typedef std::reverse_iterator<iterator> reverse_iterator;
  67. typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
  68. // 23.3.1.1 construct/copy/destroy:
  69. #if __cplusplus < 201103L
  70. multimap() : _Base() { }
  71. multimap(const multimap& __x)
  72. : _Base(__x) { }
  73. ~multimap() { }
  74. #else
  75. multimap() = default;
  76. multimap(const multimap&) = default;
  77. multimap(multimap&&) = default;
  78. multimap(initializer_list<value_type> __l,
  79. const _Compare& __c = _Compare(),
  80. const allocator_type& __a = allocator_type())
  81. : _Base(__l, __c, __a) { }
  82. explicit
  83. multimap(const allocator_type& __a)
  84. : _Base(__a) { }
  85. multimap(const multimap& __m, const allocator_type& __a)
  86. : _Base(__m, __a) { }
  87. multimap(multimap&& __m, const allocator_type& __a)
  88. noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) )
  89. : _Safe(std::move(__m._M_safe()), __a),
  90. _Base(std::move(__m._M_base()), __a) { }
  91. multimap(initializer_list<value_type> __l, const allocator_type& __a)
  92. : _Base(__l, __a) { }
  93. template<typename _InputIterator>
  94. multimap(_InputIterator __first, _InputIterator __last,
  95. const allocator_type& __a)
  96. : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
  97. __last)),
  98. __gnu_debug::__base(__last), __a) { }
  99. ~multimap() = default;
  100. #endif
  101. explicit multimap(const _Compare& __comp,
  102. const _Allocator& __a = _Allocator())
  103. : _Base(__comp, __a) { }
  104. template<typename _InputIterator>
  105. multimap(_InputIterator __first, _InputIterator __last,
  106. const _Compare& __comp = _Compare(),
  107. const _Allocator& __a = _Allocator())
  108. : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
  109. __last)),
  110. __gnu_debug::__base(__last),
  111. __comp, __a) { }
  112. multimap(const _Base& __x)
  113. : _Base(__x) { }
  114. #if __cplusplus < 201103L
  115. multimap&
  116. operator=(const multimap& __x)
  117. {
  118. this->_M_safe() = __x;
  119. _M_base() = __x;
  120. return *this;
  121. }
  122. #else
  123. multimap&
  124. operator=(const multimap&) = default;
  125. multimap&
  126. operator=(multimap&&) = default;
  127. multimap&
  128. operator=(initializer_list<value_type> __l)
  129. {
  130. _M_base() = __l;
  131. this->_M_invalidate_all();
  132. return *this;
  133. }
  134. #endif
  135. using _Base::get_allocator;
  136. // iterators:
  137. iterator
  138. begin() _GLIBCXX_NOEXCEPT
  139. { return iterator(_Base::begin(), this); }
  140. const_iterator
  141. begin() const _GLIBCXX_NOEXCEPT
  142. { return const_iterator(_Base::begin(), this); }
  143. iterator
  144. end() _GLIBCXX_NOEXCEPT
  145. { return iterator(_Base::end(), this); }
  146. const_iterator
  147. end() const _GLIBCXX_NOEXCEPT
  148. { return const_iterator(_Base::end(), this); }
  149. reverse_iterator
  150. rbegin() _GLIBCXX_NOEXCEPT
  151. { return reverse_iterator(end()); }
  152. const_reverse_iterator
  153. rbegin() const _GLIBCXX_NOEXCEPT
  154. { return const_reverse_iterator(end()); }
  155. reverse_iterator
  156. rend() _GLIBCXX_NOEXCEPT
  157. { return reverse_iterator(begin()); }
  158. const_reverse_iterator
  159. rend() const _GLIBCXX_NOEXCEPT
  160. { return const_reverse_iterator(begin()); }
  161. #if __cplusplus >= 201103L
  162. const_iterator
  163. cbegin() const noexcept
  164. { return const_iterator(_Base::begin(), this); }
  165. const_iterator
  166. cend() const noexcept
  167. { return const_iterator(_Base::end(), this); }
  168. const_reverse_iterator
  169. crbegin() const noexcept
  170. { return const_reverse_iterator(end()); }
  171. const_reverse_iterator
  172. crend() const noexcept
  173. { return const_reverse_iterator(begin()); }
  174. #endif
  175. // capacity:
  176. using _Base::empty;
  177. using _Base::size;
  178. using _Base::max_size;
  179. // modifiers:
  180. #if __cplusplus >= 201103L
  181. template<typename... _Args>
  182. iterator
  183. emplace(_Args&&... __args)
  184. {
  185. return iterator(_Base::emplace(std::forward<_Args>(__args)...), this);
  186. }
  187. template<typename... _Args>
  188. iterator
  189. emplace_hint(const_iterator __pos, _Args&&... __args)
  190. {
  191. __glibcxx_check_insert(__pos);
  192. return iterator(_Base::emplace_hint(__pos.base(),
  193. std::forward<_Args>(__args)...),
  194. this);
  195. }
  196. #endif
  197. iterator
  198. insert(const value_type& __x)
  199. { return iterator(_Base::insert(__x), this); }
  200. #if __cplusplus >= 201103L
  201. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  202. // 2354. Unnecessary copying when inserting into maps with braced-init
  203. iterator
  204. insert(value_type&& __x)
  205. { return { _Base::insert(std::move(__x)), this }; }
  206. template<typename _Pair, typename = typename
  207. std::enable_if<std::is_constructible<value_type,
  208. _Pair&&>::value>::type>
  209. iterator
  210. insert(_Pair&& __x)
  211. { return iterator(_Base::insert(std::forward<_Pair>(__x)), this); }
  212. #endif
  213. #if __cplusplus >= 201103L
  214. void
  215. insert(std::initializer_list<value_type> __list)
  216. { _Base::insert(__list); }
  217. #endif
  218. iterator
  219. #if __cplusplus >= 201103L
  220. insert(const_iterator __position, const value_type& __x)
  221. #else
  222. insert(iterator __position, const value_type& __x)
  223. #endif
  224. {
  225. __glibcxx_check_insert(__position);
  226. return iterator(_Base::insert(__position.base(), __x), this);
  227. }
  228. #if __cplusplus >= 201103L
  229. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  230. // 2354. Unnecessary copying when inserting into maps with braced-init
  231. iterator
  232. insert(const_iterator __position, value_type&& __x)
  233. {
  234. __glibcxx_check_insert(__position);
  235. return { _Base::insert(__position.base(), std::move(__x)), this };
  236. }
  237. template<typename _Pair, typename = typename
  238. std::enable_if<std::is_constructible<value_type,
  239. _Pair&&>::value>::type>
  240. iterator
  241. insert(const_iterator __position, _Pair&& __x)
  242. {
  243. __glibcxx_check_insert(__position);
  244. return iterator(_Base::insert(__position.base(),
  245. std::forward<_Pair>(__x)), this);
  246. }
  247. #endif
  248. template<typename _InputIterator>
  249. void
  250. insert(_InputIterator __first, _InputIterator __last)
  251. {
  252. typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
  253. __glibcxx_check_valid_range2(__first, __last, __dist);
  254. if (__dist.second >= __gnu_debug::__dp_sign)
  255. _Base::insert(__gnu_debug::__unsafe(__first),
  256. __gnu_debug::__unsafe(__last));
  257. else
  258. _Base::insert(__first, __last);
  259. }
  260. #if __cplusplus > 201402L
  261. using node_type = typename _Base::node_type;
  262. node_type
  263. extract(const_iterator __position)
  264. {
  265. __glibcxx_check_erase(__position);
  266. this->_M_invalidate_if(_Equal(__position.base()));
  267. return _Base::extract(__position.base());
  268. }
  269. node_type
  270. extract(const key_type& __key)
  271. {
  272. const auto __position = find(__key);
  273. if (__position != end())
  274. return extract(__position);
  275. return {};
  276. }
  277. iterator
  278. insert(node_type&& __nh)
  279. { return iterator(_Base::insert(std::move(__nh)), this); }
  280. iterator
  281. insert(const_iterator __hint, node_type&& __nh)
  282. {
  283. __glibcxx_check_insert(__hint);
  284. return iterator(_Base::insert(__hint.base(), std::move(__nh)), this);
  285. }
  286. using _Base::merge;
  287. #endif // C++17
  288. #if __cplusplus >= 201103L
  289. iterator
  290. erase(const_iterator __position)
  291. {
  292. __glibcxx_check_erase(__position);
  293. this->_M_invalidate_if(_Equal(__position.base()));
  294. return iterator(_Base::erase(__position.base()), this);
  295. }
  296. iterator
  297. erase(iterator __position)
  298. { return erase(const_iterator(__position)); }
  299. #else
  300. void
  301. erase(iterator __position)
  302. {
  303. __glibcxx_check_erase(__position);
  304. this->_M_invalidate_if(_Equal(__position.base()));
  305. _Base::erase(__position.base());
  306. }
  307. #endif
  308. size_type
  309. erase(const key_type& __x)
  310. {
  311. std::pair<_Base_iterator, _Base_iterator> __victims =
  312. _Base::equal_range(__x);
  313. size_type __count = 0;
  314. _Base_iterator __victim = __victims.first;
  315. while (__victim != __victims.second)
  316. {
  317. this->_M_invalidate_if(_Equal(__victim));
  318. _Base::erase(__victim++);
  319. ++__count;
  320. }
  321. return __count;
  322. }
  323. #if __cplusplus >= 201103L
  324. iterator
  325. erase(const_iterator __first, const_iterator __last)
  326. {
  327. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  328. // 151. can't currently clear() empty container
  329. __glibcxx_check_erase_range(__first, __last);
  330. for (_Base_const_iterator __victim = __first.base();
  331. __victim != __last.base(); ++__victim)
  332. {
  333. _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
  334. _M_message(__gnu_debug::__msg_valid_range)
  335. ._M_iterator(__first, "first")
  336. ._M_iterator(__last, "last"));
  337. this->_M_invalidate_if(_Equal(__victim));
  338. }
  339. return iterator(_Base::erase(__first.base(), __last.base()), this);
  340. }
  341. #else
  342. void
  343. erase(iterator __first, iterator __last)
  344. {
  345. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  346. // 151. can't currently clear() empty container
  347. __glibcxx_check_erase_range(__first, __last);
  348. for (_Base_iterator __victim = __first.base();
  349. __victim != __last.base(); ++__victim)
  350. {
  351. _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
  352. _M_message(__gnu_debug::__msg_valid_range)
  353. ._M_iterator(__first, "first")
  354. ._M_iterator(__last, "last"));
  355. this->_M_invalidate_if(_Equal(__victim));
  356. }
  357. _Base::erase(__first.base(), __last.base());
  358. }
  359. #endif
  360. void
  361. swap(multimap& __x)
  362. _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
  363. {
  364. _Safe::_M_swap(__x);
  365. _Base::swap(__x);
  366. }
  367. void
  368. clear() _GLIBCXX_NOEXCEPT
  369. {
  370. this->_M_invalidate_all();
  371. _Base::clear();
  372. }
  373. // observers:
  374. using _Base::key_comp;
  375. using _Base::value_comp;
  376. // 23.3.1.3 multimap operations:
  377. iterator
  378. find(const key_type& __x)
  379. { return iterator(_Base::find(__x), this); }
  380. #if __cplusplus > 201103L
  381. template<typename _Kt,
  382. typename _Req =
  383. typename __has_is_transparent<_Compare, _Kt>::type>
  384. iterator
  385. find(const _Kt& __x)
  386. { return { _Base::find(__x), this }; }
  387. #endif
  388. const_iterator
  389. find(const key_type& __x) const
  390. { return const_iterator(_Base::find(__x), this); }
  391. #if __cplusplus > 201103L
  392. template<typename _Kt,
  393. typename _Req =
  394. typename __has_is_transparent<_Compare, _Kt>::type>
  395. const_iterator
  396. find(const _Kt& __x) const
  397. { return { _Base::find(__x), this }; }
  398. #endif
  399. using _Base::count;
  400. iterator
  401. lower_bound(const key_type& __x)
  402. { return iterator(_Base::lower_bound(__x), this); }
  403. #if __cplusplus > 201103L
  404. template<typename _Kt,
  405. typename _Req =
  406. typename __has_is_transparent<_Compare, _Kt>::type>
  407. iterator
  408. lower_bound(const _Kt& __x)
  409. { return { _Base::lower_bound(__x), this }; }
  410. #endif
  411. const_iterator
  412. lower_bound(const key_type& __x) const
  413. { return const_iterator(_Base::lower_bound(__x), this); }
  414. #if __cplusplus > 201103L
  415. template<typename _Kt,
  416. typename _Req =
  417. typename __has_is_transparent<_Compare, _Kt>::type>
  418. const_iterator
  419. lower_bound(const _Kt& __x) const
  420. { return { _Base::lower_bound(__x), this }; }
  421. #endif
  422. iterator
  423. upper_bound(const key_type& __x)
  424. { return iterator(_Base::upper_bound(__x), this); }
  425. #if __cplusplus > 201103L
  426. template<typename _Kt,
  427. typename _Req =
  428. typename __has_is_transparent<_Compare, _Kt>::type>
  429. iterator
  430. upper_bound(const _Kt& __x)
  431. { return { _Base::upper_bound(__x), this }; }
  432. #endif
  433. const_iterator
  434. upper_bound(const key_type& __x) const
  435. { return const_iterator(_Base::upper_bound(__x), this); }
  436. #if __cplusplus > 201103L
  437. template<typename _Kt,
  438. typename _Req =
  439. typename __has_is_transparent<_Compare, _Kt>::type>
  440. const_iterator
  441. upper_bound(const _Kt& __x) const
  442. { return { _Base::upper_bound(__x), this }; }
  443. #endif
  444. std::pair<iterator,iterator>
  445. equal_range(const key_type& __x)
  446. {
  447. std::pair<_Base_iterator, _Base_iterator> __res =
  448. _Base::equal_range(__x);
  449. return std::make_pair(iterator(__res.first, this),
  450. iterator(__res.second, this));
  451. }
  452. #if __cplusplus > 201103L
  453. template<typename _Kt,
  454. typename _Req =
  455. typename __has_is_transparent<_Compare, _Kt>::type>
  456. std::pair<iterator, iterator>
  457. equal_range(const _Kt& __x)
  458. {
  459. auto __res = _Base::equal_range(__x);
  460. return { { __res.first, this }, { __res.second, this } };
  461. }
  462. #endif
  463. std::pair<const_iterator,const_iterator>
  464. equal_range(const key_type& __x) const
  465. {
  466. std::pair<_Base_const_iterator, _Base_const_iterator> __res =
  467. _Base::equal_range(__x);
  468. return std::make_pair(const_iterator(__res.first, this),
  469. const_iterator(__res.second, this));
  470. }
  471. #if __cplusplus > 201103L
  472. template<typename _Kt,
  473. typename _Req =
  474. typename __has_is_transparent<_Compare, _Kt>::type>
  475. std::pair<const_iterator, const_iterator>
  476. equal_range(const _Kt& __x) const
  477. {
  478. auto __res = _Base::equal_range(__x);
  479. return { { __res.first, this }, { __res.second, this } };
  480. }
  481. #endif
  482. _Base&
  483. _M_base() _GLIBCXX_NOEXCEPT { return *this; }
  484. const _Base&
  485. _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
  486. };
  487. #if __cpp_deduction_guides >= 201606
  488. template<typename _InputIterator,
  489. typename _Compare = less<__iter_key_t<_InputIterator>>,
  490. typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
  491. typename = _RequireInputIter<_InputIterator>,
  492. typename = _RequireAllocator<_Allocator>>
  493. multimap(_InputIterator, _InputIterator,
  494. _Compare = _Compare(), _Allocator = _Allocator())
  495. -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
  496. _Compare, _Allocator>;
  497. template<typename _Key, typename _Tp, typename _Compare = less<_Key>,
  498. typename _Allocator = allocator<pair<const _Key, _Tp>>,
  499. typename = _RequireAllocator<_Allocator>>
  500. multimap(initializer_list<pair<_Key, _Tp>>,
  501. _Compare = _Compare(), _Allocator = _Allocator())
  502. -> multimap<_Key, _Tp, _Compare, _Allocator>;
  503. template<typename _InputIterator, typename _Allocator,
  504. typename = _RequireInputIter<_InputIterator>,
  505. typename = _RequireAllocator<_Allocator>>
  506. multimap(_InputIterator, _InputIterator, _Allocator)
  507. -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
  508. less<__iter_key_t<_InputIterator>>, _Allocator>;
  509. template<typename _Key, typename _Tp, typename _Allocator,
  510. typename = _RequireAllocator<_Allocator>>
  511. multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
  512. -> multimap<_Key, _Tp, less<_Key>, _Allocator>;
  513. #endif
  514. template<typename _Key, typename _Tp,
  515. typename _Compare, typename _Allocator>
  516. inline bool
  517. operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
  518. const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
  519. { return __lhs._M_base() == __rhs._M_base(); }
  520. template<typename _Key, typename _Tp,
  521. typename _Compare, typename _Allocator>
  522. inline bool
  523. operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
  524. const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
  525. { return __lhs._M_base() != __rhs._M_base(); }
  526. template<typename _Key, typename _Tp,
  527. typename _Compare, typename _Allocator>
  528. inline bool
  529. operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
  530. const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
  531. { return __lhs._M_base() < __rhs._M_base(); }
  532. template<typename _Key, typename _Tp,
  533. typename _Compare, typename _Allocator>
  534. inline bool
  535. operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
  536. const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
  537. { return __lhs._M_base() <= __rhs._M_base(); }
  538. template<typename _Key, typename _Tp,
  539. typename _Compare, typename _Allocator>
  540. inline bool
  541. operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
  542. const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
  543. { return __lhs._M_base() >= __rhs._M_base(); }
  544. template<typename _Key, typename _Tp,
  545. typename _Compare, typename _Allocator>
  546. inline bool
  547. operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
  548. const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
  549. { return __lhs._M_base() > __rhs._M_base(); }
  550. template<typename _Key, typename _Tp,
  551. typename _Compare, typename _Allocator>
  552. inline void
  553. swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
  554. multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
  555. _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
  556. { __lhs.swap(__rhs); }
  557. } // namespace __debug
  558. } // namespace std
  559. #endif