map.hpp 101 KB

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