map.hpp 104 KB

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