map.hpp 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_CONTAINER_MAP_HPP
  11. #define BOOST_CONTAINER_MAP_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #if defined(BOOST_HAS_PRAGMA_ONCE)
  16. # pragma once
  17. #endif
  18. #include <boost/container/detail/config_begin.hpp>
  19. #include <boost/container/detail/workaround.hpp>
  20. // container
  21. #include <boost/container/container_fwd.hpp>
  22. #include <boost/container/new_allocator.hpp> //new_allocator
  23. #include <boost/container/throw_exception.hpp>
  24. // container/detail
  25. #include <boost/container/detail/mpl.hpp>
  26. #include <boost/container/detail/tree.hpp>
  27. #include <boost/container/detail/type_traits.hpp>
  28. #include <boost/container/detail/value_init.hpp>
  29. #include <boost/container/detail/pair.hpp>
  30. #include <boost/container/detail/pair_key_mapped_of_value.hpp>
  31. #include <boost/container/detail/algorithm.hpp>
  32. // move
  33. #include <boost/move/traits.hpp>
  34. #include <boost/move/utility_core.hpp>
  35. // move/detail
  36. #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  37. #include <boost/move/detail/fwd_macros.hpp>
  38. #endif
  39. #include <boost/move/detail/move_helpers.hpp>
  40. // intrusive/detail
  41. #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
  42. #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
  43. // std
  44. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  45. #include <initializer_list>
  46. #endif
  47. namespace boost {
  48. namespace container {
  49. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  50. //! A map is a kind of associative container that supports unique keys (contains at
  51. //! most one of each key value) and provides for fast retrieval of values of another
  52. //! type T based on the keys. The map class supports bidirectional iterators.
  53. //!
  54. //! A map satisfies all of the requirements of a container and of a reversible
  55. //! container and of an associative container. The <code>value_type</code> stored
  56. //! by this container is the value_type is std::pair<const Key, T>.
  57. //!
  58. //! \tparam Key is the key_type of the map
  59. //! \tparam T is the <code>mapped_type</code>
  60. //! \tparam Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
  61. //! \tparam Allocator is the allocator to allocate the <code>value_type</code>s
  62. //! (e.g. <i>allocator< std::pair<const Key, T> > </i>).
  63. //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options.
  64. template < class Key, class T, class Compare = std::less<Key>
  65. , class Allocator = void, class Options = tree_assoc_defaults >
  66. #else
  67. template <class Key, class T, class Compare, class Allocator, class Options>
  68. #endif
  69. class map
  70. ///@cond
  71. : public dtl::tree
  72. < std::pair<const Key, T>
  73. , int
  74. , Compare, Allocator, Options>
  75. ///@endcond
  76. {
  77. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  78. private:
  79. BOOST_COPYABLE_AND_MOVABLE(map)
  80. typedef int select_1st_t;
  81. typedef std::pair<const Key, T> value_type_impl;
  82. typedef dtl::tree
  83. <value_type_impl, select_1st_t, Compare, Allocator, Options> base_t;
  84. typedef dtl::pair <Key, T> movable_value_type_impl;
  85. typedef typename base_t::value_compare value_compare_impl;
  86. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  87. public:
  88. //////////////////////////////////////////////
  89. //
  90. // types
  91. //
  92. //////////////////////////////////////////////
  93. typedef Key key_type;
  94. typedef T mapped_type;
  95. typedef typename base_t::allocator_type allocator_type;
  96. typedef ::boost::container::allocator_traits<allocator_type> allocator_traits_type;
  97. typedef typename boost::container::allocator_traits<allocator_type>::value_type value_type;
  98. typedef typename boost::container::allocator_traits<allocator_type>::pointer pointer;
  99. typedef typename boost::container::allocator_traits<allocator_type>::const_pointer const_pointer;
  100. typedef typename boost::container::allocator_traits<allocator_type>::reference reference;
  101. typedef typename boost::container::allocator_traits<allocator_type>::const_reference const_reference;
  102. typedef typename boost::container::allocator_traits<allocator_type>::size_type size_type;
  103. typedef typename boost::container::allocator_traits<allocator_type>::difference_type difference_type;
  104. typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
  105. typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
  106. typedef Compare key_compare;
  107. typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
  108. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
  109. typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
  110. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
  111. //typedef std::pair<key_type, mapped_type> nonconst_value_type;
  112. typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type;
  113. typedef BOOST_CONTAINER_IMPDEF(node_handle<
  114. typename base_t::stored_allocator_type
  115. BOOST_MOVE_I pair_key_mapped_of_value
  116. <key_type BOOST_MOVE_I mapped_type> >) node_type;
  117. typedef BOOST_CONTAINER_IMPDEF
  118. (insert_return_type_base<iterator BOOST_MOVE_I node_type>) insert_return_type;
  119. //allocator_type::value_type type must be std::pair<CONST Key, T>
  120. BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<typename allocator_type::value_type, std::pair<const Key, T> >::value));
  121. //////////////////////////////////////////////
  122. //
  123. // construct/copy/destroy
  124. //
  125. //////////////////////////////////////////////
  126. //! <b>Effects</b>: Default constructs an empty map.
  127. //!
  128. //! <b>Complexity</b>: Constant.
  129. inline
  130. map() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<allocator_type>::value &&
  131. dtl::is_nothrow_default_constructible<Compare>::value)
  132. : base_t()
  133. {}
  134. //! <b>Effects</b>: Constructs an empty map using the specified comparison object
  135. //! and allocator.
  136. //!
  137. //! <b>Complexity</b>: Constant.
  138. inline map(const Compare& comp, const allocator_type& a)
  139. : base_t(comp, a)
  140. {}
  141. //! <b>Effects</b>: Constructs an empty map using the specified comparison object.
  142. //!
  143. //! <b>Complexity</b>: Constant.
  144. inline explicit map(const Compare& comp)
  145. : base_t(comp)
  146. {}
  147. //! <b>Effects</b>: Constructs an empty map using the specified allocator.
  148. //!
  149. //! <b>Complexity</b>: Constant.
  150. inline explicit map(const allocator_type& a)
  151. : base_t(a)
  152. {}
  153. //! <b>Effects</b>: Constructs an empty map and
  154. //! inserts elements from the range [first ,last ).
  155. //!
  156. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  157. //! the predicate and otherwise N logN, where N is last - first.
  158. template <class InputIterator>
  159. inline map(InputIterator first, InputIterator last)
  160. : base_t(true, first, last)
  161. {}
  162. //! <b>Effects</b>: Constructs an empty map using the specified
  163. //! allocator, and inserts elements from the range [first ,last ).
  164. //!
  165. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  166. //! the predicate and otherwise N logN, where N is last - first.
  167. template <class InputIterator>
  168. inline map(InputIterator first, InputIterator last, const allocator_type& a)
  169. : base_t(true, first, last, Compare(), a)
  170. {}
  171. //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
  172. //! inserts elements from the range [first ,last ).
  173. //!
  174. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  175. //! the predicate and otherwise N logN, where N is last - first.
  176. template <class InputIterator>
  177. inline map(InputIterator first, InputIterator last, const Compare& comp)
  178. : base_t(true, first, last, comp)
  179. {}
  180. //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
  181. //! allocator, and inserts elements from the range [first ,last ).
  182. //!
  183. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  184. //! the predicate and otherwise N logN, where N is last - first.
  185. template <class InputIterator>
  186. inline map(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  187. : base_t(true, first, last, comp, a)
  188. {}
  189. //! <b>Effects</b>: Constructs an empty map and
  190. //! inserts elements from the ordered unique range [first ,last). This function
  191. //! is more efficient than the normal range creation for ordered ranges.
  192. //!
  193. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  194. //! unique values.
  195. //!
  196. //! <b>Complexity</b>: Linear in N.
  197. //!
  198. //! <b>Note</b>: Non-standard extension.
  199. template <class InputIterator>
  200. inline map( ordered_unique_range_t, InputIterator first, InputIterator last)
  201. : base_t(ordered_range, first, last)
  202. {}
  203. //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
  204. //! inserts elements from the ordered unique range [first ,last). This function
  205. //! is more efficient than the normal range creation for ordered ranges.
  206. //!
  207. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  208. //! unique values.
  209. //!
  210. //! <b>Complexity</b>: Linear in N.
  211. //!
  212. //! <b>Note</b>: Non-standard extension.
  213. template <class InputIterator>
  214. inline map( ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp)
  215. : base_t(ordered_range, first, last, comp)
  216. {}
  217. //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
  218. //! allocator, and inserts elements from the ordered unique range [first ,last). This function
  219. //! is more efficient than the normal range creation for ordered ranges.
  220. //!
  221. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  222. //! unique values.
  223. //!
  224. //! <b>Complexity</b>: Linear in N.
  225. //!
  226. //! <b>Note</b>: Non-standard extension.
  227. template <class InputIterator>
  228. inline map( ordered_unique_range_t, InputIterator first, InputIterator last
  229. , const Compare& comp, const allocator_type& a)
  230. : base_t(ordered_range, first, last, comp, a)
  231. {}
  232. //! <b>Effects</b>: Constructs an empty map using the specified allocator object and
  233. //! inserts elements from the ordered unique range [first ,last). This function
  234. //! is more efficient than the normal range creation for ordered ranges.
  235. //!
  236. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  237. //! unique values.
  238. //!
  239. //! <b>Complexity</b>: Linear in N.
  240. //!
  241. //! <b>Note</b>: Non-standard extension.
  242. template <class InputIterator>
  243. inline map(ordered_unique_range_t, InputIterator first, InputIterator last, const allocator_type& a)
  244. : base_t(ordered_range, first, last, Compare(), a)
  245. {}
  246. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  247. //! <b>Effects</b>: Constructs an empty map and
  248. //! inserts elements from the range [il.begin(), il.end()).
  249. //!
  250. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted according
  251. //! to the predicate and otherwise N logN, where N is il.first() - il.end().
  252. inline map(std::initializer_list<value_type> il)
  253. : base_t(true, il.begin(), il.end())
  254. {}
  255. //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
  256. //! inserts elements from the range [il.begin(), il.end()).
  257. //!
  258. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  259. //! the predicate and otherwise N logN, where N is il.first() - il.end().
  260. inline map(std::initializer_list<value_type> il, const Compare& comp)
  261. : base_t(true, il.begin(), il.end(), comp)
  262. {}
  263. //! <b>Effects</b>: Constructs an empty map using the specified
  264. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  265. //!
  266. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  267. //! the predicate and otherwise N logN, where N is il.first() - il.end().
  268. inline map(std::initializer_list<value_type> il, const allocator_type& a)
  269. : base_t(true, il.begin(), il.end(), Compare(), a)
  270. {}
  271. //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
  272. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  273. //!
  274. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  275. //! the predicate and otherwise N logN, where N is il.first() - il.end().
  276. inline map(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  277. : base_t(true, il.begin(), il.end(), comp, a)
  278. {}
  279. //! <b>Effects</b>: Constructs an empty map and inserts elements from the ordered unique range [il.begin(), il.end()).
  280. //! This function is more efficient than the normal range creation for ordered ranges.
  281. //!
  282. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  283. //! unique values.
  284. //!
  285. //! <b>Complexity</b>: Linear in N.
  286. //!
  287. //! <b>Note</b>: Non-standard extension.
  288. inline map(ordered_unique_range_t, std::initializer_list<value_type> il)
  289. : base_t(ordered_range, il.begin(), il.end())
  290. {}
  291. //! <b>Effects</b>: Constructs an empty map using the specified comparison object,
  292. //! and inserts elements from the ordered unique range [il.begin(), il.end()). This function
  293. //! is more efficient than the normal range creation for ordered ranges.
  294. //!
  295. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  296. //! unique values.
  297. //!
  298. //! <b>Complexity</b>: Linear in N.
  299. //!
  300. //! <b>Note</b>: Non-standard extension.
  301. inline map(ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp)
  302. : base_t(ordered_range, il.begin(), il.end(), comp)
  303. {}
  304. //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
  305. //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function
  306. //! is more efficient than the normal range creation for ordered ranges.
  307. //!
  308. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  309. //! unique values.
  310. //!
  311. //! <b>Complexity</b>: Linear in N.
  312. //!
  313. //! <b>Note</b>: Non-standard extension.
  314. inline map( ordered_unique_range_t, std::initializer_list<value_type> il
  315. , const Compare& comp, const allocator_type& a)
  316. : base_t(ordered_range, il.begin(), il.end(), comp, a)
  317. {}
  318. #endif
  319. //! <b>Effects</b>: Copy constructs a map.
  320. //!
  321. //! <b>Complexity</b>: Linear in x.size().
  322. inline map(const map& x)
  323. : base_t(static_cast<const base_t&>(x))
  324. {}
  325. //! <b>Effects</b>: Move constructs a map. Constructs *this using x's resources.
  326. //!
  327. //! <b>Complexity</b>: Constant.
  328. //!
  329. //! <b>Postcondition</b>: x is emptied.
  330. inline map(BOOST_RV_REF(map) x)
  331. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value)
  332. : base_t(BOOST_MOVE_BASE(base_t, x))
  333. {}
  334. //! <b>Effects</b>: Copy constructs a map using the specified allocator.
  335. //!
  336. //! <b>Complexity</b>: Linear in x.size().
  337. inline map(const map& x, const allocator_type &a)
  338. : base_t(static_cast<const base_t&>(x), a)
  339. {}
  340. //! <b>Effects</b>: Move constructs a map using the specified allocator.
  341. //! Constructs *this using x's resources.
  342. //!
  343. //! <b>Complexity</b>: Constant if x == x.get_allocator(), linear otherwise.
  344. //!
  345. //! <b>Postcondition</b>: x is emptied.
  346. inline map(BOOST_RV_REF(map) x, const allocator_type &a)
  347. : base_t(BOOST_MOVE_BASE(base_t, x), a)
  348. {}
  349. //! <b>Effects</b>: Makes *this a copy of x.
  350. //!
  351. //! <b>Complexity</b>: Linear in x.size().
  352. inline map& operator=(BOOST_COPY_ASSIGN_REF(map) x)
  353. { return static_cast<map&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
  354. //! <b>Effects</b>: this->swap(x.get()).
  355. //!
  356. //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
  357. //! is false and (allocation throws or value_type's move constructor throws)
  358. //!
  359. //! <b>Complexity</b>: Constant if allocator_traits_type::
  360. //! propagate_on_container_move_assignment is true or
  361. //! this->get>allocator() == x.get_allocator(). Linear otherwise.
  362. inline map& operator=(BOOST_RV_REF(map) x)
  363. BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
  364. allocator_traits_type::is_always_equal::value) &&
  365. boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
  366. { return static_cast<map&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
  367. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  368. //! <b>Effects</b>: Assign content of il to *this.
  369. //!
  370. inline map& operator=(std::initializer_list<value_type> il)
  371. {
  372. this->clear();
  373. insert(il.begin(), il.end());
  374. return *this;
  375. }
  376. #endif
  377. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  378. //! <b>Effects</b>: Returns a copy of the allocator that
  379. //! was passed to the object's constructor.
  380. //!
  381. //! <b>Complexity</b>: Constant.
  382. allocator_type get_allocator() const;
  383. //! <b>Effects</b>: Returns a reference to the internal allocator.
  384. //!
  385. //! <b>Throws</b>: Nothing
  386. //!
  387. //! <b>Complexity</b>: Constant.
  388. //!
  389. //! <b>Note</b>: Non-standard extension.
  390. stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW;
  391. //! <b>Effects</b>: Returns a reference to the internal allocator.
  392. //!
  393. //! <b>Throws</b>: Nothing
  394. //!
  395. //! <b>Complexity</b>: Constant.
  396. //!
  397. //! <b>Note</b>: Non-standard extension.
  398. const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
  399. //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
  400. //!
  401. //! <b>Throws</b>: Nothing.
  402. //!
  403. //! <b>Complexity</b>: Constant.
  404. iterator begin() BOOST_NOEXCEPT_OR_NOTHROW;
  405. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
  406. //!
  407. //! <b>Throws</b>: Nothing.
  408. //!
  409. //! <b>Complexity</b>: Constant.
  410. const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW;
  411. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
  412. //!
  413. //! <b>Throws</b>: Nothing.
  414. //!
  415. //! <b>Complexity</b>: Constant.
  416. const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  417. //! <b>Effects</b>: Returns an iterator to the end of the container.
  418. //!
  419. //! <b>Throws</b>: Nothing.
  420. //!
  421. //! <b>Complexity</b>: Constant.
  422. iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
  423. //! <b>Effects</b>: Returns a const_iterator to the end of the container.
  424. //!
  425. //! <b>Throws</b>: Nothing.
  426. //!
  427. //! <b>Complexity</b>: Constant.
  428. const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
  429. //! <b>Effects</b>: Returns a const_iterator to the end of the container.
  430. //!
  431. //! <b>Throws</b>: Nothing.
  432. //!
  433. //! <b>Complexity</b>: Constant.
  434. const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
  435. //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
  436. //! of the reversed container.
  437. //!
  438. //! <b>Throws</b>: Nothing.
  439. //!
  440. //! <b>Complexity</b>: Constant.
  441. reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
  442. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  443. //! of the reversed container.
  444. //!
  445. //! <b>Throws</b>: Nothing.
  446. //!
  447. //! <b>Complexity</b>: Constant.
  448. const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  449. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  450. //! of the reversed container.
  451. //!
  452. //! <b>Throws</b>: Nothing.
  453. //!
  454. //! <b>Complexity</b>: Constant.
  455. const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  456. //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
  457. //! of the reversed container.
  458. //!
  459. //! <b>Throws</b>: Nothing.
  460. //!
  461. //! <b>Complexity</b>: Constant.
  462. reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
  463. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
  464. //! of the reversed container.
  465. //!
  466. //! <b>Throws</b>: Nothing.
  467. //!
  468. //! <b>Complexity</b>: Constant.
  469. const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
  470. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
  471. //! of the reversed container.
  472. //!
  473. //! <b>Throws</b>: Nothing.
  474. //!
  475. //! <b>Complexity</b>: Constant.
  476. const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
  477. //! <b>Effects</b>: Returns true if the container contains no elements.
  478. //!
  479. //! <b>Throws</b>: Nothing.
  480. //!
  481. //! <b>Complexity</b>: Constant.
  482. bool empty() const BOOST_NOEXCEPT_OR_NOTHROW;
  483. //! <b>Effects</b>: Returns the number of the elements contained in the container.
  484. //!
  485. //! <b>Throws</b>: Nothing.
  486. //!
  487. //! <b>Complexity</b>: Constant.
  488. size_type size() const BOOST_NOEXCEPT_OR_NOTHROW;
  489. //! <b>Effects</b>: Returns the largest possible size of the container.
  490. //!
  491. //! <b>Throws</b>: Nothing.
  492. //!
  493. //! <b>Complexity</b>: Constant.
  494. size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW;
  495. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  496. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  497. //! <b>Effects</b>: If there is no key equivalent to x in the map, inserts
  498. //! value_type(x, T()) into the map.
  499. //!
  500. //! <b>Returns</b>: A reference to the mapped_type corresponding to x in *this.
  501. //!
  502. //! <b>Complexity</b>: Logarithmic.
  503. mapped_type& operator[](const key_type &k);
  504. //! <b>Effects</b>: If there is no key equivalent to x in the map, inserts
  505. //! value_type(boost::move(x), T()) into the map (the key is move-constructed)
  506. //!
  507. //! <b>Returns</b>: A reference to the mapped_type corresponding to x in *this.
  508. //!
  509. //! <b>Complexity</b>: Logarithmic.
  510. mapped_type& operator[](key_type &&k);
  511. #elif defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN)
  512. //in compilers like GCC 3.4, we can't catch temporaries
  513. inline mapped_type& operator[](const key_type &k) { return this->priv_subscript(k); }
  514. inline mapped_type& operator[](BOOST_RV_REF(key_type) k) { return this->priv_subscript(::boost::move(k)); }
  515. #else
  516. BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript)
  517. #endif
  518. //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj)
  519. //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value
  520. //! as if by insert, constructing it from value_type(k, forward<M>(obj)).
  521. //!
  522. //! No iterators or references are invalidated. If the insertion is successful, pointers and references
  523. //! to the element obtained while it is held in the node handle are invalidated, and pointers and
  524. //! references obtained to that element before it was extracted become valid.
  525. //!
  526. //! <b>Returns</b>: The bool component is true if the insertion took place and false if the assignment
  527. //! took place. The iterator component is pointing at the element that was inserted or updated.
  528. //!
  529. //! <b>Complexity</b>: Logarithmic in the size of the container.
  530. template <class M>
  531. inline std::pair<iterator, bool> insert_or_assign(const key_type& k, BOOST_FWD_REF(M) obj)
  532. { return this->base_t::insert_or_assign(const_iterator(), k, ::boost::forward<M>(obj)); }
  533. //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj)
  534. //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value
  535. //! as if by insert, constructing it from value_type(k, move(obj)).
  536. //!
  537. //! No iterators or references are invalidated. If the insertion is successful, pointers and references
  538. //! to the element obtained while it is held in the node handle are invalidated, and pointers and
  539. //! references obtained to that element before it was extracted become valid.
  540. //!
  541. //! <b>Returns</b>: The bool component is true if the insertion took place and false if the assignment
  542. //! took place. The iterator component is pointing at the element that was inserted or updated.
  543. //!
  544. //! <b>Complexity</b>: Logarithmic in the size of the container.
  545. template <class M>
  546. inline std::pair<iterator, bool> insert_or_assign(BOOST_RV_REF(key_type) k, BOOST_FWD_REF(M) obj)
  547. { return this->base_t::insert_or_assign(const_iterator(), ::boost::move(k), ::boost::forward<M>(obj)); }
  548. //! <b>Requires</b>: This overload is available only if key_compare::is_transparent exists.
  549. //!
  550. //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj)
  551. //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value
  552. //! as if by insert, constructing it from value_type(k, move(obj)).
  553. //!
  554. //! No iterators or references are invalidated. If the insertion is successful, pointers and references
  555. //! to the element obtained while it is held in the node handle are invalidated, and pointers and
  556. //! references obtained to that element before it was extracted become valid.
  557. //!
  558. //! <b>Returns</b>: The bool component is true if the insertion took place and false if the assignment
  559. //! took place. The iterator component is pointing at the element that was inserted or updated.
  560. //!
  561. //! <b>Complexity</b>: Logarithmic in the size of the container.
  562. template <class K, class M>
  563. BOOST_CONTAINER_DOC1ST
  564. ( std::pair<iterator BOOST_MOVE_I bool>
  565. , typename dtl::enable_if_transparent< key_compare
  566. BOOST_MOVE_I K
  567. BOOST_MOVE_I std::pair<iterator BOOST_MOVE_I bool>
  568. >::type) //transparent
  569. insert_or_assign(BOOST_FWD_REF(K) k, BOOST_FWD_REF(M) obj)
  570. { return this->base_t::insert_or_assign(const_iterator(), ::boost::forward<K>(k), ::boost::forward<M>(obj)); }
  571. //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj)
  572. //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value
  573. //! as if by insert, constructing it from value_type(k, forward<M>(obj)) and the new element
  574. //! to the container as close as possible to the position just before hint.
  575. //!
  576. //! No iterators or references are invalidated. If the insertion is successful, pointers and references
  577. //! to the element obtained while it is held in the node handle are invalidated, and pointers and
  578. //! references obtained to that element before it was extracted become valid.
  579. //!
  580. //! <b>Returns</b>: The returned iterator points to the map element whose key is equivalent to k.
  581. //!
  582. //! <b>Complexity</b>: Logarithmic in the size of the container in general, but amortized constant if
  583. //! the new element is inserted just before hint.
  584. template <class M>
  585. inline iterator insert_or_assign(const_iterator hint, const key_type& k, BOOST_FWD_REF(M) obj)
  586. { return this->base_t::insert_or_assign(hint, k, ::boost::forward<M>(obj)).first; }
  587. //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj)
  588. //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value
  589. //! as if by insert, constructing it from value_type(k, move(obj)) and the new element
  590. //! to the container as close as possible to the position just before hint.
  591. //!
  592. //! No iterators or references are invalidated. If the insertion is successful, pointers and references
  593. //! to the element obtained while it is held in the node handle are invalidated, and pointers and
  594. //! references obtained to that element before it was extracted become valid.
  595. //!
  596. //! <b>Returns</b>: The returned iterator points to the map element whose key is equivalent to k.
  597. //!
  598. //! <b>Complexity</b>: Logarithmic in the size of the container in general, but amortized constant if
  599. //! the new element is inserted just before hint.
  600. template <class M>
  601. inline iterator insert_or_assign(const_iterator hint, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(M) obj)
  602. { return this->base_t::insert_or_assign(hint, ::boost::move(k), ::boost::forward<M>(obj)).first; }
  603. //! <b>Requires</b>: This overload is available only if key_compare::is_transparent exists.
  604. //!
  605. //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj)
  606. //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value
  607. //! as if by insert, constructing it from value_type(k, move(obj)) and the new element
  608. //! to the container as close as possible to the position just before hint.
  609. //!
  610. //! No iterators or references are invalidated. If the insertion is successful, pointers and references
  611. //! to the element obtained while it is held in the node handle are invalidated, and pointers and
  612. //! references obtained to that element before it was extracted become valid.
  613. //!
  614. //! <b>Returns</b>: The returned iterator points to the map element whose key is equivalent to k.
  615. //!
  616. //! <b>Complexity</b>: Logarithmic in the size of the container in general, but amortized constant if
  617. //! the new element is inserted just before hint.
  618. template <class K, class M>
  619. BOOST_CONTAINER_DOC1ST
  620. ( iterator
  621. , typename dtl::enable_if_transparent< key_compare
  622. BOOST_MOVE_I K
  623. BOOST_MOVE_I iterator
  624. >::type) //transparent
  625. insert_or_assign(const_iterator hint, BOOST_FWD_REF(K) k, BOOST_FWD_REF(M) obj)
  626. { return this->base_t::insert_or_assign(hint, ::boost::forward<K>(k), ::boost::forward<M>(obj)).first; }
  627. //! <b>Returns</b>: A reference to the element whose key is equivalent to x.
  628. //! Throws: An exception object of type out_of_range if no such element is present.
  629. //! <b>Complexity</b>: logarithmic.
  630. T& at(const key_type& k)
  631. {
  632. iterator i = this->find(k);
  633. if(i == this->end()){
  634. throw_out_of_range("map::at key not found");
  635. }
  636. return i->second;
  637. }
  638. //! <b>Returns</b>: A reference to the element whose key is equivalent to x.
  639. //! Throws: An exception object of type out_of_range if no such element is present.
  640. //! <b>Complexity</b>: logarithmic.
  641. BOOST_CONTAINER_ATTRIBUTE_NODISCARD const T& at(const key_type& k) const
  642. {
  643. const_iterator i = this->find(k);
  644. if(i == this->end()){
  645. throw_out_of_range("map::at key not found");
  646. }
  647. return i->second;
  648. }
  649. //////////////////////////////////////////////
  650. //
  651. // modifiers
  652. //
  653. //////////////////////////////////////////////
  654. //! <b>Effects</b>: Inserts x if and only if there is no element in the container
  655. //! with key equivalent to the key of x.
  656. //!
  657. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  658. //! if the insertion takes place, and the iterator component of the pair
  659. //! points to the element with key equivalent to the key of x.
  660. //!
  661. //! <b>Complexity</b>: Logarithmic.
  662. inline std::pair<iterator,bool> insert(const value_type& x)
  663. { return this->base_t::insert_unique_convertible(x); }
  664. //! <b>Effects</b>: Move constructs a new value from x if and only if there is
  665. //! no element in the container with key equivalent to the key of x.
  666. //!
  667. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  668. //! if the insertion takes place, and the iterator component of the pair
  669. //! points to the element with key equivalent to the key of x.
  670. //!
  671. //! <b>Complexity</b>: Logarithmic.
  672. inline std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)
  673. { return this->base_t::insert_unique_convertible(boost::move(x)); }
  674. //! <b>Effects</b>: Inserts a new value_type created from the pair if and only if
  675. //! there is no element in the container with key equivalent to the key of x.
  676. //!
  677. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  678. //! if the insertion takes place, and the iterator component of the pair
  679. //! points to the element with key equivalent to the key of x.
  680. //!
  681. //! <b>Complexity</b>: Logarithmic.
  682. template <class Pair>
  683. inline BOOST_CONTAINER_DOC1ST
  684. ( std::pair<iterator BOOST_MOVE_I bool>
  685. , typename dtl::enable_if_c<
  686. dtl::is_convertible<Pair BOOST_MOVE_I value_type>::value ||
  687. dtl::is_convertible<Pair BOOST_MOVE_I movable_value_type>::value
  688. BOOST_MOVE_I std::pair<iterator BOOST_MOVE_I bool> >::type)
  689. insert(BOOST_FWD_REF(Pair) x)
  690. { return this->base_t::emplace_unique(boost::forward<Pair>(x)); }
  691. inline iterator insert(const_iterator p, const value_type& x)
  692. { return this->base_t::insert_unique_hint_convertible(p, x); }
  693. //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
  694. //! no element in the container with key equivalent to the key of x.
  695. //! p is a hint pointing to where the insert should start to search.
  696. //!
  697. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  698. //! to the key of x.
  699. //!
  700. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  701. //! is inserted right before p.
  702. inline iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
  703. { return this->base_t::insert_unique_hint_convertible(p, boost::move(x)); }
  704. //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
  705. //! no element in the container with key equivalent to the key of x.
  706. //! p is a hint pointing to where the insert should start to search.
  707. //!
  708. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  709. //! to the key of x.
  710. //!
  711. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  712. //! is inserted right before p.
  713. template <class Pair>
  714. inline BOOST_CONTAINER_DOC1ST
  715. ( iterator
  716. , typename dtl::enable_if_c<
  717. dtl::is_convertible<Pair BOOST_MOVE_I value_type>::value ||
  718. dtl::is_convertible<Pair BOOST_MOVE_I movable_value_type>::value
  719. BOOST_MOVE_I iterator >::type)
  720. insert(const_iterator p, BOOST_FWD_REF(Pair) x)
  721. { return this->base_t::emplace_hint_unique(p, boost::forward<Pair>(x)); }
  722. /*
  723. //! <b>Effects</b>: Move constructs a new value from x if and only if there is
  724. //! no element in the container with key equivalent to the key of x.
  725. //! p is a hint pointing to where the insert should start to search.
  726. //!
  727. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  728. //! to the key of x.
  729. //!
  730. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  731. //! is inserted right before p.
  732. inline iterator insert(const_iterator p, BOOST_RV_REF(nonconst_value_type) x)
  733. { return this->try_emplace(p, boost::move(x.first), boost::move(x.second)); }
  734. //! <b>Effects</b>: Move constructs a new value from x if and only if there is
  735. //! no element in the container with key equivalent to the key of x.
  736. //! p is a hint pointing to where the insert should start to search.
  737. //!
  738. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  739. //! to the key of x.
  740. //!
  741. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  742. //! is inserted right before p.
  743. inline iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x)
  744. { return this->try_emplace(p, boost::move(x.first), boost::move(x.second)); }
  745. //! <b>Effects</b>: Inserts a copy of x in the container.
  746. //! p is a hint pointing to where the insert should start to search.
  747. //!
  748. //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
  749. //!
  750. //! <b>Complexity</b>: Logarithmic.
  751. inline iterator insert(const_iterator p, const nonconst_value_type& x)
  752. { return this->try_emplace(p, x.first, x.second); }
  753. */
  754. //! <b>Requires</b>: first, last are not iterators into *this.
  755. //!
  756. //! <b>Effects</b>: inserts each element from the range [first,last) if and only
  757. //! if there is no element with key equivalent to the key of that element.
  758. //!
  759. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
  760. template <class InputIterator>
  761. inline void insert(InputIterator first, InputIterator last)
  762. { this->base_t::insert_unique_range(first, last); }
  763. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  764. //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end()) if and only
  765. //! if there is no element with key equivalent to the key of that element.
  766. //!
  767. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end())
  768. inline void insert(std::initializer_list<value_type> il)
  769. { this->base_t::insert_unique_range(il.begin(), il.end()); }
  770. #endif
  771. //! <b>Requires</b>: nh is empty or this->get_allocator() == nh.get_allocator().
  772. //!
  773. //! <b>Effects</b>: If nh is empty, has no effect. Otherwise, inserts the element owned
  774. //! by nh if and only if there is no element in the container with a key equivalent to nh.key().
  775. //!
  776. //! <b>Returns</b>: If nh is empty, insert_return_type.inserted is false, insert_return_type.position
  777. //! is end(), and insert_return_type.node is empty. Otherwise if the insertion took place,
  778. //! insert_return_type.inserted is true, insert_return_type.position points to the inserted element,
  779. //! and insert_return_type.node is empty; if the insertion failed, insert_return_type.inserted is
  780. //! false, insert_return_type.node has the previous value of nh, and insert_return_type.position
  781. //! points to an element with a key equivalent to nh.key().
  782. //!
  783. //! <b>Complexity</b>: Logarithmic
  784. insert_return_type insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  785. {
  786. typename base_t::node_type n(boost::move(nh));
  787. typename base_t::insert_return_type base_ret(this->base_t::insert_unique_node(boost::move(n)));
  788. return insert_return_type (base_ret.inserted, base_ret.position, boost::move(base_ret.node));
  789. }
  790. //! <b>Effects</b>: Same as `insert(node_type && nh)` but the element is inserted as close as possible
  791. //! to the position just prior to "hint".
  792. //!
  793. //! <b>Complexity</b>: logarithmic in general, but amortized constant if the element is inserted
  794. //! right before "hint".
  795. insert_return_type insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  796. {
  797. typename base_t::node_type n(boost::move(nh));
  798. typename base_t::insert_return_type base_ret(this->base_t::insert_unique_node(hint, boost::move(n)));
  799. return insert_return_type (base_ret.inserted, base_ret.position, boost::move(base_ret.node));
  800. }
  801. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  802. //! <b>Effects</b>: Inserts an object x of type T constructed with
  803. //! std::forward<Args>(args)... in the container if and only if there is
  804. //! no element in the container with an equivalent key.
  805. //! p is a hint pointing to where the insert should start to search.
  806. //!
  807. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  808. //! if the insertion takes place, and the iterator component of the pair
  809. //! points to the element with key equivalent to the key of x.
  810. //!
  811. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  812. //! is inserted right before p.
  813. template <class... Args>
  814. inline std::pair<iterator,bool> emplace(BOOST_FWD_REF(Args)... args)
  815. { return this->base_t::emplace_unique(boost::forward<Args>(args)...); }
  816. //! <b>Effects</b>: Inserts an object of type T constructed with
  817. //! std::forward<Args>(args)... in the container if and only if there is
  818. //! no element in the container with an equivalent key.
  819. //! p is a hint pointing to where the insert should start to search.
  820. //!
  821. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  822. //! to the key of x.
  823. //!
  824. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  825. //! is inserted right before p.
  826. template <class... Args>
  827. inline iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
  828. { return this->base_t::emplace_hint_unique(p, boost::forward<Args>(args)...); }
  829. //! <b>Requires</b>: value_type shall be EmplaceConstructible into map from piecewise_construct,
  830. //! forward_as_tuple(k), forward_as_tuple(forward<Args>(args)...).
  831. //!
  832. //! <b>Effects</b>: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise
  833. //! inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(k),
  834. //! forward_as_tuple(forward<Args>(args)...).
  835. //!
  836. //! <b>Returns</b>: The bool component of the returned pair is true if and only if the
  837. //! insertion took place. The returned iterator points to the map element whose key is equivalent to k.
  838. //!
  839. //! <b>Complexity</b>: Logarithmic.
  840. template <class... Args>
  841. inline std::pair<iterator, bool> try_emplace(const key_type& k, BOOST_FWD_REF(Args)... args)
  842. { return this->base_t::try_emplace(const_iterator(), k, boost::forward<Args>(args)...); }
  843. //! <b>Requires</b>: value_type shall be EmplaceConstructible into map from piecewise_construct,
  844. //! forward_as_tuple(k), forward_as_tuple(forward<Args>(args)...).
  845. //!
  846. //! <b>Effects</b>: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise
  847. //! inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(k),
  848. //! forward_as_tuple(forward<Args>(args)...).
  849. //!
  850. //! <b>Returns</b>: The returned iterator points to the map element whose key is equivalent to k.
  851. //!
  852. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if value
  853. //! is inserted right before p.
  854. template <class... Args>
  855. inline iterator try_emplace(const_iterator hint, const key_type &k, BOOST_FWD_REF(Args)... args)
  856. { return this->base_t::try_emplace(hint, k, boost::forward<Args>(args)...).first; }
  857. //! <b>Requires</b>: value_type shall be EmplaceConstructible into map from piecewise_construct,
  858. //! forward_as_tuple(move(k)), forward_as_tuple(forward<Args>(args)...).
  859. //!
  860. //! <b>Effects</b>: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise
  861. //! inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(move(k)),
  862. //! forward_as_tuple(forward<Args>(args)...).
  863. //!
  864. //! <b>Returns</b>: The bool component of the returned pair is true if and only if the
  865. //! insertion took place. The returned iterator points to the map element whose key is equivalent to k.
  866. //!
  867. //! <b>Complexity</b>: Logarithmic.
  868. template <class... Args>
  869. inline std::pair<iterator, bool> try_emplace(BOOST_RV_REF(key_type) k, BOOST_FWD_REF(Args)... args)
  870. { return this->base_t::try_emplace(const_iterator(), boost::move(k), boost::forward<Args>(args)...); }
  871. //! <b>Requires</b>: value_type shall be EmplaceConstructible into map from piecewise_construct,
  872. //! forward_as_tuple(move(k)), forward_as_tuple(forward<Args>(args)...).
  873. //!
  874. //! <b>Effects</b>: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise
  875. //! inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(move(k)),
  876. //! forward_as_tuple(forward<Args>(args)...).
  877. //!
  878. //! <b>Returns</b>: The returned iterator points to the map element whose key is equivalent to k.
  879. //!
  880. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if value
  881. //! is inserted right before p.
  882. template <class... Args>
  883. inline iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(Args)... args)
  884. { return this->base_t::try_emplace(hint, boost::move(k), boost::forward<Args>(args)...).first; }
  885. #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  886. #define BOOST_CONTAINER_MAP_EMPLACE_CODE(N) \
  887. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  888. inline std::pair<iterator,bool> emplace(BOOST_MOVE_UREF##N)\
  889. { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\
  890. \
  891. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  892. inline iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  893. { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  894. \
  895. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  896. inline std::pair<iterator, bool> try_emplace(const key_type& k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  897. { return this->base_t::try_emplace(const_iterator(), k BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  898. \
  899. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  900. inline iterator try_emplace(const_iterator hint, const key_type &k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  901. { return this->base_t::try_emplace(hint, k BOOST_MOVE_I##N BOOST_MOVE_FWD##N).first; }\
  902. \
  903. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  904. inline std::pair<iterator, bool> try_emplace(BOOST_RV_REF(key_type) k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  905. { return this->base_t::try_emplace(const_iterator(), boost::move(k) BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  906. \
  907. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  908. inline iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  909. { return this->base_t::try_emplace(hint, boost::move(k) BOOST_MOVE_I##N BOOST_MOVE_FWD##N).first; }\
  910. //
  911. BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MAP_EMPLACE_CODE)
  912. #undef BOOST_CONTAINER_MAP_EMPLACE_CODE
  913. #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  914. //! <b>Effects</b>: If present, erases the element in the container with key equivalent to x.
  915. //!
  916. //! <b>Returns</b>: Returns the number of erased elements (0/1).
  917. //!
  918. //! <b>Complexity</b>: log(size()) + count(k)
  919. inline size_type erase(const key_type& x)
  920. { return this->base_t::erase_unique(x); }
  921. //! <b>Requires</b>: This overload is available only if
  922. //! key_compare::is_transparent exists.
  923. //!
  924. //! <b>Effects</b>: If present, erases the element in the container with key equivalent to x.
  925. //!
  926. //! <b>Returns</b>: Returns the number of erased elements (0/1).
  927. template <class K>
  928. inline BOOST_CONTAINER_DOC1ST
  929. (size_type
  930. , typename dtl::enable_if_c<
  931. dtl::is_transparent<key_compare>::value && //transparent
  932. !dtl::is_convertible<K BOOST_MOVE_I iterator>::value && //not convertible to iterator
  933. !dtl::is_convertible<K BOOST_MOVE_I const_iterator>::value //not convertible to const_iterator
  934. BOOST_MOVE_I size_type>::type)
  935. erase(BOOST_FWD_REF(K) x)
  936. { return this->base_t::erase_unique(x); }
  937. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  938. //! <b>Effects</b>: Erases the element pointed to by p.
  939. //!
  940. //! <b>Returns</b>: Returns an iterator pointing to the element immediately
  941. //! following q prior to the element being erased. If no such element exists,
  942. //! returns end().
  943. //!
  944. //! <b>Complexity</b>: Amortized constant time
  945. iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW;
  946. //! <b>Effects</b>: Erases all the elements in the range [first, last).
  947. //!
  948. //! <b>Returns</b>: Returns last.
  949. //!
  950. //! <b>Complexity</b>: log(size())+N where N is the distance from first to last.
  951. iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW;
  952. #else
  953. using base_t::erase;
  954. #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  955. //! <b>Effects</b>: Removes the first element in the container with key equivalent to k.
  956. //!
  957. //! <b>Returns</b>: A node_type owning the element if found, otherwise an empty node_type.
  958. //!
  959. //! <b>Complexity</b>: log(size()).
  960. node_type extract(const key_type& k)
  961. {
  962. typename base_t::node_type base_nh(this->base_t::extract(k));
  963. node_type nh(boost::move(base_nh));
  964. return BOOST_MOVE_RET(node_type, nh);
  965. }
  966. //! <b>Effects</b>: Removes the element pointed to by "position".
  967. //!
  968. //! <b>Returns</b>: A node_type owning the element, otherwise an empty node_type.
  969. //!
  970. //! <b>Complexity</b>: Amortized constant.
  971. node_type extract(const_iterator position)
  972. {
  973. typename base_t::node_type base_nh(this->base_t::extract(position));
  974. node_type nh(boost::move(base_nh));
  975. return BOOST_MOVE_RET(node_type, nh);
  976. }
  977. //! <b>Requires</b>: this->get_allocator() == source.get_allocator().
  978. //!
  979. //! <b>Effects</b>: Attempts to extract each element in source and insert it into a using
  980. //! the comparison object of *this. If there is an element in a with key equivalent to the
  981. //! key of an element from source, then that element is not extracted from source.
  982. //!
  983. //! <b>Postcondition</b>: Pointers and references to the transferred elements of source refer
  984. //! to those same elements but as members of *this. Iterators referring to the transferred
  985. //! elements will continue to refer to their elements, but they now behave as iterators into *this,
  986. //! not into source.
  987. //!
  988. //! <b>Throws</b>: Nothing unless the comparison object throws.
  989. //!
  990. //! <b>Complexity</b>: N log(size() + N) (N has the value source.size())
  991. template<class C2>
  992. inline void merge(map<Key, T, C2, Allocator, Options>& source)
  993. {
  994. typedef dtl::tree
  995. <value_type_impl, select_1st_t, C2, Allocator, Options> base2_t;
  996. this->merge_unique(static_cast<base2_t&>(source));
  997. }
  998. //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&)
  999. template<class C2>
  1000. inline void merge(BOOST_RV_REF_BEG map<Key, T, C2, Allocator, Options> BOOST_RV_REF_END source)
  1001. { return this->merge(static_cast<map<Key, T, C2, Allocator, Options>&>(source)); }
  1002. //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&)
  1003. template<class C2>
  1004. inline void merge(multimap<Key, T, C2, Allocator, Options>& source)
  1005. {
  1006. typedef dtl::tree
  1007. <value_type_impl, select_1st_t, C2, Allocator, Options> base2_t;
  1008. this->base_t::merge_unique(static_cast<base2_t&>(source));
  1009. }
  1010. //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&)
  1011. template<class C2>
  1012. inline void merge(BOOST_RV_REF_BEG multimap<Key, T, C2, Allocator, Options> BOOST_RV_REF_END source)
  1013. { return this->merge(static_cast<multimap<Key, T, C2, Allocator, Options>&>(source)); }
  1014. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1015. //! <b>Effects</b>: Swaps the contents of *this and x.
  1016. //!
  1017. //! <b>Throws</b>: Nothing.
  1018. //!
  1019. //! <b>Complexity</b>: Constant.
  1020. void swap(map& x)
  1021. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1022. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1023. //! <b>Effects</b>: erase(begin(),end()).
  1024. //!
  1025. //! <b>Postcondition</b>: size() == 0.
  1026. //!
  1027. //! <b>Complexity</b>: linear in size().
  1028. void clear() BOOST_NOEXCEPT_OR_NOTHROW;
  1029. //! <b>Effects</b>: Returns the comparison object out
  1030. //! of which a was constructed.
  1031. //!
  1032. //! <b>Complexity</b>: Constant.
  1033. key_compare key_comp() const;
  1034. //! <b>Effects</b>: Returns an object of value_compare constructed out
  1035. //! of the comparison object.
  1036. //!
  1037. //! <b>Complexity</b>: Constant.
  1038. value_compare value_comp() const;
  1039. //! <b>Returns</b>: An iterator pointing to an element with the key
  1040. //! equivalent to x, or end() if such an element is not found.
  1041. //!
  1042. //! <b>Complexity</b>: Logarithmic.
  1043. iterator find(const key_type& x);
  1044. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  1045. //! equivalent to x, or end() if such an element is not found.
  1046. //!
  1047. //! <b>Complexity</b>: Logarithmic.
  1048. const_iterator find(const key_type& x) const;
  1049. //! <b>Requires</b>: This overload is available only if
  1050. //! key_compare::is_transparent exists.
  1051. //!
  1052. //! <b>Returns</b>: An iterator pointing to an element with the key
  1053. //! equivalent to x, or end() if such an element is not found.
  1054. //!
  1055. //! <b>Complexity</b>: Logarithmic.
  1056. template<typename K>
  1057. iterator find(const K& x);
  1058. //! <b>Requires</b>: This overload is available only if
  1059. //! key_compare::is_transparent exists.
  1060. //!
  1061. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  1062. //! equivalent to x, or end() if such an element is not found.
  1063. //!
  1064. //! <b>Complexity</b>: Logarithmic.
  1065. template<typename K>
  1066. const_iterator find(const K& x) const;
  1067. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1068. //! <b>Returns</b>: The number of elements with key equivalent to x.
  1069. //!
  1070. //! <b>Complexity</b>: log(size())+count(k)
  1071. BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
  1072. size_type count(const key_type& x) const
  1073. { return static_cast<size_type>(this->find(x) != this->cend()); }
  1074. //! <b>Requires</b>: This overload is available only if
  1075. //! key_compare::is_transparent exists.
  1076. //!
  1077. //! <b>Returns</b>: The number of elements with key equivalent to x.
  1078. //!
  1079. //! <b>Complexity</b>: log(size())+count(k)
  1080. template<typename K>
  1081. BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
  1082. size_type count(const K& x) const
  1083. { return static_cast<size_type>(this->find(x) != this->cend()); }
  1084. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1085. //! <b>Returns</b>: Returns true if there is an element with key
  1086. //! equivalent to key in the container, otherwise false.
  1087. //!
  1088. //! <b>Complexity</b>: log(size()).
  1089. bool contains(const key_type& x) const;
  1090. //! <b>Requires</b>: This overload is available only if
  1091. //! key_compare::is_transparent exists.
  1092. //!
  1093. //! <b>Returns</b>: Returns true if there is an element with key
  1094. //! equivalent to key in the container, otherwise false.
  1095. //!
  1096. //! <b>Complexity</b>: log(size()).
  1097. template<typename K>
  1098. bool contains(const K& x) const;
  1099. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  1100. //! than x, or end() if such an element is not found.
  1101. //!
  1102. //! <b>Complexity</b>: Logarithmic
  1103. iterator lower_bound(const key_type& x);
  1104. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  1105. //! less than x, or end() if such an element is not found.
  1106. //!
  1107. //! <b>Complexity</b>: Logarithmic
  1108. const_iterator lower_bound(const key_type& x) const;
  1109. //! <b>Requires</b>: This overload is available only if
  1110. //! key_compare::is_transparent exists.
  1111. //!
  1112. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  1113. //! than x, or end() if such an element is not found.
  1114. //!
  1115. //! <b>Complexity</b>: Logarithmic
  1116. template<typename K>
  1117. iterator lower_bound(const K& x);
  1118. //! <b>Requires</b>: This overload is available only if
  1119. //! key_compare::is_transparent exists.
  1120. //!
  1121. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  1122. //! less than x, or end() if such an element is not found.
  1123. //!
  1124. //! <b>Complexity</b>: Logarithmic
  1125. template<typename K>
  1126. const_iterator lower_bound(const K& x) const;
  1127. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  1128. //! than x, or end() if such an element is not found.
  1129. //!
  1130. //! <b>Complexity</b>: Logarithmic
  1131. iterator upper_bound(const key_type& x);
  1132. //! <b>Returns</b>: A const iterator pointing to the first element with key
  1133. //! greater than x, or end() if such an element is not found.
  1134. //!
  1135. //! <b>Complexity</b>: Logarithmic
  1136. const_iterator upper_bound(const key_type& x) const;
  1137. //! <b>Requires</b>: This overload is available only if
  1138. //! key_compare::is_transparent exists.
  1139. //!
  1140. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  1141. //! than x, or end() if such an element is not found.
  1142. //!
  1143. //! <b>Complexity</b>: Logarithmic
  1144. template<typename K>
  1145. iterator upper_bound(const K& x);
  1146. //! <b>Requires</b>: This overload is available only if
  1147. //! key_compare::is_transparent exists.
  1148. //!
  1149. //! <b>Returns</b>: A const iterator pointing to the first element with key
  1150. //! greater than x, or end() if such an element is not found.
  1151. //!
  1152. //! <b>Complexity</b>: Logarithmic
  1153. template<typename K>
  1154. const_iterator upper_bound(const K& x) const;
  1155. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  1156. //!
  1157. //! <b>Complexity</b>: Logarithmic
  1158. std::pair<iterator,iterator> equal_range(const key_type& x);
  1159. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  1160. //!
  1161. //! <b>Complexity</b>: Logarithmic
  1162. std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
  1163. //! <b>Requires</b>: This overload is available only if
  1164. //! key_compare::is_transparent exists.
  1165. //!
  1166. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  1167. //!
  1168. //! <b>Complexity</b>: Logarithmic
  1169. template<typename K>
  1170. std::pair<iterator,iterator> equal_range(const K& x);
  1171. //! <b>Requires</b>: This overload is available only if
  1172. //! key_compare::is_transparent exists.
  1173. //!
  1174. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  1175. //!
  1176. //! <b>Complexity</b>: Logarithmic
  1177. template<typename K>
  1178. std::pair<const_iterator,const_iterator> equal_range(const K& x) const;
  1179. //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees.
  1180. //!
  1181. //! <b>Complexity</b>: Linear
  1182. void rebalance();
  1183. //! <b>Effects</b>: Returns true if x and y are equal
  1184. //!
  1185. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1186. friend bool operator==(const map& x, const map& y);
  1187. //! <b>Effects</b>: Returns true if x and y are unequal
  1188. //!
  1189. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1190. friend bool operator!=(const map& x, const map& y);
  1191. //! <b>Effects</b>: Returns true if x is less than y
  1192. //!
  1193. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1194. friend bool operator<(const map& x, const map& y);
  1195. //! <b>Effects</b>: Returns true if x is greater than y
  1196. //!
  1197. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1198. friend bool operator>(const map& x, const map& y);
  1199. //! <b>Effects</b>: Returns true if x is equal or less than y
  1200. //!
  1201. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1202. friend bool operator<=(const map& x, const map& y);
  1203. //! <b>Effects</b>: Returns true if x is equal or greater than y
  1204. //!
  1205. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1206. friend bool operator>=(const map& x, const map& y);
  1207. //! <b>Effects</b>: x.swap(y)
  1208. //!
  1209. //! <b>Complexity</b>: Constant.
  1210. friend void swap(map& x, map& y)
  1211. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1212. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1213. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1214. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1215. private:
  1216. template<class KeyConvertible>
  1217. inline mapped_type& priv_subscript(BOOST_FWD_REF(KeyConvertible) k)
  1218. {
  1219. return this->try_emplace(boost::forward<KeyConvertible>(k)).first->second;
  1220. }
  1221. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1222. };
  1223. //! <b>Effects</b>: Erases all elements that satisfy the predicate pred from the container c.
  1224. //!
  1225. //! <b>Complexity</b>: Linear.
  1226. template <class K, class M, class C, class A, class O, class Pred>
  1227. inline typename map<K, M, C, A, O>::size_type erase_if(map<K, M, C, A, O>& c, Pred pred)
  1228. {
  1229. return container_erase_if(c, pred);
  1230. }
  1231. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  1232. template <typename InputIterator>
  1233. map(InputIterator, InputIterator) ->
  1234. map< it_based_non_const_first_type_t<InputIterator>
  1235. , it_based_second_type_t<InputIterator>>;
  1236. template < typename InputIterator, typename AllocatorOrCompare>
  1237. map(InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1238. map< it_based_non_const_first_type_t<InputIterator>
  1239. , it_based_second_type_t<InputIterator>
  1240. , typename dtl::if_c< // Compare
  1241. dtl::is_allocator<AllocatorOrCompare>::value
  1242. , std::less<it_based_non_const_first_type_t<InputIterator>>
  1243. , AllocatorOrCompare
  1244. >::type
  1245. , typename dtl::if_c< // Allocator
  1246. dtl::is_allocator<AllocatorOrCompare>::value
  1247. , AllocatorOrCompare
  1248. , new_allocator<std::pair<it_based_const_first_type_t<InputIterator>, it_based_second_type_t<InputIterator>>>
  1249. >::type
  1250. >;
  1251. template < typename InputIterator, typename Compare, typename Allocator
  1252. , typename = dtl::require_nonallocator_t<Compare>
  1253. , typename = dtl::require_allocator_t<Allocator>>
  1254. map(InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1255. map< it_based_non_const_first_type_t<InputIterator>
  1256. , it_based_second_type_t<InputIterator>
  1257. , Compare
  1258. , Allocator>;
  1259. template <typename InputIterator>
  1260. map(ordered_unique_range_t, InputIterator, InputIterator) ->
  1261. map< it_based_non_const_first_type_t<InputIterator>
  1262. , it_based_second_type_t<InputIterator>>;
  1263. template < typename InputIterator, typename AllocatorOrCompare>
  1264. map(ordered_unique_range_t, InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1265. map< it_based_non_const_first_type_t<InputIterator>
  1266. , it_based_second_type_t<InputIterator>
  1267. , typename dtl::if_c< // Compare
  1268. dtl::is_allocator<AllocatorOrCompare>::value
  1269. , std::less<it_based_non_const_first_type_t<InputIterator>>
  1270. , AllocatorOrCompare
  1271. >::type
  1272. , typename dtl::if_c< // Allocator
  1273. dtl::is_allocator<AllocatorOrCompare>::value
  1274. , AllocatorOrCompare
  1275. , new_allocator<std::pair<it_based_const_first_type_t<InputIterator>, it_based_second_type_t<InputIterator>>>
  1276. >::type
  1277. >;
  1278. template < typename InputIterator, typename Compare, typename Allocator
  1279. , typename = dtl::require_nonallocator_t<Compare>
  1280. , typename = dtl::require_allocator_t<Allocator>>
  1281. map(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1282. map< it_based_non_const_first_type_t<InputIterator>
  1283. , it_based_second_type_t<InputIterator>
  1284. , Compare
  1285. , Allocator>;
  1286. #endif
  1287. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1288. } //namespace container {
  1289. //!has_trivial_destructor_after_move<> == true_type
  1290. //!specialization for optimizations
  1291. template <class Key, class T, class Compare, class Allocator, class Options>
  1292. struct has_trivial_destructor_after_move<boost::container::map<Key, T, Compare, Allocator, Options> >
  1293. {
  1294. typedef ::boost::container::dtl::tree<std::pair<const Key, T>, int, Compare, Allocator, Options> tree;
  1295. BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
  1296. };
  1297. namespace container {
  1298. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1299. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  1300. //! A multimap is a kind of associative container that supports equivalent keys
  1301. //! (possibly containing multiple copies of the same key value) and provides for
  1302. //! fast retrieval of values of another type T based on the keys. The multimap class
  1303. //! supports bidirectional iterators.
  1304. //!
  1305. //! A multimap satisfies all of the requirements of a container and of a reversible
  1306. //! container and of an associative container. The <code>value_type</code> stored
  1307. //! by this container is the value_type is std::pair<const Key, T>.
  1308. //!
  1309. //! \tparam Key is the key_type of the map
  1310. //! \tparam Value is the <code>mapped_type</code>
  1311. //! \tparam Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
  1312. //! \tparam Allocator is the allocator to allocate the <code>value_type</code>s
  1313. //! (e.g. <i>allocator< std::pair<const Key, T> > </i>).
  1314. //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options.
  1315. template < class Key, class T, class Compare = std::less<Key>
  1316. , class Allocator = new_allocator< std::pair< const Key, T> >, class Options = tree_assoc_defaults>
  1317. #else
  1318. template <class Key, class T, class Compare, class Allocator, class Options>
  1319. #endif
  1320. class multimap
  1321. ///@cond
  1322. : public dtl::tree
  1323. < std::pair<const Key, T>
  1324. , int
  1325. , Compare, Allocator, Options>
  1326. ///@endcond
  1327. {
  1328. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1329. private:
  1330. BOOST_COPYABLE_AND_MOVABLE(multimap)
  1331. typedef int select_1st_t;
  1332. typedef std::pair<const Key, T> value_type_impl;
  1333. typedef dtl::tree
  1334. <value_type_impl, select_1st_t, Compare, Allocator, Options> base_t;
  1335. typedef dtl::pair <Key, T> movable_value_type_impl;
  1336. typedef typename base_t::value_compare value_compare_impl;
  1337. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1338. public:
  1339. //////////////////////////////////////////////
  1340. //
  1341. // types
  1342. //
  1343. //////////////////////////////////////////////
  1344. typedef Key key_type;
  1345. typedef T mapped_type;
  1346. typedef typename base_t::allocator_type allocator_type;
  1347. typedef ::boost::container::allocator_traits<allocator_type> allocator_traits_type;
  1348. typedef typename boost::container::allocator_traits<allocator_type>::value_type value_type;
  1349. typedef typename boost::container::allocator_traits<allocator_type>::pointer pointer;
  1350. typedef typename boost::container::allocator_traits<allocator_type>::const_pointer const_pointer;
  1351. typedef typename boost::container::allocator_traits<allocator_type>::reference reference;
  1352. typedef typename boost::container::allocator_traits<allocator_type>::const_reference const_reference;
  1353. typedef typename boost::container::allocator_traits<allocator_type>::size_type size_type;
  1354. typedef typename boost::container::allocator_traits<allocator_type>::difference_type difference_type;
  1355. typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
  1356. typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
  1357. typedef Compare key_compare;
  1358. typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
  1359. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
  1360. typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
  1361. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
  1362. //typedef std::pair<key_type, mapped_type> nonconst_value_type;
  1363. typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type;
  1364. typedef BOOST_CONTAINER_IMPDEF(node_handle<
  1365. typename base_t::stored_allocator_type
  1366. BOOST_MOVE_I pair_key_mapped_of_value
  1367. <key_type BOOST_MOVE_I mapped_type> >) node_type;
  1368. //allocator_type::value_type type must be std::pair<CONST Key, T>
  1369. BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<typename allocator_type::value_type, std::pair<const Key, T> >::value));
  1370. //////////////////////////////////////////////
  1371. //
  1372. // construct/copy/destroy
  1373. //
  1374. //////////////////////////////////////////////
  1375. //! <b>Effects</b>: Default constructs an empty multimap.
  1376. //!
  1377. //! <b>Complexity</b>: Constant.
  1378. inline multimap()
  1379. BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<allocator_type>::value &&
  1380. dtl::is_nothrow_default_constructible<Compare>::value)
  1381. : base_t()
  1382. {}
  1383. //! <b>Effects</b>: Constructs an empty multimap using the specified allocator
  1384. //! object and allocator.
  1385. //!
  1386. //! <b>Complexity</b>: Constant.
  1387. inline explicit multimap(const allocator_type& a)
  1388. : base_t(a)
  1389. {}
  1390. //! <b>Effects</b>: Constructs an empty multimap using the specified comparison.
  1391. //!
  1392. //! <b>Complexity</b>: Constant.
  1393. inline explicit multimap(const Compare& comp)
  1394. : base_t(comp)
  1395. {}
  1396. //! <b>Effects</b>: Constructs an empty multimap using the specified comparison and allocator.
  1397. //!
  1398. //! <b>Complexity</b>: Constant.
  1399. inline multimap(const Compare& comp, const allocator_type& a)
  1400. : base_t(comp, a)
  1401. {}
  1402. //! <b>Effects</b>: Constructs an empty multimap and
  1403. //! inserts elements from the range [first ,last ).
  1404. //!
  1405. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  1406. //! the predicate and otherwise N logN, where N is last - first.
  1407. template <class InputIterator>
  1408. inline multimap(InputIterator first, InputIterator last)
  1409. : base_t(false, first, last)
  1410. {}
  1411. //! <b>Effects</b>: Constructs an empty multimap using the specified
  1412. //! allocator, and inserts elements from the range [first ,last ).
  1413. //!
  1414. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  1415. //! the predicate and otherwise N logN, where N is last - first.
  1416. template <class InputIterator>
  1417. inline multimap(InputIterator first, InputIterator last, const allocator_type& a)
  1418. : base_t(false, first, last, Compare(), a)
  1419. {}
  1420. //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
  1421. //! inserts elements from the range [first ,last ).
  1422. //!
  1423. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  1424. //! the predicate and otherwise N logN, where N is last - first.
  1425. template <class InputIterator>
  1426. inline multimap(InputIterator first, InputIterator last, const Compare& comp)
  1427. : base_t(false, first, last, comp)
  1428. {}
  1429. //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object
  1430. //! and allocator, and inserts elements from the range [first ,last ).
  1431. //!
  1432. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  1433. //! the predicate and otherwise N logN, where N is last - first.
  1434. template <class InputIterator>
  1435. inline multimap(InputIterator first, InputIterator last,
  1436. const Compare& comp, const allocator_type& a)
  1437. : base_t(false, first, last, comp, a)
  1438. {}
  1439. //! <b>Effects</b>: Constructs an empty multimap and
  1440. //! inserts elements from the ordered range [first ,last). This function
  1441. //! is more efficient than the normal range creation for ordered ranges.
  1442. //!
  1443. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1444. //!
  1445. //! <b>Complexity</b>: Linear in N.
  1446. //!
  1447. //! <b>Note</b>: Non-standard extension.
  1448. template <class InputIterator>
  1449. inline multimap(ordered_range_t, InputIterator first, InputIterator last)
  1450. : base_t(ordered_range, first, last)
  1451. {}
  1452. //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
  1453. //! inserts elements from the ordered range [first ,last). This function
  1454. //! is more efficient than the normal range creation for ordered ranges.
  1455. //!
  1456. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1457. //!
  1458. //! <b>Complexity</b>: Linear in N.
  1459. //!
  1460. //! <b>Note</b>: Non-standard extension.
  1461. template <class InputIterator>
  1462. inline multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp)
  1463. : base_t(ordered_range, first, last, comp)
  1464. {}
  1465. //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
  1466. //! allocator, and inserts elements from the ordered range [first ,last). This function
  1467. //! is more efficient than the normal range creation for ordered ranges.
  1468. //!
  1469. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1470. //!
  1471. //! <b>Complexity</b>: Linear in N.
  1472. //!
  1473. //! <b>Note</b>: Non-standard extension.
  1474. template <class InputIterator>
  1475. inline multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp,
  1476. const allocator_type& a)
  1477. : base_t(ordered_range, first, last, comp, a)
  1478. {}
  1479. //! <b>Effects</b>: Constructs an empty multimap using the specified allocator and
  1480. //! inserts elements from the ordered range [first ,last). This function
  1481. //! is more efficient than the normal range creation for ordered ranges.
  1482. //!
  1483. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1484. //!
  1485. //! <b>Complexity</b>: Linear in N.
  1486. //!
  1487. //! <b>Note</b>: Non-standard extension.
  1488. template <class InputIterator>
  1489. inline multimap(ordered_range_t, InputIterator first, InputIterator last, const allocator_type& a)
  1490. : base_t(ordered_range, first, last, Compare(), a)
  1491. {}
  1492. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1493. //! <b>Effects</b>: Constructs an empty multimap and
  1494. //! and inserts elements from the range [il.begin(), il.end()).
  1495. //!
  1496. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  1497. //! the predicate and otherwise N logN, where N is il.first() - il.end().
  1498. inline multimap(std::initializer_list<value_type> il)
  1499. : base_t(false, il.begin(), il.end())
  1500. {}
  1501. //! <b>Effects</b>: Constructs an empty multimap using the specified
  1502. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  1503. //!
  1504. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  1505. //! the predicate and otherwise N logN, where N is il.first() - il.end().
  1506. inline multimap(std::initializer_list<value_type> il, const allocator_type& a)
  1507. : base_t(false, il.begin(), il.end(), Compare(), a)
  1508. {}
  1509. //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
  1510. //! inserts elements from the range [il.begin(), il.end()).
  1511. //!
  1512. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  1513. //! the predicate and otherwise N logN, where N is il.first() - il.end().
  1514. inline multimap(std::initializer_list<value_type> il, const Compare& comp)
  1515. : base_t(false, il.begin(), il.end(), comp)
  1516. {}
  1517. //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
  1518. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  1519. //!
  1520. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  1521. //! the predicate and otherwise N logN, where N is il.first() - il.end().
  1522. inline multimap(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  1523. : base_t(false, il.begin(), il.end(), comp, a)
  1524. {}
  1525. //! <b>Effects</b>: Constructs an empty map and
  1526. //! inserts elements from the ordered range [il.begin(), il.end()). This function
  1527. //! is more efficient than the normal range creation for ordered ranges.
  1528. //!
  1529. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
  1530. //!
  1531. //! <b>Complexity</b>: Linear in N.
  1532. //!
  1533. //! <b>Note</b>: Non-standard extension.
  1534. inline multimap(ordered_range_t, std::initializer_list<value_type> il)
  1535. : base_t(ordered_range, il.begin(), il.end())
  1536. {}
  1537. //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
  1538. //! inserts elements from the ordered range [il.begin(), il.end()). This function
  1539. //! is more efficient than the normal range creation for ordered ranges.
  1540. //!
  1541. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
  1542. //!
  1543. //! <b>Complexity</b>: Linear in N.
  1544. //!
  1545. //! <b>Note</b>: Non-standard extension.
  1546. inline multimap(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp)
  1547. : base_t(ordered_range, il.begin(), il.end(), comp)
  1548. {}
  1549. //! <b>Effects</b>: Constructs an empty map and
  1550. //! inserts elements from the ordered range [il.begin(), il.end()). This function
  1551. //! is more efficient than the normal range creation for ordered ranges.
  1552. //!
  1553. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
  1554. //!
  1555. //! <b>Complexity</b>: Linear in N.
  1556. //!
  1557. //! <b>Note</b>: Non-standard extension.
  1558. inline multimap(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  1559. : base_t(ordered_range, il.begin(), il.end(), comp, a)
  1560. {}
  1561. #endif
  1562. //! <b>Effects</b>: Copy constructs a multimap.
  1563. //!
  1564. //! <b>Complexity</b>: Linear in x.size().
  1565. inline multimap(const multimap& x)
  1566. : base_t(static_cast<const base_t&>(x))
  1567. {}
  1568. //! <b>Effects</b>: Move constructs a multimap. Constructs *this using x's resources.
  1569. //!
  1570. //! <b>Complexity</b>: Constant.
  1571. //!
  1572. //! <b>Postcondition</b>: x is emptied.
  1573. inline multimap(BOOST_RV_REF(multimap) x)
  1574. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value)
  1575. : base_t(BOOST_MOVE_BASE(base_t, x))
  1576. {}
  1577. //! <b>Effects</b>: Copy constructs a multimap.
  1578. //!
  1579. //! <b>Complexity</b>: Linear in x.size().
  1580. inline multimap(const multimap& x, const allocator_type &a)
  1581. : base_t(static_cast<const base_t&>(x), a)
  1582. {}
  1583. //! <b>Effects</b>: Move constructs a multimap using the specified allocator.
  1584. //! Constructs *this using x's resources.
  1585. //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
  1586. //!
  1587. //! <b>Postcondition</b>: x is emptied.
  1588. inline multimap(BOOST_RV_REF(multimap) x, const allocator_type &a)
  1589. : base_t(BOOST_MOVE_BASE(base_t, x), a)
  1590. {}
  1591. //! <b>Effects</b>: Makes *this a copy of x.
  1592. //!
  1593. //! <b>Complexity</b>: Linear in x.size().
  1594. inline multimap& operator=(BOOST_COPY_ASSIGN_REF(multimap) x)
  1595. { return static_cast<multimap&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
  1596. //! <b>Effects</b>: this->swap(x.get()).
  1597. //!
  1598. //! <b>Complexity</b>: Constant.
  1599. inline multimap& operator=(BOOST_RV_REF(multimap) x)
  1600. BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
  1601. allocator_traits_type::is_always_equal::value) &&
  1602. boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
  1603. { return static_cast<multimap&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
  1604. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1605. //! <b>Effects</b>: Assign content of il to *this.
  1606. //!
  1607. inline multimap& operator=(std::initializer_list<value_type> il)
  1608. {
  1609. this->clear();
  1610. insert(il.begin(), il.end());
  1611. return *this;
  1612. }
  1613. #endif
  1614. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1615. //! @copydoc ::boost::container::set::get_allocator()
  1616. allocator_type get_allocator() const;
  1617. //! @copydoc ::boost::container::set::get_stored_allocator()
  1618. stored_allocator_type &get_stored_allocator();
  1619. //! @copydoc ::boost::container::set::get_stored_allocator() const
  1620. const stored_allocator_type &get_stored_allocator() const;
  1621. //! @copydoc ::boost::container::set::begin()
  1622. iterator begin();
  1623. //! @copydoc ::boost::container::set::begin() const
  1624. const_iterator begin() const;
  1625. //! @copydoc ::boost::container::set::cbegin() const
  1626. const_iterator cbegin() const;
  1627. //! @copydoc ::boost::container::set::end()
  1628. iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
  1629. //! @copydoc ::boost::container::set::end() const
  1630. const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
  1631. //! @copydoc ::boost::container::set::cend() const
  1632. const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1633. //! @copydoc ::boost::container::set::rbegin()
  1634. reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
  1635. //! @copydoc ::boost::container::set::rbegin() const
  1636. const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  1637. //! @copydoc ::boost::container::set::crbegin() const
  1638. const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  1639. //! @copydoc ::boost::container::set::rend()
  1640. reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
  1641. //! @copydoc ::boost::container::set::rend() const
  1642. const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1643. //! @copydoc ::boost::container::set::crend() const
  1644. const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1645. //! @copydoc ::boost::container::set::empty() const
  1646. bool empty() const;
  1647. //! @copydoc ::boost::container::set::size() const
  1648. size_type size() const;
  1649. //! @copydoc ::boost::container::set::max_size() const
  1650. size_type max_size() const;
  1651. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1652. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1653. //! <b>Effects</b>: Inserts an object of type T constructed with
  1654. //! std::forward<Args>(args)... in the container.
  1655. //! p is a hint pointing to where the insert should start to search.
  1656. //!
  1657. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1658. //! to the key of x.
  1659. //!
  1660. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1661. //! is inserted right before p.
  1662. template <class... Args>
  1663. inline iterator emplace(BOOST_FWD_REF(Args)... args)
  1664. { return this->base_t::emplace_equal(boost::forward<Args>(args)...); }
  1665. //! <b>Effects</b>: Inserts an object of type T constructed with
  1666. //! std::forward<Args>(args)... in the container.
  1667. //! p is a hint pointing to where the insert should start to search.
  1668. //!
  1669. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1670. //! to the key of x.
  1671. //!
  1672. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1673. //! is inserted right before p.
  1674. template <class... Args>
  1675. inline iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
  1676. { return this->base_t::emplace_hint_equal(p, boost::forward<Args>(args)...); }
  1677. #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  1678. #define BOOST_CONTAINER_MULTIMAP_EMPLACE_CODE(N) \
  1679. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  1680. inline iterator emplace(BOOST_MOVE_UREF##N)\
  1681. { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\
  1682. \
  1683. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  1684. inline iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  1685. { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  1686. //
  1687. BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MULTIMAP_EMPLACE_CODE)
  1688. #undef BOOST_CONTAINER_MULTIMAP_EMPLACE_CODE
  1689. #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  1690. //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
  1691. //! newly inserted element.
  1692. //!
  1693. //! <b>Complexity</b>: Logarithmic.
  1694. inline iterator insert(const value_type& x)
  1695. { return this->base_t::insert_equal_convertible(x); }
  1696. //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
  1697. //! the iterator pointing to the newly inserted element.
  1698. //!
  1699. //! <b>Complexity</b>: Logarithmic.
  1700. inline iterator insert(BOOST_RV_REF(value_type) x)
  1701. { return this->base_t::insert_equal_convertible(boost::move(x)); }
  1702. //! <b>Effects</b>: Inserts a new value constructed from x and returns
  1703. //! the iterator pointing to the newly inserted element.
  1704. //!
  1705. //! <b>Complexity</b>: Logarithmic.
  1706. template<class Pair>
  1707. inline BOOST_CONTAINER_DOC1ST
  1708. ( iterator
  1709. , typename dtl::enable_if_c<
  1710. dtl::is_convertible<Pair BOOST_MOVE_I value_type>::value ||
  1711. dtl::is_convertible<Pair BOOST_MOVE_I movable_value_type>::value
  1712. BOOST_MOVE_I iterator >::type)
  1713. insert(BOOST_FWD_REF(Pair) x)
  1714. { return this->base_t::emplace_equal(boost::forward<Pair>(x)); }
  1715. //! <b>Effects</b>: Inserts a copy of x in the container.
  1716. //! p is a hint pointing to where the insert should start to search.
  1717. //!
  1718. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1719. //! to the key of x.
  1720. //!
  1721. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1722. //! is inserted right before p.
  1723. inline iterator insert(const_iterator p, const value_type& x)
  1724. { return this->base_t::insert_equal_hint_convertible(p, x); }
  1725. //! <b>Effects</b>: Inserts a new value move constructed from x in the container.
  1726. //! p is a hint pointing to where the insert should start to search.
  1727. //!
  1728. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1729. //! to the key of x.
  1730. //!
  1731. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1732. //! is inserted right before p.
  1733. inline iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x)
  1734. { return this->base_t::insert_equal_hint_convertible(p, boost::move(x)); }
  1735. //! <b>Effects</b>: Inserts a new value constructed from x in the container.
  1736. //! p is a hint pointing to where the insert should start to search.
  1737. //!
  1738. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1739. //! to the key of x.
  1740. //!
  1741. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1742. //! is inserted right before p.
  1743. template<class Pair>
  1744. inline BOOST_CONTAINER_DOC1ST
  1745. ( iterator
  1746. , typename dtl::enable_if_c<
  1747. dtl::is_convertible<Pair BOOST_MOVE_I value_type>::value ||
  1748. dtl::is_convertible<Pair BOOST_MOVE_I movable_value_type>::value
  1749. BOOST_MOVE_I iterator>::type)
  1750. insert(const_iterator p, BOOST_FWD_REF(Pair) x)
  1751. { return this->base_t::emplace_hint_equal(p, boost::forward<Pair>(x)); }
  1752. //! <b>Requires</b>: first, last are not iterators into *this.
  1753. //!
  1754. //! <b>Effects</b>: inserts each element from the range [first,last) .
  1755. //!
  1756. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
  1757. template <class InputIterator>
  1758. inline void insert(InputIterator first, InputIterator last)
  1759. { this->base_t::insert_equal_range(first, last); }
  1760. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1761. //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end().
  1762. //!
  1763. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end())
  1764. inline void insert(std::initializer_list<value_type> il)
  1765. { this->base_t::insert_equal_range(il.begin(), il.end()); }
  1766. #endif
  1767. //! <b>Requires</b>: nh is empty or this->get_allocator() == nh.get_allocator().
  1768. //!
  1769. //! <b>Effects/Returns</b>: If nh is empty, has no effect and returns end(). Otherwise, inserts
  1770. //! the element owned by nh and returns an iterator pointing to the newly inserted element.
  1771. //! If a range containing elements with keys equivalent to nh.key() exists,
  1772. //! the element is inserted at the end of that range. nh is always emptied.
  1773. //!
  1774. //! <b>Complexity</b>: Logarithmic
  1775. iterator insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  1776. {
  1777. typename base_t::node_type n(boost::move(nh));
  1778. return this->base_t::insert_equal_node(boost::move(n));
  1779. }
  1780. //! <b>Effects</b>: Same as `insert(node_type && nh)` but the element is inserted as close as possible
  1781. //! to the position just prior to "hint".
  1782. //!
  1783. //! <b>Complexity</b>: logarithmic in general, but amortized constant if the element is inserted
  1784. //! right before "hint".
  1785. iterator insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  1786. {
  1787. typename base_t::node_type n(boost::move(nh));
  1788. return this->base_t::insert_equal_node(hint, boost::move(n));
  1789. }
  1790. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1791. //! @copydoc ::boost::container::set::erase(const_iterator)
  1792. iterator erase(const_iterator p);
  1793. //! @copydoc ::boost::container::set::erase(const key_type&)
  1794. size_type erase(const key_type& x);
  1795. //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator)
  1796. iterator erase(const_iterator first, const_iterator last);
  1797. #endif
  1798. //! @copydoc ::boost::container::map::extract(const key_type&)
  1799. node_type extract(const key_type& k)
  1800. {
  1801. typename base_t::node_type base_nh(this->base_t::extract(k));
  1802. return node_type(boost::move(base_nh));
  1803. }
  1804. //! @copydoc ::boost::container::map::extract(const_iterator)
  1805. node_type extract(const_iterator position)
  1806. {
  1807. typename base_t::node_type base_nh(this->base_t::extract(position));
  1808. return node_type (boost::move(base_nh));
  1809. }
  1810. //! <b>Requires</b>: this->get_allocator() == source.get_allocator().
  1811. //!
  1812. //! <b>Effects</b>: Extracts each element in source and insert it into a using
  1813. //! the comparison object of *this.
  1814. //!
  1815. //! <b>Postcondition</b>: Pointers and references to the transferred elements of source refer
  1816. //! to those same elements but as members of *this. Iterators referring to the transferred
  1817. //! elements will continue to refer to their elements, but they now behave as iterators into *this,
  1818. //! not into source.
  1819. //!
  1820. //! <b>Throws</b>: Nothing unless the comparison object throws.
  1821. //!
  1822. //! <b>Complexity</b>: N log(size() + N) (N has the value source.size())
  1823. template<class C2>
  1824. inline void merge(multimap<Key, T, C2, Allocator, Options>& source)
  1825. {
  1826. typedef dtl::tree
  1827. <value_type_impl, select_1st_t, C2, Allocator, Options> base2_t;
  1828. this->base_t::merge_equal(static_cast<base2_t&>(source));
  1829. }
  1830. //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&)
  1831. template<class C2>
  1832. inline void merge(BOOST_RV_REF_BEG multimap<Key, T, C2, Allocator, Options> BOOST_RV_REF_END source)
  1833. { return this->merge(static_cast<multimap<Key, T, C2, Allocator, Options>&>(source)); }
  1834. //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&)
  1835. template<class C2>
  1836. inline void merge(map<Key, T, C2, Allocator, Options>& source)
  1837. {
  1838. typedef dtl::tree
  1839. <value_type_impl, select_1st_t, C2, Allocator, Options> base2_t;
  1840. this->base_t::merge_equal(static_cast<base2_t&>(source));
  1841. }
  1842. //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&)
  1843. template<class C2>
  1844. inline void merge(BOOST_RV_REF_BEG map<Key, T, C2, Allocator, Options> BOOST_RV_REF_END source)
  1845. { return this->merge(static_cast<map<Key, T, C2, Allocator, Options>&>(source)); }
  1846. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1847. //! @copydoc ::boost::container::set::swap
  1848. void swap(multiset& x)
  1849. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1850. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1851. //! @copydoc ::boost::container::set::clear
  1852. void clear() BOOST_NOEXCEPT_OR_NOTHROW;
  1853. //! @copydoc ::boost::container::set::key_comp
  1854. key_compare key_comp() const;
  1855. //! @copydoc ::boost::container::set::value_comp
  1856. value_compare value_comp() const;
  1857. //! <b>Returns</b>: An iterator pointing to an element with the key
  1858. //! equivalent to x, or end() if such an element is not found.
  1859. //!
  1860. //! <b>Complexity</b>: Logarithmic.
  1861. iterator find(const key_type& x);
  1862. //! <b>Returns</b>: A const iterator pointing to an element with the key
  1863. //! equivalent to x, or end() if such an element is not found.
  1864. //!
  1865. //! <b>Complexity</b>: Logarithmic.
  1866. const_iterator find(const key_type& x) const;
  1867. //! <b>Requires</b>: This overload is available only if
  1868. //! key_compare::is_transparent exists.
  1869. //!
  1870. //! <b>Returns</b>: An iterator pointing to an element with the key
  1871. //! equivalent to x, or end() if such an element is not found.
  1872. //!
  1873. //! <b>Complexity</b>: Logarithmic.
  1874. template<typename K>
  1875. iterator find(const K& x);
  1876. //! <b>Requires</b>: This overload is available only if
  1877. //! key_compare::is_transparent exists.
  1878. //!
  1879. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  1880. //! equivalent to x, or end() if such an element is not found.
  1881. //!
  1882. //! <b>Complexity</b>: Logarithmic.
  1883. template<typename K>
  1884. const_iterator find(const K& x) const;
  1885. //! <b>Returns</b>: The number of elements with key equivalent to x.
  1886. //!
  1887. //! <b>Complexity</b>: log(size())+count(k)
  1888. size_type count(const key_type& x) const;
  1889. //! <b>Requires</b>: This overload is available only if
  1890. //! key_compare::is_transparent exists.
  1891. //!
  1892. //! <b>Returns</b>: The number of elements with key equivalent to x.
  1893. //!
  1894. //! <b>Complexity</b>: log(size())+count(k)
  1895. template<typename K>
  1896. size_type count(const K& x) const;
  1897. //! <b>Returns</b>: Returns true if there is an element with key
  1898. //! equivalent to key in the container, otherwise false.
  1899. //!
  1900. //! <b>Complexity</b>: log(size()).
  1901. bool contains(const key_type& x) const;
  1902. //! <b>Requires</b>: This overload is available only if
  1903. //! key_compare::is_transparent exists.
  1904. //!
  1905. //! <b>Returns</b>: Returns true if there is an element with key
  1906. //! equivalent to key in the container, otherwise false.
  1907. //!
  1908. //! <b>Complexity</b>: log(size()).
  1909. template<typename K>
  1910. bool contains(const K& x) const;
  1911. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  1912. //! than x, or end() if such an element is not found.
  1913. //!
  1914. //! <b>Complexity</b>: Logarithmic
  1915. iterator lower_bound(const key_type& x);
  1916. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  1917. //! less than x, or end() if such an element is not found.
  1918. //!
  1919. //! <b>Complexity</b>: Logarithmic
  1920. const_iterator lower_bound(const key_type& x) const;
  1921. //! <b>Requires</b>: This overload is available only if
  1922. //! key_compare::is_transparent exists.
  1923. //!
  1924. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  1925. //! than x, or end() if such an element is not found.
  1926. //!
  1927. //! <b>Complexity</b>: Logarithmic
  1928. template<typename K>
  1929. iterator lower_bound(const K& x);
  1930. //! <b>Requires</b>: This overload is available only if
  1931. //! key_compare::is_transparent exists.
  1932. //!
  1933. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  1934. //! less than x, or end() if such an element is not found.
  1935. //!
  1936. //! <b>Complexity</b>: Logarithmic
  1937. template<typename K>
  1938. const_iterator lower_bound(const K& x) const;
  1939. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  1940. //! than x, or end() if such an element is not found.
  1941. //!
  1942. //! <b>Complexity</b>: Logarithmic
  1943. iterator upper_bound(const key_type& x);
  1944. //! <b>Returns</b>: A const iterator pointing to the first element with key
  1945. //! greater than x, or end() if such an element is not found.
  1946. //!
  1947. //! <b>Complexity</b>: Logarithmic
  1948. const_iterator upper_bound(const key_type& x) const;
  1949. //! <b>Requires</b>: This overload is available only if
  1950. //! key_compare::is_transparent exists.
  1951. //!
  1952. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  1953. //! than x, or end() if such an element is not found.
  1954. //!
  1955. //! <b>Complexity</b>: Logarithmic
  1956. template<typename K>
  1957. iterator upper_bound(const K& x);
  1958. //! <b>Requires</b>: This overload is available only if
  1959. //! key_compare::is_transparent exists.
  1960. //!
  1961. //! <b>Returns</b>: A const iterator pointing to the first element with key
  1962. //! greater than x, or end() if such an element is not found.
  1963. //!
  1964. //! <b>Complexity</b>: Logarithmic
  1965. template<typename K>
  1966. const_iterator upper_bound(const K& x) const;
  1967. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  1968. //!
  1969. //! <b>Complexity</b>: Logarithmic
  1970. std::pair<iterator,iterator> equal_range(const key_type& x);
  1971. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  1972. //!
  1973. //! <b>Complexity</b>: Logarithmic
  1974. std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
  1975. //! <b>Requires</b>: This overload is available only if
  1976. //! key_compare::is_transparent exists.
  1977. //!
  1978. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  1979. //!
  1980. //! <b>Complexity</b>: Logarithmic
  1981. template<typename K>
  1982. std::pair<iterator,iterator> equal_range(const K& x);
  1983. //! <b>Requires</b>: This overload is available only if
  1984. //! key_compare::is_transparent exists.
  1985. //!
  1986. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  1987. //!
  1988. //! <b>Complexity</b>: Logarithmic
  1989. template<typename K>
  1990. std::pair<const_iterator,const_iterator> equal_range(const K& x) const;
  1991. //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees.
  1992. //!
  1993. //! <b>Complexity</b>: Linear
  1994. void rebalance();
  1995. //! <b>Effects</b>: Returns true if x and y are equal
  1996. //!
  1997. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1998. friend bool operator==(const multimap& x, const multimap& y);
  1999. //! <b>Effects</b>: Returns true if x and y are unequal
  2000. //!
  2001. //! <b>Complexity</b>: Linear to the number of elements in the container.
  2002. friend bool operator!=(const multimap& x, const multimap& y);
  2003. //! <b>Effects</b>: Returns true if x is less than y
  2004. //!
  2005. //! <b>Complexity</b>: Linear to the number of elements in the container.
  2006. friend bool operator<(const multimap& x, const multimap& y);
  2007. //! <b>Effects</b>: Returns true if x is greater than y
  2008. //!
  2009. //! <b>Complexity</b>: Linear to the number of elements in the container.
  2010. friend bool operator>(const multimap& x, const multimap& y);
  2011. //! <b>Effects</b>: Returns true if x is equal or less than y
  2012. //!
  2013. //! <b>Complexity</b>: Linear to the number of elements in the container.
  2014. friend bool operator<=(const multimap& x, const multimap& y);
  2015. //! <b>Effects</b>: Returns true if x is equal or greater than y
  2016. //!
  2017. //! <b>Complexity</b>: Linear to the number of elements in the container.
  2018. friend bool operator>=(const multimap& x, const multimap& y);
  2019. //! <b>Effects</b>: x.swap(y)
  2020. //!
  2021. //! <b>Complexity</b>: Constant.
  2022. friend void swap(multimap& x, multimap& y)
  2023. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  2024. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  2025. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  2026. };
  2027. //! <b>Effects</b>: Erases all elements that satisfy the predicate pred from the container c.
  2028. //!
  2029. //! <b>Complexity</b>: Linear.
  2030. template <class K, class M, class C, class A, class O, class Pred>
  2031. inline typename multimap<K, M, C, A, O>::size_type erase_if(multimap<K, M, C, A, O>& c, Pred pred)
  2032. {
  2033. return container_erase_if(c, pred);
  2034. }
  2035. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  2036. template <typename InputIterator>
  2037. multimap(InputIterator, InputIterator) ->
  2038. multimap< it_based_non_const_first_type_t<InputIterator>
  2039. , it_based_second_type_t<InputIterator>>;
  2040. template < typename InputIterator, typename AllocatorOrCompare>
  2041. multimap(InputIterator, InputIterator, AllocatorOrCompare const&) ->
  2042. multimap< it_based_non_const_first_type_t<InputIterator>
  2043. , it_based_second_type_t<InputIterator>
  2044. , typename dtl::if_c< // Compare
  2045. dtl::is_allocator<AllocatorOrCompare>::value
  2046. , std::less<it_based_non_const_first_type_t<InputIterator>>
  2047. , AllocatorOrCompare
  2048. >::type
  2049. , typename dtl::if_c< // Allocator
  2050. dtl::is_allocator<AllocatorOrCompare>::value
  2051. , AllocatorOrCompare
  2052. , new_allocator<std::pair<it_based_const_first_type_t<InputIterator>, it_based_second_type_t<InputIterator>>>
  2053. >::type
  2054. >;
  2055. template < typename InputIterator, typename Compare, typename Allocator
  2056. , typename = dtl::require_nonallocator_t<Compare>
  2057. , typename = dtl::require_allocator_t<Allocator>>
  2058. multimap(InputIterator, InputIterator, Compare const&, Allocator const&) ->
  2059. multimap< it_based_non_const_first_type_t<InputIterator>
  2060. , it_based_second_type_t<InputIterator>
  2061. , Compare
  2062. , Allocator>;
  2063. template <typename InputIterator>
  2064. multimap(ordered_range_t, InputIterator, InputIterator) ->
  2065. multimap< it_based_non_const_first_type_t<InputIterator>
  2066. , it_based_second_type_t<InputIterator>>;
  2067. template < typename InputIterator, typename AllocatorOrCompare>
  2068. multimap(ordered_range_t, InputIterator, InputIterator, AllocatorOrCompare const&) ->
  2069. multimap< it_based_non_const_first_type_t<InputIterator>
  2070. , it_based_second_type_t<InputIterator>
  2071. , typename dtl::if_c< // Compare
  2072. dtl::is_allocator<AllocatorOrCompare>::value
  2073. , std::less<it_based_const_first_type_t<InputIterator>>
  2074. , AllocatorOrCompare
  2075. >::type
  2076. , typename dtl::if_c< // Allocator
  2077. dtl::is_allocator<AllocatorOrCompare>::value
  2078. , AllocatorOrCompare
  2079. , new_allocator<std::pair<it_based_const_first_type_t<InputIterator>, it_based_second_type_t<InputIterator>>>
  2080. >::type
  2081. >;
  2082. template < typename InputIterator, typename Compare, typename Allocator
  2083. , typename = dtl::require_nonallocator_t<Compare>
  2084. , typename = dtl::require_allocator_t<Allocator>>
  2085. multimap(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
  2086. multimap< it_based_non_const_first_type_t<InputIterator>
  2087. , it_based_second_type_t<InputIterator>
  2088. , Compare
  2089. , Allocator>;
  2090. #endif
  2091. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  2092. } //namespace container {
  2093. //!has_trivial_destructor_after_move<> == true_type
  2094. //!specialization for optimizations
  2095. template <class Key, class T, class Compare, class Allocator, class Options>
  2096. struct has_trivial_destructor_after_move<boost::container::multimap<Key, T, Compare, Allocator, Options> >
  2097. {
  2098. typedef ::boost::container::dtl::tree<std::pair<const Key, T>, int, Compare, Allocator, Options> tree;
  2099. BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
  2100. };
  2101. namespace container {
  2102. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  2103. }}
  2104. #include <boost/container/detail/config_end.hpp>
  2105. #endif // BOOST_CONTAINER_MAP_HPP