multimap.h 20 KB

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