map.hpp 101 KB

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