stl_multimap.h 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. // Multimap implementation -*- C++ -*-
  2. // Copyright (C) 2001-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. /*
  21. *
  22. * Copyright (c) 1994
  23. * Hewlett-Packard Company
  24. *
  25. * Permission to use, copy, modify, distribute and sell this software
  26. * and its documentation for any purpose is hereby granted without fee,
  27. * provided that the above copyright notice appear in all copies and
  28. * that both that copyright notice and this permission notice appear
  29. * in supporting documentation. Hewlett-Packard Company makes no
  30. * representations about the suitability of this software for any
  31. * purpose. It is provided "as is" without express or implied warranty.
  32. *
  33. *
  34. * Copyright (c) 1996,1997
  35. * Silicon Graphics Computer Systems, Inc.
  36. *
  37. * Permission to use, copy, modify, distribute and sell this software
  38. * and its documentation for any purpose is hereby granted without fee,
  39. * provided that the above copyright notice appear in all copies and
  40. * that both that copyright notice and this permission notice appear
  41. * in supporting documentation. Silicon Graphics makes no
  42. * representations about the suitability of this software for any
  43. * purpose. It is provided "as is" without express or implied warranty.
  44. */
  45. /** @file bits/stl_multimap.h
  46. * This is an internal header file, included by other library headers.
  47. * Do not attempt to use it directly. @headername{map}
  48. */
  49. #ifndef _STL_MULTIMAP_H
  50. #define _STL_MULTIMAP_H 1
  51. #include <bits/concept_check.h>
  52. #if __cplusplus >= 201103L
  53. #include <initializer_list>
  54. #endif
  55. namespace std _GLIBCXX_VISIBILITY(default)
  56. {
  57. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  58. _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
  59. template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
  60. class map;
  61. /**
  62. * @brief A standard container made up of (key,value) pairs, which can be
  63. * retrieved based on a key, in logarithmic time.
  64. *
  65. * @ingroup associative_containers
  66. *
  67. * @tparam _Key Type of key objects.
  68. * @tparam _Tp Type of mapped objects.
  69. * @tparam _Compare Comparison function object type, defaults to less<_Key>.
  70. * @tparam _Alloc Allocator type, defaults to
  71. * allocator<pair<const _Key, _Tp>.
  72. *
  73. * Meets the requirements of a <a href="tables.html#65">container</a>, a
  74. * <a href="tables.html#66">reversible container</a>, and an
  75. * <a href="tables.html#69">associative container</a> (using equivalent
  76. * keys). For a @c multimap<Key,T> the key_type is Key, the mapped_type
  77. * is T, and the value_type is std::pair<const Key,T>.
  78. *
  79. * Multimaps support bidirectional iterators.
  80. *
  81. * The private tree data is declared exactly the same way for map and
  82. * multimap; the distinction is made entirely in how the tree functions are
  83. * called (*_unique versus *_equal, same as the standard).
  84. */
  85. template <typename _Key, typename _Tp,
  86. typename _Compare = std::less<_Key>,
  87. typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
  88. class multimap
  89. {
  90. public:
  91. typedef _Key key_type;
  92. typedef _Tp mapped_type;
  93. typedef std::pair<const _Key, _Tp> value_type;
  94. typedef _Compare key_compare;
  95. typedef _Alloc allocator_type;
  96. private:
  97. #ifdef _GLIBCXX_CONCEPT_CHECKS
  98. // concept requirements
  99. typedef typename _Alloc::value_type _Alloc_value_type;
  100. # if __cplusplus < 201103L
  101. __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
  102. # endif
  103. __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
  104. _BinaryFunctionConcept)
  105. __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
  106. #endif
  107. #if __cplusplus >= 201103L
  108. #if __cplusplus > 201703L || defined __STRICT_ANSI__
  109. static_assert(is_same<typename _Alloc::value_type, value_type>::value,
  110. "std::multimap must have the same value_type as its allocator");
  111. #endif
  112. #endif
  113. public:
  114. #pragma GCC diagnostic push
  115. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  116. class value_compare
  117. : public std::binary_function<value_type, value_type, bool>
  118. {
  119. friend class multimap<_Key, _Tp, _Compare, _Alloc>;
  120. protected:
  121. _Compare comp;
  122. value_compare(_Compare __c)
  123. : comp(__c) { }
  124. public:
  125. bool operator()(const value_type& __x, const value_type& __y) const
  126. { return comp(__x.first, __y.first); }
  127. };
  128. #pragma GCC diagnostic pop
  129. private:
  130. /// This turns a red-black tree into a [multi]map.
  131. typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
  132. rebind<value_type>::other _Pair_alloc_type;
  133. typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
  134. key_compare, _Pair_alloc_type> _Rep_type;
  135. /// The actual tree structure.
  136. _Rep_type _M_t;
  137. typedef __gnu_cxx::__alloc_traits<_Pair_alloc_type> _Alloc_traits;
  138. public:
  139. // many of these are specified differently in ISO, but the following are
  140. // "functionally equivalent"
  141. typedef typename _Alloc_traits::pointer pointer;
  142. typedef typename _Alloc_traits::const_pointer const_pointer;
  143. typedef typename _Alloc_traits::reference reference;
  144. typedef typename _Alloc_traits::const_reference const_reference;
  145. typedef typename _Rep_type::iterator iterator;
  146. typedef typename _Rep_type::const_iterator const_iterator;
  147. typedef typename _Rep_type::size_type size_type;
  148. typedef typename _Rep_type::difference_type difference_type;
  149. typedef typename _Rep_type::reverse_iterator reverse_iterator;
  150. typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
  151. #if __cplusplus > 201402L
  152. using node_type = typename _Rep_type::node_type;
  153. #endif
  154. // [23.3.2] construct/copy/destroy
  155. // (get_allocator() is also listed in this section)
  156. /**
  157. * @brief Default constructor creates no elements.
  158. */
  159. #if __cplusplus < 201103L
  160. multimap() : _M_t() { }
  161. #else
  162. multimap() = default;
  163. #endif
  164. /**
  165. * @brief Creates a %multimap with no elements.
  166. * @param __comp A comparison object.
  167. * @param __a An allocator object.
  168. */
  169. explicit
  170. multimap(const _Compare& __comp,
  171. const allocator_type& __a = allocator_type())
  172. : _M_t(__comp, _Pair_alloc_type(__a)) { }
  173. /**
  174. * @brief %Multimap copy constructor.
  175. *
  176. * Whether the allocator is copied depends on the allocator traits.
  177. */
  178. #if __cplusplus < 201103L
  179. multimap(const multimap& __x)
  180. : _M_t(__x._M_t) { }
  181. #else
  182. multimap(const multimap&) = default;
  183. /**
  184. * @brief %Multimap move constructor.
  185. *
  186. * The newly-created %multimap contains the exact contents of the
  187. * moved instance. The moved instance is a valid, but unspecified
  188. * %multimap.
  189. */
  190. multimap(multimap&&) = default;
  191. /**
  192. * @brief Builds a %multimap from an initializer_list.
  193. * @param __l An initializer_list.
  194. * @param __comp A comparison functor.
  195. * @param __a An allocator object.
  196. *
  197. * Create a %multimap consisting of copies of the elements from
  198. * the initializer_list. This is linear in N if the list is already
  199. * sorted, and NlogN otherwise (where N is @a __l.size()).
  200. */
  201. multimap(initializer_list<value_type> __l,
  202. const _Compare& __comp = _Compare(),
  203. const allocator_type& __a = allocator_type())
  204. : _M_t(__comp, _Pair_alloc_type(__a))
  205. { _M_t._M_insert_range_equal(__l.begin(), __l.end()); }
  206. /// Allocator-extended default constructor.
  207. explicit
  208. multimap(const allocator_type& __a)
  209. : _M_t(_Pair_alloc_type(__a)) { }
  210. /// Allocator-extended copy constructor.
  211. multimap(const multimap& __m,
  212. const __type_identity_t<allocator_type>& __a)
  213. : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
  214. /// Allocator-extended move constructor.
  215. multimap(multimap&& __m, const __type_identity_t<allocator_type>& __a)
  216. noexcept(is_nothrow_copy_constructible<_Compare>::value
  217. && _Alloc_traits::_S_always_equal())
  218. : _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { }
  219. /// Allocator-extended initialier-list constructor.
  220. multimap(initializer_list<value_type> __l, const allocator_type& __a)
  221. : _M_t(_Pair_alloc_type(__a))
  222. { _M_t._M_insert_range_equal(__l.begin(), __l.end()); }
  223. /// Allocator-extended range constructor.
  224. template<typename _InputIterator>
  225. multimap(_InputIterator __first, _InputIterator __last,
  226. const allocator_type& __a)
  227. : _M_t(_Pair_alloc_type(__a))
  228. { _M_t._M_insert_range_equal(__first, __last); }
  229. #endif
  230. /**
  231. * @brief Builds a %multimap from a range.
  232. * @param __first An input iterator.
  233. * @param __last An input iterator.
  234. *
  235. * Create a %multimap consisting of copies of the elements from
  236. * [__first,__last). This is linear in N if the range is already sorted,
  237. * and NlogN otherwise (where N is distance(__first,__last)).
  238. */
  239. template<typename _InputIterator>
  240. multimap(_InputIterator __first, _InputIterator __last)
  241. : _M_t()
  242. { _M_t._M_insert_range_equal(__first, __last); }
  243. /**
  244. * @brief Builds a %multimap from a range.
  245. * @param __first An input iterator.
  246. * @param __last An input iterator.
  247. * @param __comp A comparison functor.
  248. * @param __a An allocator object.
  249. *
  250. * Create a %multimap consisting of copies of the elements from
  251. * [__first,__last). This is linear in N if the range is already sorted,
  252. * and NlogN otherwise (where N is distance(__first,__last)).
  253. */
  254. template<typename _InputIterator>
  255. multimap(_InputIterator __first, _InputIterator __last,
  256. const _Compare& __comp,
  257. const allocator_type& __a = allocator_type())
  258. : _M_t(__comp, _Pair_alloc_type(__a))
  259. { _M_t._M_insert_range_equal(__first, __last); }
  260. #if __cplusplus >= 201103L
  261. /**
  262. * The dtor only erases the elements, and note that if the elements
  263. * themselves are pointers, the pointed-to memory is not touched in any
  264. * way. Managing the pointer is the user's responsibility.
  265. */
  266. ~multimap() = default;
  267. #endif
  268. /**
  269. * @brief %Multimap assignment operator.
  270. *
  271. * Whether the allocator is copied depends on the allocator traits.
  272. */
  273. #if __cplusplus < 201103L
  274. multimap&
  275. operator=(const multimap& __x)
  276. {
  277. _M_t = __x._M_t;
  278. return *this;
  279. }
  280. #else
  281. multimap&
  282. operator=(const multimap&) = default;
  283. /// Move assignment operator.
  284. multimap&
  285. operator=(multimap&&) = default;
  286. /**
  287. * @brief %Multimap list assignment operator.
  288. * @param __l An initializer_list.
  289. *
  290. * This function fills a %multimap with copies of the elements
  291. * in the initializer list @a __l.
  292. *
  293. * Note that the assignment completely changes the %multimap and
  294. * that the resulting %multimap's size is the same as the number
  295. * of elements assigned.
  296. */
  297. multimap&
  298. operator=(initializer_list<value_type> __l)
  299. {
  300. _M_t._M_assign_equal(__l.begin(), __l.end());
  301. return *this;
  302. }
  303. #endif
  304. /// Get a copy of the memory allocation object.
  305. allocator_type
  306. get_allocator() const _GLIBCXX_NOEXCEPT
  307. { return allocator_type(_M_t.get_allocator()); }
  308. // iterators
  309. /**
  310. * Returns a read/write iterator that points to the first pair in the
  311. * %multimap. Iteration is done in ascending order according to the
  312. * keys.
  313. */
  314. iterator
  315. begin() _GLIBCXX_NOEXCEPT
  316. { return _M_t.begin(); }
  317. /**
  318. * Returns a read-only (constant) iterator that points to the first pair
  319. * in the %multimap. Iteration is done in ascending order according to
  320. * the keys.
  321. */
  322. const_iterator
  323. begin() const _GLIBCXX_NOEXCEPT
  324. { return _M_t.begin(); }
  325. /**
  326. * Returns a read/write iterator that points one past the last pair in
  327. * the %multimap. Iteration is done in ascending order according to the
  328. * keys.
  329. */
  330. iterator
  331. end() _GLIBCXX_NOEXCEPT
  332. { return _M_t.end(); }
  333. /**
  334. * Returns a read-only (constant) iterator that points one past the last
  335. * pair in the %multimap. Iteration is done in ascending order according
  336. * to the keys.
  337. */
  338. const_iterator
  339. end() const _GLIBCXX_NOEXCEPT
  340. { return _M_t.end(); }
  341. /**
  342. * Returns a read/write reverse iterator that points to the last pair in
  343. * the %multimap. Iteration is done in descending order according to the
  344. * keys.
  345. */
  346. reverse_iterator
  347. rbegin() _GLIBCXX_NOEXCEPT
  348. { return _M_t.rbegin(); }
  349. /**
  350. * Returns a read-only (constant) reverse iterator that points to the
  351. * last pair in the %multimap. Iteration is done in descending order
  352. * according to the keys.
  353. */
  354. const_reverse_iterator
  355. rbegin() const _GLIBCXX_NOEXCEPT
  356. { return _M_t.rbegin(); }
  357. /**
  358. * Returns a read/write reverse iterator that points to one before the
  359. * first pair in the %multimap. Iteration is done in descending order
  360. * according to the keys.
  361. */
  362. reverse_iterator
  363. rend() _GLIBCXX_NOEXCEPT
  364. { return _M_t.rend(); }
  365. /**
  366. * Returns a read-only (constant) reverse iterator that points to one
  367. * before the first pair in the %multimap. Iteration is done in
  368. * descending order according to the keys.
  369. */
  370. const_reverse_iterator
  371. rend() const _GLIBCXX_NOEXCEPT
  372. { return _M_t.rend(); }
  373. #if __cplusplus >= 201103L
  374. /**
  375. * Returns a read-only (constant) iterator that points to the first pair
  376. * in the %multimap. Iteration is done in ascending order according to
  377. * the keys.
  378. */
  379. const_iterator
  380. cbegin() const noexcept
  381. { return _M_t.begin(); }
  382. /**
  383. * Returns a read-only (constant) iterator that points one past the last
  384. * pair in the %multimap. Iteration is done in ascending order according
  385. * to the keys.
  386. */
  387. const_iterator
  388. cend() const noexcept
  389. { return _M_t.end(); }
  390. /**
  391. * Returns a read-only (constant) reverse iterator that points to the
  392. * last pair in the %multimap. Iteration is done in descending order
  393. * according to the keys.
  394. */
  395. const_reverse_iterator
  396. crbegin() const noexcept
  397. { return _M_t.rbegin(); }
  398. /**
  399. * Returns a read-only (constant) reverse iterator that points to one
  400. * before the first pair in the %multimap. Iteration is done in
  401. * descending order according to the keys.
  402. */
  403. const_reverse_iterator
  404. crend() const noexcept
  405. { return _M_t.rend(); }
  406. #endif
  407. // capacity
  408. /** Returns true if the %multimap is empty. */
  409. _GLIBCXX_NODISCARD bool
  410. empty() const _GLIBCXX_NOEXCEPT
  411. { return _M_t.empty(); }
  412. /** Returns the size of the %multimap. */
  413. size_type
  414. size() const _GLIBCXX_NOEXCEPT
  415. { return _M_t.size(); }
  416. /** Returns the maximum size of the %multimap. */
  417. size_type
  418. max_size() const _GLIBCXX_NOEXCEPT
  419. { return _M_t.max_size(); }
  420. // modifiers
  421. #if __cplusplus >= 201103L
  422. /**
  423. * @brief Build and insert a std::pair into the %multimap.
  424. *
  425. * @param __args Arguments used to generate a new pair instance (see
  426. * std::piecewise_contruct for passing arguments to each
  427. * part of the pair constructor).
  428. *
  429. * @return An iterator that points to the inserted (key,value) pair.
  430. *
  431. * This function builds and inserts a (key, value) %pair into the
  432. * %multimap.
  433. * Contrary to a std::map the %multimap does not rely on unique keys and
  434. * thus multiple pairs with the same key can be inserted.
  435. *
  436. * Insertion requires logarithmic time.
  437. */
  438. template<typename... _Args>
  439. iterator
  440. emplace(_Args&&... __args)
  441. { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
  442. /**
  443. * @brief Builds and inserts a std::pair into the %multimap.
  444. *
  445. * @param __pos An iterator that serves as a hint as to where the pair
  446. * should be inserted.
  447. * @param __args Arguments used to generate a new pair instance (see
  448. * std::piecewise_contruct for passing arguments to each
  449. * part of the pair constructor).
  450. * @return An iterator that points to the inserted (key,value) pair.
  451. *
  452. * This function inserts a (key, value) pair into the %multimap.
  453. * Contrary to a std::map the %multimap does not rely on unique keys and
  454. * thus multiple pairs with the same key can be inserted.
  455. * Note that the first parameter is only a hint and can potentially
  456. * improve the performance of the insertion process. A bad hint would
  457. * cause no gains in efficiency.
  458. *
  459. * For more on @a hinting, see:
  460. * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
  461. *
  462. * Insertion requires logarithmic time (if the hint is not taken).
  463. */
  464. template<typename... _Args>
  465. iterator
  466. emplace_hint(const_iterator __pos, _Args&&... __args)
  467. {
  468. return _M_t._M_emplace_hint_equal(__pos,
  469. std::forward<_Args>(__args)...);
  470. }
  471. #endif
  472. /**
  473. * @brief Inserts a std::pair into the %multimap.
  474. * @param __x Pair to be inserted (see std::make_pair for easy creation
  475. * of pairs).
  476. * @return An iterator that points to the inserted (key,value) pair.
  477. *
  478. * This function inserts a (key, value) pair into the %multimap.
  479. * Contrary to a std::map the %multimap does not rely on unique keys and
  480. * thus multiple pairs with the same key can be inserted.
  481. *
  482. * Insertion requires logarithmic time.
  483. * @{
  484. */
  485. iterator
  486. insert(const value_type& __x)
  487. { return _M_t._M_insert_equal(__x); }
  488. #if __cplusplus >= 201103L
  489. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  490. // 2354. Unnecessary copying when inserting into maps with braced-init
  491. iterator
  492. insert(value_type&& __x)
  493. { return _M_t._M_insert_equal(std::move(__x)); }
  494. template<typename _Pair>
  495. __enable_if_t<is_constructible<value_type, _Pair>::value, iterator>
  496. insert(_Pair&& __x)
  497. { return _M_t._M_emplace_equal(std::forward<_Pair>(__x)); }
  498. #endif
  499. /// @}
  500. /**
  501. * @brief Inserts a std::pair into the %multimap.
  502. * @param __position An iterator that serves as a hint as to where the
  503. * pair should be inserted.
  504. * @param __x Pair to be inserted (see std::make_pair for easy creation
  505. * of pairs).
  506. * @return An iterator that points to the inserted (key,value) pair.
  507. *
  508. * This function inserts a (key, value) pair into the %multimap.
  509. * Contrary to a std::map the %multimap does not rely on unique keys and
  510. * thus multiple pairs with the same key can be inserted.
  511. * Note that the first parameter is only a hint and can potentially
  512. * improve the performance of the insertion process. A bad hint would
  513. * cause no gains in efficiency.
  514. *
  515. * For more on @a hinting, see:
  516. * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
  517. *
  518. * Insertion requires logarithmic time (if the hint is not taken).
  519. * @{
  520. */
  521. iterator
  522. #if __cplusplus >= 201103L
  523. insert(const_iterator __position, const value_type& __x)
  524. #else
  525. insert(iterator __position, const value_type& __x)
  526. #endif
  527. { return _M_t._M_insert_equal_(__position, __x); }
  528. #if __cplusplus >= 201103L
  529. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  530. // 2354. Unnecessary copying when inserting into maps with braced-init
  531. iterator
  532. insert(const_iterator __position, value_type&& __x)
  533. { return _M_t._M_insert_equal_(__position, std::move(__x)); }
  534. template<typename _Pair>
  535. __enable_if_t<is_constructible<value_type, _Pair&&>::value, iterator>
  536. insert(const_iterator __position, _Pair&& __x)
  537. {
  538. return _M_t._M_emplace_hint_equal(__position,
  539. std::forward<_Pair>(__x));
  540. }
  541. #endif
  542. /// @}
  543. /**
  544. * @brief A template function that attempts to insert a range
  545. * of elements.
  546. * @param __first Iterator pointing to the start of the range to be
  547. * inserted.
  548. * @param __last Iterator pointing to the end of the range.
  549. *
  550. * Complexity similar to that of the range constructor.
  551. */
  552. template<typename _InputIterator>
  553. void
  554. insert(_InputIterator __first, _InputIterator __last)
  555. { _M_t._M_insert_range_equal(__first, __last); }
  556. #if __cplusplus >= 201103L
  557. /**
  558. * @brief Attempts to insert a list of std::pairs into the %multimap.
  559. * @param __l A std::initializer_list<value_type> of pairs to be
  560. * inserted.
  561. *
  562. * Complexity similar to that of the range constructor.
  563. */
  564. void
  565. insert(initializer_list<value_type> __l)
  566. { this->insert(__l.begin(), __l.end()); }
  567. #endif
  568. #if __cplusplus > 201402L
  569. /// Extract a node.
  570. node_type
  571. extract(const_iterator __pos)
  572. {
  573. __glibcxx_assert(__pos != end());
  574. return _M_t.extract(__pos);
  575. }
  576. /// Extract a node.
  577. node_type
  578. extract(const key_type& __x)
  579. { return _M_t.extract(__x); }
  580. /// Re-insert an extracted node.
  581. iterator
  582. insert(node_type&& __nh)
  583. { return _M_t._M_reinsert_node_equal(std::move(__nh)); }
  584. /// Re-insert an extracted node.
  585. iterator
  586. insert(const_iterator __hint, node_type&& __nh)
  587. { return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); }
  588. template<typename, typename>
  589. friend struct std::_Rb_tree_merge_helper;
  590. template<typename _Cmp2>
  591. void
  592. merge(multimap<_Key, _Tp, _Cmp2, _Alloc>& __source)
  593. {
  594. using _Merge_helper = _Rb_tree_merge_helper<multimap, _Cmp2>;
  595. _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
  596. }
  597. template<typename _Cmp2>
  598. void
  599. merge(multimap<_Key, _Tp, _Cmp2, _Alloc>&& __source)
  600. { merge(__source); }
  601. template<typename _Cmp2>
  602. void
  603. merge(map<_Key, _Tp, _Cmp2, _Alloc>& __source)
  604. {
  605. using _Merge_helper = _Rb_tree_merge_helper<multimap, _Cmp2>;
  606. _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
  607. }
  608. template<typename _Cmp2>
  609. void
  610. merge(map<_Key, _Tp, _Cmp2, _Alloc>&& __source)
  611. { merge(__source); }
  612. #endif // C++17
  613. #if __cplusplus >= 201103L
  614. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  615. // DR 130. Associative erase should return an iterator.
  616. /**
  617. * @brief Erases an element from a %multimap.
  618. * @param __position An iterator pointing to the element to be erased.
  619. * @return An iterator pointing to the element immediately following
  620. * @a position prior to the element being erased. If no such
  621. * element exists, end() is returned.
  622. *
  623. * This function erases an element, pointed to by the given iterator,
  624. * from a %multimap. Note that this function only erases the element,
  625. * and that if the element is itself a pointer, the pointed-to memory is
  626. * not touched in any way. Managing the pointer is the user's
  627. * responsibility.
  628. *
  629. * @{
  630. */
  631. iterator
  632. erase(const_iterator __position)
  633. { return _M_t.erase(__position); }
  634. // LWG 2059.
  635. _GLIBCXX_ABI_TAG_CXX11
  636. iterator
  637. erase(iterator __position)
  638. { return _M_t.erase(__position); }
  639. /// @}
  640. #else
  641. /**
  642. * @brief Erases an element from a %multimap.
  643. * @param __position An iterator pointing to the element to be erased.
  644. *
  645. * This function erases an element, pointed to by the given iterator,
  646. * from a %multimap. Note that this function only erases the element,
  647. * and that if the element is itself a pointer, the pointed-to memory is
  648. * not touched in any way. Managing the pointer is the user's
  649. * responsibility.
  650. */
  651. void
  652. erase(iterator __position)
  653. { _M_t.erase(__position); }
  654. #endif
  655. /**
  656. * @brief Erases elements according to the provided key.
  657. * @param __x Key of element to be erased.
  658. * @return The number of elements erased.
  659. *
  660. * This function erases all elements located by the given key from a
  661. * %multimap.
  662. * Note that this function only erases the element, and that if
  663. * the element is itself a pointer, the pointed-to memory is not touched
  664. * in any way. Managing the pointer is the user's responsibility.
  665. */
  666. size_type
  667. erase(const key_type& __x)
  668. { return _M_t.erase(__x); }
  669. #if __cplusplus >= 201103L
  670. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  671. // DR 130. Associative erase should return an iterator.
  672. /**
  673. * @brief Erases a [first,last) range of elements from a %multimap.
  674. * @param __first Iterator pointing to the start of the range to be
  675. * erased.
  676. * @param __last Iterator pointing to the end of the range to be
  677. * erased .
  678. * @return The iterator @a __last.
  679. *
  680. * This function erases a sequence of elements from a %multimap.
  681. * Note that this function only erases the elements, and that if
  682. * the elements themselves are pointers, the pointed-to memory is not
  683. * touched in any way. Managing the pointer is the user's
  684. * responsibility.
  685. */
  686. iterator
  687. erase(const_iterator __first, const_iterator __last)
  688. { return _M_t.erase(__first, __last); }
  689. #else
  690. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  691. // DR 130. Associative erase should return an iterator.
  692. /**
  693. * @brief Erases a [first,last) range of elements from a %multimap.
  694. * @param __first Iterator pointing to the start of the range to be
  695. * erased.
  696. * @param __last Iterator pointing to the end of the range to
  697. * be erased.
  698. *
  699. * This function erases a sequence of elements from a %multimap.
  700. * Note that this function only erases the elements, and that if
  701. * the elements themselves are pointers, the pointed-to memory is not
  702. * touched in any way. Managing the pointer is the user's
  703. * responsibility.
  704. */
  705. void
  706. erase(iterator __first, iterator __last)
  707. { _M_t.erase(__first, __last); }
  708. #endif
  709. /**
  710. * @brief Swaps data with another %multimap.
  711. * @param __x A %multimap of the same element and allocator types.
  712. *
  713. * This exchanges the elements between two multimaps in constant time.
  714. * (It is only swapping a pointer, an integer, and an instance of
  715. * the @c Compare type (which itself is often stateless and empty), so it
  716. * should be quite fast.)
  717. * Note that the global std::swap() function is specialized such that
  718. * std::swap(m1,m2) will feed to this function.
  719. *
  720. * Whether the allocators are swapped depends on the allocator traits.
  721. */
  722. void
  723. swap(multimap& __x)
  724. _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
  725. { _M_t.swap(__x._M_t); }
  726. /**
  727. * Erases all elements in a %multimap. Note that this function only
  728. * erases the elements, and that if the elements themselves are pointers,
  729. * the pointed-to memory is not touched in any way. Managing the pointer
  730. * is the user's responsibility.
  731. */
  732. void
  733. clear() _GLIBCXX_NOEXCEPT
  734. { _M_t.clear(); }
  735. // observers
  736. /**
  737. * Returns the key comparison object out of which the %multimap
  738. * was constructed.
  739. */
  740. key_compare
  741. key_comp() const
  742. { return _M_t.key_comp(); }
  743. /**
  744. * Returns a value comparison object, built from the key comparison
  745. * object out of which the %multimap was constructed.
  746. */
  747. value_compare
  748. value_comp() const
  749. { return value_compare(_M_t.key_comp()); }
  750. // multimap operations
  751. ///@{
  752. /**
  753. * @brief Tries to locate an element in a %multimap.
  754. * @param __x Key of (key, value) pair to be located.
  755. * @return Iterator pointing to sought-after element,
  756. * or end() if not found.
  757. *
  758. * This function takes a key and tries to locate the element with which
  759. * the key matches. If successful the function returns an iterator
  760. * pointing to the sought after %pair. If unsuccessful it returns the
  761. * past-the-end ( @c end() ) iterator.
  762. */
  763. iterator
  764. find(const key_type& __x)
  765. { return _M_t.find(__x); }
  766. #if __cplusplus > 201103L
  767. template<typename _Kt>
  768. auto
  769. find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
  770. { return _M_t._M_find_tr(__x); }
  771. #endif
  772. ///@}
  773. ///@{
  774. /**
  775. * @brief Tries to locate an element in a %multimap.
  776. * @param __x Key of (key, value) pair to be located.
  777. * @return Read-only (constant) iterator pointing to sought-after
  778. * element, or end() if not found.
  779. *
  780. * This function takes a key and tries to locate the element with which
  781. * the key matches. If successful the function returns a constant
  782. * iterator pointing to the sought after %pair. If unsuccessful it
  783. * returns the past-the-end ( @c end() ) iterator.
  784. */
  785. const_iterator
  786. find(const key_type& __x) const
  787. { return _M_t.find(__x); }
  788. #if __cplusplus > 201103L
  789. template<typename _Kt>
  790. auto
  791. find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x))
  792. { return _M_t._M_find_tr(__x); }
  793. #endif
  794. ///@}
  795. ///@{
  796. /**
  797. * @brief Finds the number of elements with given key.
  798. * @param __x Key of (key, value) pairs to be located.
  799. * @return Number of elements with specified key.
  800. */
  801. size_type
  802. count(const key_type& __x) const
  803. { return _M_t.count(__x); }
  804. #if __cplusplus > 201103L
  805. template<typename _Kt>
  806. auto
  807. count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
  808. { return _M_t._M_count_tr(__x); }
  809. #endif
  810. ///@}
  811. #if __cplusplus > 201703L
  812. ///@{
  813. /**
  814. * @brief Finds whether an element with the given key exists.
  815. * @param __x Key of (key, value) pairs to be located.
  816. * @return True if there is any element with the specified key.
  817. */
  818. bool
  819. contains(const key_type& __x) const
  820. { return _M_t.find(__x) != _M_t.end(); }
  821. template<typename _Kt>
  822. auto
  823. contains(const _Kt& __x) const
  824. -> decltype(_M_t._M_find_tr(__x), void(), true)
  825. { return _M_t._M_find_tr(__x) != _M_t.end(); }
  826. ///@}
  827. #endif
  828. ///@{
  829. /**
  830. * @brief Finds the beginning of a subsequence matching given key.
  831. * @param __x Key of (key, value) pair to be located.
  832. * @return Iterator pointing to first element equal to or greater
  833. * than key, or end().
  834. *
  835. * This function returns the first element of a subsequence of elements
  836. * that matches the given key. If unsuccessful it returns an iterator
  837. * pointing to the first element that has a greater value than given key
  838. * or end() if no such element exists.
  839. */
  840. iterator
  841. lower_bound(const key_type& __x)
  842. { return _M_t.lower_bound(__x); }
  843. #if __cplusplus > 201103L
  844. template<typename _Kt>
  845. auto
  846. lower_bound(const _Kt& __x)
  847. -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
  848. { return iterator(_M_t._M_lower_bound_tr(__x)); }
  849. #endif
  850. ///@}
  851. ///@{
  852. /**
  853. * @brief Finds the beginning of a subsequence matching given key.
  854. * @param __x Key of (key, value) pair to be located.
  855. * @return Read-only (constant) iterator pointing to first element
  856. * equal to or greater than key, or end().
  857. *
  858. * This function returns the first element of a subsequence of
  859. * elements that matches the given key. If unsuccessful the
  860. * iterator will point to the next greatest element or, if no
  861. * such greater element exists, to end().
  862. */
  863. const_iterator
  864. lower_bound(const key_type& __x) const
  865. { return _M_t.lower_bound(__x); }
  866. #if __cplusplus > 201103L
  867. template<typename _Kt>
  868. auto
  869. lower_bound(const _Kt& __x) const
  870. -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
  871. { return const_iterator(_M_t._M_lower_bound_tr(__x)); }
  872. #endif
  873. ///@}
  874. ///@{
  875. /**
  876. * @brief Finds the end of a subsequence matching given key.
  877. * @param __x Key of (key, value) pair to be located.
  878. * @return Iterator pointing to the first element
  879. * greater than key, or end().
  880. */
  881. iterator
  882. upper_bound(const key_type& __x)
  883. { return _M_t.upper_bound(__x); }
  884. #if __cplusplus > 201103L
  885. template<typename _Kt>
  886. auto
  887. upper_bound(const _Kt& __x)
  888. -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
  889. { return iterator(_M_t._M_upper_bound_tr(__x)); }
  890. #endif
  891. ///@}
  892. ///@{
  893. /**
  894. * @brief Finds the end of a subsequence matching given key.
  895. * @param __x Key of (key, value) pair to be located.
  896. * @return Read-only (constant) iterator pointing to first iterator
  897. * greater than key, or end().
  898. */
  899. const_iterator
  900. upper_bound(const key_type& __x) const
  901. { return _M_t.upper_bound(__x); }
  902. #if __cplusplus > 201103L
  903. template<typename _Kt>
  904. auto
  905. upper_bound(const _Kt& __x) const
  906. -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
  907. { return const_iterator(_M_t._M_upper_bound_tr(__x)); }
  908. #endif
  909. ///@}
  910. ///@{
  911. /**
  912. * @brief Finds a subsequence matching given key.
  913. * @param __x Key of (key, value) pairs to be located.
  914. * @return Pair of iterators that possibly points to the subsequence
  915. * matching given key.
  916. *
  917. * This function is equivalent to
  918. * @code
  919. * std::make_pair(c.lower_bound(val),
  920. * c.upper_bound(val))
  921. * @endcode
  922. * (but is faster than making the calls separately).
  923. */
  924. std::pair<iterator, iterator>
  925. equal_range(const key_type& __x)
  926. { return _M_t.equal_range(__x); }
  927. #if __cplusplus > 201103L
  928. template<typename _Kt>
  929. auto
  930. equal_range(const _Kt& __x)
  931. -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
  932. { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); }
  933. #endif
  934. ///@}
  935. ///@{
  936. /**
  937. * @brief Finds a subsequence matching given key.
  938. * @param __x Key of (key, value) pairs to be located.
  939. * @return Pair of read-only (constant) iterators that possibly points
  940. * to the subsequence matching given key.
  941. *
  942. * This function is equivalent to
  943. * @code
  944. * std::make_pair(c.lower_bound(val),
  945. * c.upper_bound(val))
  946. * @endcode
  947. * (but is faster than making the calls separately).
  948. */
  949. std::pair<const_iterator, const_iterator>
  950. equal_range(const key_type& __x) const
  951. { return _M_t.equal_range(__x); }
  952. #if __cplusplus > 201103L
  953. template<typename _Kt>
  954. auto
  955. equal_range(const _Kt& __x) const
  956. -> decltype(pair<const_iterator, const_iterator>(
  957. _M_t._M_equal_range_tr(__x)))
  958. {
  959. return pair<const_iterator, const_iterator>(
  960. _M_t._M_equal_range_tr(__x));
  961. }
  962. #endif
  963. ///@}
  964. template<typename _K1, typename _T1, typename _C1, typename _A1>
  965. friend bool
  966. operator==(const multimap<_K1, _T1, _C1, _A1>&,
  967. const multimap<_K1, _T1, _C1, _A1>&);
  968. #if __cpp_lib_three_way_comparison
  969. template<typename _K1, typename _T1, typename _C1, typename _A1>
  970. friend __detail::__synth3way_t<pair<const _K1, _T1>>
  971. operator<=>(const multimap<_K1, _T1, _C1, _A1>&,
  972. const multimap<_K1, _T1, _C1, _A1>&);
  973. #else
  974. template<typename _K1, typename _T1, typename _C1, typename _A1>
  975. friend bool
  976. operator<(const multimap<_K1, _T1, _C1, _A1>&,
  977. const multimap<_K1, _T1, _C1, _A1>&);
  978. #endif
  979. };
  980. #if __cpp_deduction_guides >= 201606
  981. template<typename _InputIterator,
  982. typename _Compare = less<__iter_key_t<_InputIterator>>,
  983. typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
  984. typename = _RequireInputIter<_InputIterator>,
  985. typename = _RequireNotAllocator<_Compare>,
  986. typename = _RequireAllocator<_Allocator>>
  987. multimap(_InputIterator, _InputIterator,
  988. _Compare = _Compare(), _Allocator = _Allocator())
  989. -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
  990. _Compare, _Allocator>;
  991. template<typename _Key, typename _Tp, typename _Compare = less<_Key>,
  992. typename _Allocator = allocator<pair<const _Key, _Tp>>,
  993. typename = _RequireNotAllocator<_Compare>,
  994. typename = _RequireAllocator<_Allocator>>
  995. multimap(initializer_list<pair<_Key, _Tp>>,
  996. _Compare = _Compare(), _Allocator = _Allocator())
  997. -> multimap<_Key, _Tp, _Compare, _Allocator>;
  998. template<typename _InputIterator, typename _Allocator,
  999. typename = _RequireInputIter<_InputIterator>,
  1000. typename = _RequireAllocator<_Allocator>>
  1001. multimap(_InputIterator, _InputIterator, _Allocator)
  1002. -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
  1003. less<__iter_key_t<_InputIterator>>, _Allocator>;
  1004. template<typename _Key, typename _Tp, typename _Allocator,
  1005. typename = _RequireAllocator<_Allocator>>
  1006. multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
  1007. -> multimap<_Key, _Tp, less<_Key>, _Allocator>;
  1008. #endif // deduction guides
  1009. /**
  1010. * @brief Multimap equality comparison.
  1011. * @param __x A %multimap.
  1012. * @param __y A %multimap of the same type as @a __x.
  1013. * @return True iff the size and elements of the maps are equal.
  1014. *
  1015. * This is an equivalence relation. It is linear in the size of the
  1016. * multimaps. Multimaps are considered equivalent if their sizes are equal,
  1017. * and if corresponding elements compare equal.
  1018. */
  1019. template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
  1020. inline bool
  1021. operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
  1022. const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
  1023. { return __x._M_t == __y._M_t; }
  1024. #if __cpp_lib_three_way_comparison
  1025. /**
  1026. * @brief Multimap ordering relation.
  1027. * @param __x A `multimap`.
  1028. * @param __y A `multimap` of the same type as `x`.
  1029. * @return A value indicating whether `__x` is less than, equal to,
  1030. * greater than, or incomparable with `__y`.
  1031. *
  1032. * This is a total ordering relation. It is linear in the size of the
  1033. * maps. The elements must be comparable with @c <.
  1034. *
  1035. * See `std::lexicographical_compare_three_way()` for how the determination
  1036. * is made. This operator is used to synthesize relational operators like
  1037. * `<` and `>=` etc.
  1038. */
  1039. template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
  1040. inline __detail::__synth3way_t<pair<const _Key, _Tp>>
  1041. operator<=>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
  1042. const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
  1043. { return __x._M_t <=> __y._M_t; }
  1044. #else
  1045. /**
  1046. * @brief Multimap ordering relation.
  1047. * @param __x A %multimap.
  1048. * @param __y A %multimap of the same type as @a __x.
  1049. * @return True iff @a x is lexicographically less than @a y.
  1050. *
  1051. * This is a total ordering relation. It is linear in the size of the
  1052. * multimaps. The elements must be comparable with @c <.
  1053. *
  1054. * See std::lexicographical_compare() for how the determination is made.
  1055. */
  1056. template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
  1057. inline bool
  1058. operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
  1059. const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
  1060. { return __x._M_t < __y._M_t; }
  1061. /// Based on operator==
  1062. template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
  1063. inline bool
  1064. operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
  1065. const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
  1066. { return !(__x == __y); }
  1067. /// Based on operator<
  1068. template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
  1069. inline bool
  1070. operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
  1071. const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
  1072. { return __y < __x; }
  1073. /// Based on operator<
  1074. template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
  1075. inline bool
  1076. operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
  1077. const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
  1078. { return !(__y < __x); }
  1079. /// Based on operator<
  1080. template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
  1081. inline bool
  1082. operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
  1083. const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
  1084. { return !(__x < __y); }
  1085. #endif // three-way comparison
  1086. /// See std::multimap::swap().
  1087. template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
  1088. inline void
  1089. swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
  1090. multimap<_Key, _Tp, _Compare, _Alloc>& __y)
  1091. _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
  1092. { __x.swap(__y); }
  1093. _GLIBCXX_END_NAMESPACE_CONTAINER
  1094. #if __cplusplus > 201402L
  1095. // Allow std::multimap access to internals of compatible maps.
  1096. template<typename _Key, typename _Val, typename _Cmp1, typename _Alloc,
  1097. typename _Cmp2>
  1098. struct
  1099. _Rb_tree_merge_helper<_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>,
  1100. _Cmp2>
  1101. {
  1102. private:
  1103. friend class _GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>;
  1104. static auto&
  1105. _S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map)
  1106. { return __map._M_t; }
  1107. static auto&
  1108. _S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map)
  1109. { return __map._M_t; }
  1110. };
  1111. #endif // C++17
  1112. _GLIBCXX_END_NAMESPACE_VERSION
  1113. } // namespace std
  1114. #endif /* _STL_MULTIMAP_H */