flat_set.hpp 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944
  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_FLAT_SET_HPP
  11. #define BOOST_CONTAINER_FLAT_SET_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/allocator_traits.hpp>
  22. #include <boost/container/container_fwd.hpp>
  23. #include <boost/container/new_allocator.hpp> //new_allocator
  24. // container/detail
  25. #include <boost/container/detail/flat_tree.hpp>
  26. #include <boost/container/detail/mpl.hpp>
  27. // move
  28. #include <boost/move/traits.hpp>
  29. #include <boost/move/utility_core.hpp>
  30. // move/detail
  31. #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  32. #include <boost/move/detail/fwd_macros.hpp>
  33. #endif
  34. #include <boost/move/detail/move_helpers.hpp>
  35. // intrusive/detail
  36. #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
  37. #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
  38. // std
  39. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  40. #include <initializer_list>
  41. #endif
  42. namespace boost {
  43. namespace container {
  44. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  45. template <class Key, class Compare, class AllocatorOrContainer>
  46. class flat_multiset;
  47. #endif
  48. //! flat_set is a Sorted Associative Container that stores objects of type Key.
  49. //! It is also a Unique Associative Container, meaning that no two elements are the same.
  50. //!
  51. //! flat_set is similar to std::set but it's implemented by as an ordered sequence container.
  52. //! The underlying sequence container is by default <i>vector</i> but it can also work
  53. //! user-provided vector-like SequenceContainers (like <i>static_vector</i> or <i>small_vector</i>).
  54. //!
  55. //! Using vector-like sequence containers means that inserting a new element into a flat_set might invalidate
  56. //! previous iterators and references (unless that sequence container is <i>stable_vector</i> or a similar
  57. //! container that offers stable pointers and references). Similarly, erasing an element might invalidate
  58. //! iterators and references pointing to elements that come after (their keys are bigger) the erased element.
  59. //!
  60. //! This container provides random-access iterators.
  61. //!
  62. //! \tparam Key is the type to be inserted in the set, which is also the key_type
  63. //! \tparam Compare is the comparison functor used to order keys
  64. //! \tparam AllocatorOrContainer is either:
  65. //! - The allocator to allocate <code>value_type</code>s (e.g. <i>allocator< std::pair<Key, T> > </i>).
  66. //! (in this case <i>sequence_type</i> will be vector<value_type, AllocatorOrContainer>)
  67. //! - The SequenceContainer to be used as the underlying <i>sequence_type</i>. It must be a vector-like
  68. //! sequence container with random-access iterators.
  69. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  70. template <class Key, class Compare = std::less<Key>, class AllocatorOrContainer = new_allocator<Key> >
  71. #else
  72. template <class Key, class Compare, class AllocatorOrContainer>
  73. #endif
  74. class flat_set
  75. ///@cond
  76. : public dtl::flat_tree<Key, dtl::identity<Key>, Compare, AllocatorOrContainer>
  77. ///@endcond
  78. {
  79. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  80. private:
  81. BOOST_COPYABLE_AND_MOVABLE(flat_set)
  82. typedef dtl::flat_tree<Key, dtl::identity<Key>, Compare, AllocatorOrContainer> tree_t;
  83. public:
  84. tree_t &tree()
  85. { return *this; }
  86. const tree_t &tree() const
  87. { return *this; }
  88. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  89. public:
  90. //////////////////////////////////////////////
  91. //
  92. // types
  93. //
  94. //////////////////////////////////////////////
  95. typedef Key key_type;
  96. typedef Compare key_compare;
  97. typedef Key value_type;
  98. typedef typename BOOST_CONTAINER_IMPDEF(tree_t::sequence_type) sequence_type;
  99. typedef typename sequence_type::allocator_type allocator_type;
  100. typedef ::boost::container::allocator_traits<allocator_type> allocator_traits_type;
  101. typedef typename sequence_type::pointer pointer;
  102. typedef typename sequence_type::const_pointer const_pointer;
  103. typedef typename sequence_type::reference reference;
  104. typedef typename sequence_type::const_reference const_reference;
  105. typedef typename sequence_type::size_type size_type;
  106. typedef typename sequence_type::difference_type difference_type;
  107. typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type) stored_allocator_type;
  108. typedef typename BOOST_CONTAINER_IMPDEF(tree_t::value_compare) value_compare;
  109. typedef typename sequence_type::iterator iterator;
  110. typedef typename sequence_type::const_iterator const_iterator;
  111. typedef typename sequence_type::reverse_iterator reverse_iterator;
  112. typedef typename sequence_type::const_reverse_iterator const_reverse_iterator;
  113. public:
  114. //////////////////////////////////////////////
  115. //
  116. // construct/copy/destroy
  117. //
  118. //////////////////////////////////////////////
  119. //! <b>Effects</b>: Default constructs an empty container.
  120. //!
  121. //! <b>Complexity</b>: Constant.
  122. BOOST_CONTAINER_FORCEINLINE
  123. flat_set() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<AllocatorOrContainer>::value &&
  124. dtl::is_nothrow_default_constructible<Compare>::value)
  125. : tree_t()
  126. {}
  127. //! <b>Effects</b>: Constructs an empty container using the specified
  128. //! comparison object.
  129. //!
  130. //! <b>Complexity</b>: Constant.
  131. BOOST_CONTAINER_FORCEINLINE
  132. explicit flat_set(const Compare& comp)
  133. : tree_t(comp)
  134. {}
  135. //! <b>Effects</b>: Constructs an empty container using the specified allocator.
  136. //!
  137. //! <b>Complexity</b>: Constant.
  138. BOOST_CONTAINER_FORCEINLINE
  139. explicit flat_set(const allocator_type& a)
  140. : tree_t(a)
  141. {}
  142. //! <b>Effects</b>: Constructs an empty container using the specified
  143. //! comparison object and allocator.
  144. //!
  145. //! <b>Complexity</b>: Constant.
  146. BOOST_CONTAINER_FORCEINLINE
  147. flat_set(const Compare& comp, const allocator_type& a)
  148. : tree_t(comp, a)
  149. {}
  150. //! <b>Effects</b>: Constructs an empty container and
  151. //! inserts elements from the range [first ,last ).
  152. //!
  153. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  154. //! comp and otherwise N logN, where N is last - first.
  155. template <class InputIterator>
  156. BOOST_CONTAINER_FORCEINLINE
  157. flat_set(InputIterator first, InputIterator last)
  158. : tree_t(true, first, last)
  159. {}
  160. //! <b>Effects</b>: Constructs an empty container using the specified
  161. //! allocator, and inserts elements from the range [first ,last ).
  162. //!
  163. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  164. //! comp and otherwise N logN, where N is last - first.
  165. template <class InputIterator>
  166. BOOST_CONTAINER_FORCEINLINE
  167. flat_set(InputIterator first, InputIterator last, const allocator_type& a)
  168. : tree_t(true, first, last, a)
  169. {}
  170. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  171. //! inserts elements from the range [first ,last ).
  172. //!
  173. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  174. //! comp and otherwise N logN, where N is last - first.
  175. template <class InputIterator>
  176. BOOST_CONTAINER_FORCEINLINE
  177. flat_set(InputIterator first, InputIterator last, const Compare& comp)
  178. : tree_t(true, first, last, comp)
  179. {}
  180. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  181. //! allocator, and inserts elements from the range [first ,last ).
  182. //!
  183. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  184. //! comp and otherwise N logN, where N is last - first.
  185. template <class InputIterator>
  186. BOOST_CONTAINER_FORCEINLINE
  187. flat_set(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  188. : tree_t(true, first, last, comp, a)
  189. {}
  190. //! <b>Effects</b>: Constructs an empty container and
  191. //! inserts elements from the ordered unique range [first ,last). This function
  192. //! is more efficient than the normal range creation for ordered ranges.
  193. //!
  194. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  195. //! unique values.
  196. //!
  197. //! <b>Complexity</b>: Linear in N.
  198. //!
  199. //! <b>Note</b>: Non-standard extension.
  200. template <class InputIterator>
  201. BOOST_CONTAINER_FORCEINLINE
  202. flat_set(ordered_unique_range_t, InputIterator first, InputIterator last)
  203. : tree_t(ordered_unique_range, first, last)
  204. {}
  205. //! <b>Effects</b>: Constructs an empty container 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
  217. flat_set(ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp)
  218. : tree_t(ordered_unique_range, first, last, comp)
  219. {}
  220. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  221. //! allocator, and inserts elements from the ordered unique range [first ,last). This function
  222. //! is more efficient than the normal range creation for ordered ranges.
  223. //!
  224. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  225. //! unique values.
  226. //!
  227. //! <b>Complexity</b>: Linear in N.
  228. //!
  229. //! <b>Note</b>: Non-standard extension.
  230. template <class InputIterator>
  231. BOOST_CONTAINER_FORCEINLINE
  232. flat_set(ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  233. : tree_t(ordered_unique_range, first, last, comp, a)
  234. {}
  235. //! <b>Effects</b>: Constructs an empty container using the specified allocator and
  236. //! inserts elements from the ordered unique range [first ,last). This function
  237. //! is more efficient than the normal range creation for ordered ranges.
  238. //!
  239. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  240. //! unique values.
  241. //!
  242. //! <b>Complexity</b>: Linear in N.
  243. //!
  244. //! <b>Note</b>: Non-standard extension.
  245. template <class InputIterator>
  246. BOOST_CONTAINER_FORCEINLINE
  247. flat_set(ordered_unique_range_t, InputIterator first, InputIterator last, const allocator_type& a)
  248. : tree_t(ordered_unique_range, first, last, Compare(), a)
  249. {}
  250. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  251. //! <b>Effects</b>: Constructs an empty container and
  252. //! inserts elements from the range [il.begin(), il.end()).
  253. //!
  254. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  255. //! comp and otherwise N logN, where N is il.begin() - il.end().
  256. BOOST_CONTAINER_FORCEINLINE flat_set(std::initializer_list<value_type> il)
  257. : tree_t(true, il.begin(), il.end())
  258. {}
  259. //! <b>Effects</b>: Constructs an empty container using the specified
  260. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  261. //!
  262. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  263. //! comp and otherwise N logN, where N is il.begin() - il.end().
  264. BOOST_CONTAINER_FORCEINLINE flat_set(std::initializer_list<value_type> il, const allocator_type& a)
  265. : tree_t(true, il.begin(), il.end(), a)
  266. {}
  267. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  268. //! inserts elements from the range [il.begin(), il.end()).
  269. //!
  270. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  271. //! comp and otherwise N logN, where N is il.begin() - il.end().
  272. BOOST_CONTAINER_FORCEINLINE flat_set(std::initializer_list<value_type> il, const Compare& comp)
  273. : tree_t(true, il.begin(), il.end(), comp)
  274. {}
  275. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  276. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  277. //!
  278. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  279. //! comp and otherwise N logN, where N is il.begin() - il.end().
  280. BOOST_CONTAINER_FORCEINLINE flat_set(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  281. : tree_t(true, il.begin(), il.end(), comp, a)
  282. {}
  283. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  284. //! inserts elements from the ordered unique range [il.begin(), il.end()). This function
  285. //! is more efficient than the normal range creation for ordered ranges.
  286. //!
  287. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  288. //! unique values.
  289. //!
  290. //! <b>Complexity</b>: Linear in N.
  291. //!
  292. //! <b>Note</b>: Non-standard extension.
  293. BOOST_CONTAINER_FORCEINLINE flat_set(ordered_unique_range_t, std::initializer_list<value_type> il)
  294. : tree_t(ordered_unique_range, il.begin(), il.end())
  295. {}
  296. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  297. //! inserts elements from the ordered unique range [il.begin(), il.end()). This function
  298. //! is more efficient than the normal range creation for ordered ranges.
  299. //!
  300. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  301. //! unique values.
  302. //!
  303. //! <b>Complexity</b>: Linear in N.
  304. //!
  305. //! <b>Note</b>: Non-standard extension.
  306. BOOST_CONTAINER_FORCEINLINE flat_set(ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp)
  307. : tree_t(ordered_unique_range, il.begin(), il.end(), comp)
  308. {}
  309. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  310. //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function
  311. //! is more efficient than the normal range creation for ordered ranges.
  312. //!
  313. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  314. //! unique values.
  315. //!
  316. //! <b>Complexity</b>: Linear in N.
  317. //!
  318. //! <b>Note</b>: Non-standard extension.
  319. BOOST_CONTAINER_FORCEINLINE flat_set(ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  320. : tree_t(ordered_unique_range, il.begin(), il.end(), comp, a)
  321. {}
  322. #endif
  323. //! <b>Effects</b>: Copy constructs the container.
  324. //!
  325. //! <b>Complexity</b>: Linear in x.size().
  326. BOOST_CONTAINER_FORCEINLINE flat_set(const flat_set& x)
  327. : tree_t(static_cast<const tree_t&>(x))
  328. {}
  329. //! <b>Effects</b>: Move constructs thecontainer. Constructs *this using x's resources.
  330. //!
  331. //! <b>Complexity</b>: Constant.
  332. //!
  333. //! <b>Postcondition</b>: x is emptied.
  334. BOOST_CONTAINER_FORCEINLINE flat_set(BOOST_RV_REF(flat_set) x)
  335. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value)
  336. : tree_t(BOOST_MOVE_BASE(tree_t, x))
  337. {}
  338. //! <b>Effects</b>: Copy constructs a container using the specified allocator.
  339. //!
  340. //! <b>Complexity</b>: Linear in x.size().
  341. BOOST_CONTAINER_FORCEINLINE flat_set(const flat_set& x, const allocator_type &a)
  342. : tree_t(static_cast<const tree_t&>(x), a)
  343. {}
  344. //! <b>Effects</b>: Move constructs a container using the specified allocator.
  345. //! Constructs *this using x's resources.
  346. //!
  347. //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise
  348. BOOST_CONTAINER_FORCEINLINE flat_set(BOOST_RV_REF(flat_set) x, const allocator_type &a)
  349. : tree_t(BOOST_MOVE_BASE(tree_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 flat_set& operator=(BOOST_COPY_ASSIGN_REF(flat_set) x)
  355. { return static_cast<flat_set&>(this->tree_t::operator=(static_cast<const tree_t&>(x))); }
  356. //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
  357. //! is false and (allocation throws or value_type's move constructor throws)
  358. //!
  359. //! <b>Complexity</b>: Constant if allocator_traits_type::
  360. //! propagate_on_container_move_assignment is true or
  361. //! this->get>allocator() == x.get_allocator(). Linear otherwise.
  362. BOOST_CONTAINER_FORCEINLINE flat_set& operator=(BOOST_RV_REF(flat_set) x)
  363. BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
  364. allocator_traits_type::is_always_equal::value) &&
  365. boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
  366. { return static_cast<flat_set&>(this->tree_t::operator=(BOOST_MOVE_BASE(tree_t, x))); }
  367. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  368. //! <b>Effects</b>: Copy all elements from il to *this.
  369. //!
  370. //! <b>Complexity</b>: Linear in il.size().
  371. flat_set& operator=(std::initializer_list<value_type> il)
  372. {
  373. this->clear();
  374. this->insert(il.begin(), il.end());
  375. return *this;
  376. }
  377. #endif
  378. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  379. //! <b>Effects</b>: Returns a copy of the allocator that
  380. //! was passed to the object's constructor.
  381. //!
  382. //! <b>Complexity</b>: Constant.
  383. allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
  384. //! <b>Effects</b>: Returns a reference to the internal allocator.
  385. //!
  386. //! <b>Throws</b>: Nothing
  387. //!
  388. //! <b>Complexity</b>: Constant.
  389. //!
  390. //! <b>Note</b>: Non-standard extension.
  391. stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW;
  392. //! <b>Effects</b>: Returns a reference to the internal allocator.
  393. //!
  394. //! <b>Throws</b>: Nothing
  395. //!
  396. //! <b>Complexity</b>: Constant.
  397. //!
  398. //! <b>Note</b>: Non-standard extension.
  399. const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
  400. //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
  401. //!
  402. //! <b>Throws</b>: Nothing.
  403. //!
  404. //! <b>Complexity</b>: Constant.
  405. iterator begin() BOOST_NOEXCEPT_OR_NOTHROW;
  406. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
  407. //!
  408. //! <b>Throws</b>: Nothing.
  409. //!
  410. //! <b>Complexity</b>: Constant.
  411. const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW;
  412. //! <b>Effects</b>: Returns an iterator to the end of the container.
  413. //!
  414. //! <b>Throws</b>: Nothing.
  415. //!
  416. //! <b>Complexity</b>: Constant.
  417. iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
  418. //! <b>Effects</b>: Returns a const_iterator to the end of the container.
  419. //!
  420. //! <b>Throws</b>: Nothing.
  421. //!
  422. //! <b>Complexity</b>: Constant.
  423. const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
  424. //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
  425. //! of the reversed container.
  426. //!
  427. //! <b>Throws</b>: Nothing.
  428. //!
  429. //! <b>Complexity</b>: Constant.
  430. reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
  431. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  432. //! of the reversed container.
  433. //!
  434. //! <b>Throws</b>: Nothing.
  435. //!
  436. //! <b>Complexity</b>: Constant.
  437. const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  438. //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
  439. //! of the reversed container.
  440. //!
  441. //! <b>Throws</b>: Nothing.
  442. //!
  443. //! <b>Complexity</b>: Constant.
  444. reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
  445. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
  446. //! of the reversed container.
  447. //!
  448. //! <b>Throws</b>: Nothing.
  449. //!
  450. //! <b>Complexity</b>: Constant.
  451. const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
  452. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
  453. //!
  454. //! <b>Throws</b>: Nothing.
  455. //!
  456. //! <b>Complexity</b>: Constant.
  457. const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  458. //! <b>Effects</b>: Returns a const_iterator to the end of the container.
  459. //!
  460. //! <b>Throws</b>: Nothing.
  461. //!
  462. //! <b>Complexity</b>: Constant.
  463. const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
  464. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  465. //! of the reversed container.
  466. //!
  467. //! <b>Throws</b>: Nothing.
  468. //!
  469. //! <b>Complexity</b>: Constant.
  470. const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  471. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
  472. //! of the reversed container.
  473. //!
  474. //! <b>Throws</b>: Nothing.
  475. //!
  476. //! <b>Complexity</b>: Constant.
  477. const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
  478. //! <b>Effects</b>: Returns true if the container contains no elements.
  479. //!
  480. //! <b>Throws</b>: Nothing.
  481. //!
  482. //! <b>Complexity</b>: Constant.
  483. bool empty() const BOOST_NOEXCEPT_OR_NOTHROW;
  484. //! <b>Effects</b>: Returns the number of the elements contained in the container.
  485. //!
  486. //! <b>Throws</b>: Nothing.
  487. //!
  488. //! <b>Complexity</b>: Constant.
  489. size_type size() const BOOST_NOEXCEPT_OR_NOTHROW;
  490. //! <b>Effects</b>: Returns the largest possible size of the container.
  491. //!
  492. //! <b>Throws</b>: Nothing.
  493. //!
  494. //! <b>Complexity</b>: Constant.
  495. size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW;
  496. //! <b>Effects</b>: Number of elements for which memory has been allocated.
  497. //! capacity() is always greater than or equal to size().
  498. //!
  499. //! <b>Throws</b>: Nothing.
  500. //!
  501. //! <b>Complexity</b>: Constant.
  502. size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW;
  503. //! <b>Effects</b>: If n is less than or equal to capacity(), or the
  504. //! underlying container has no `reserve` member, this call has no
  505. //! effect. Otherwise, it is a request for allocation of additional memory.
  506. //! If the request is successful, then capacity() is greater than or equal to
  507. //! n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
  508. //!
  509. //! <b>Throws</b>: If memory allocation allocation throws or T's copy constructor throws.
  510. //!
  511. //! <b>Note</b>: If capacity() is less than "cnt", iterators and references to
  512. //! to values might be invalidated.
  513. void reserve(size_type cnt);
  514. //! <b>Effects</b>: Tries to deallocate the excess of memory created
  515. // with previous allocations. The size of the vector is unchanged
  516. //!
  517. //! <b>Throws</b>: If memory allocation throws, or Key's copy constructor throws.
  518. //!
  519. //! <b>Complexity</b>: Linear to size().
  520. void shrink_to_fit();
  521. #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  522. //////////////////////////////////////////////
  523. //
  524. // modifiers
  525. //
  526. //////////////////////////////////////////////
  527. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  528. //! <b>Effects</b>: Inserts an object x of type Key constructed with
  529. //! std::forward<Args>(args)... if and only if there is no element in the container
  530. //! with key equivalent to the key of x.
  531. //!
  532. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  533. //! if the insertion takes place, and the iterator component of the pair
  534. //! points to the element with key equivalent to the key of x.
  535. //!
  536. //! <b>Complexity</b>: Logarithmic search time plus linear insertion
  537. //! to the elements with bigger keys than x.
  538. //!
  539. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  540. template <class... Args>
  541. BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> emplace(BOOST_FWD_REF(Args)... args)
  542. { return this->tree_t::emplace_unique(boost::forward<Args>(args)...); }
  543. //! <b>Effects</b>: Inserts an object of type Key constructed with
  544. //! std::forward<Args>(args)... in the container if and only if there is
  545. //! no element in the container with key equivalent to the key of x.
  546. //! p is a hint pointing to where the insert should start to search.
  547. //!
  548. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  549. //! to the key of x.
  550. //!
  551. //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
  552. //! right before p) plus insertion linear to the elements with bigger keys than x.
  553. //!
  554. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  555. template <class... Args>
  556. BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
  557. { return this->tree_t::emplace_hint_unique(p, boost::forward<Args>(args)...); }
  558. #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  559. #define BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE(N) \
  560. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  561. BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> emplace(BOOST_MOVE_UREF##N)\
  562. { return this->tree_t::emplace_unique(BOOST_MOVE_FWD##N); }\
  563. \
  564. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  565. BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  566. { return this->tree_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  567. //
  568. BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE)
  569. #undef BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE
  570. #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  571. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  572. //! <b>Effects</b>: Inserts x if and only if there is no element in the container
  573. //! with key equivalent to the key of x.
  574. //!
  575. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  576. //! if the insertion takes place, and the iterator component of the pair
  577. //! points to the element with key equivalent to the key of x.
  578. //!
  579. //! <b>Complexity</b>: Logarithmic search time plus linear insertion
  580. //! to the elements with bigger keys than x.
  581. //!
  582. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  583. std::pair<iterator, bool> insert(const value_type &x);
  584. //! <b>Effects</b>: Inserts a new value_type move constructed from the pair if and
  585. //! only if there is no element in the container with key equivalent to the key of x.
  586. //!
  587. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  588. //! if the insertion takes place, and the iterator component of the pair
  589. //! points to the element with key equivalent to the key of x.
  590. //!
  591. //! <b>Complexity</b>: Logarithmic search time plus linear insertion
  592. //! to the elements with bigger keys than x.
  593. //!
  594. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  595. std::pair<iterator, bool> insert(value_type &&x);
  596. #else
  597. private:
  598. typedef std::pair<iterator, bool> insert_return_pair;
  599. public:
  600. BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert)
  601. #endif
  602. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  603. //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
  604. //! no element in the container with key equivalent to the key of x.
  605. //! p is a hint pointing to where the insert should start to search.
  606. //!
  607. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  608. //! to the key of x.
  609. //!
  610. //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
  611. //! right before p) plus insertion linear to the elements with bigger keys than x.
  612. //!
  613. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  614. iterator insert(const_iterator p, const value_type &x);
  615. //! <b>Effects</b>: Inserts an element move constructed from x in the container.
  616. //! p is a hint pointing to where the insert should start to search.
  617. //!
  618. //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
  619. //!
  620. //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
  621. //! right before p) plus insertion linear to the elements with bigger keys than x.
  622. //!
  623. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  624. iterator insert(const_iterator p, value_type &&x);
  625. #else
  626. BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator)
  627. #endif
  628. //! <b>Requires</b>: first, last are not iterators into *this.
  629. //!
  630. //! <b>Effects</b>: inserts each element from the range [first,last) if and only
  631. //! if there is no element with key equivalent to the key of that element.
  632. //!
  633. //! <b>Complexity</b>: N log(N).
  634. //!
  635. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  636. template <class InputIterator>
  637. BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last)
  638. { this->tree_t::insert_unique(first, last); }
  639. //! <b>Requires</b>: first, last are not iterators into *this and
  640. //! must be ordered according to the predicate and must be
  641. //! unique values.
  642. //!
  643. //! <b>Effects</b>: inserts each element from the range [first,last) .This function
  644. //! is more efficient than the normal range creation for ordered ranges.
  645. //!
  646. //! <b>Complexity</b>: Linear.
  647. //!
  648. //! <b>Note</b>: Non-standard extension. If an element is inserted it might invalidate elements.
  649. template <class InputIterator>
  650. BOOST_CONTAINER_FORCEINLINE void insert(ordered_unique_range_t, InputIterator first, InputIterator last)
  651. { this->tree_t::insert_unique(ordered_unique_range, first, last); }
  652. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  653. //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end()) if and only
  654. //! if there is no element with key equivalent to the key of that element.
  655. //!
  656. //! <b>Complexity</b>: N log(N).
  657. //!
  658. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  659. BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list<value_type> il)
  660. { this->tree_t::insert_unique(il.begin(), il.end()); }
  661. //! <b>Requires</b>: Range [il.begin(), il.end()) must be ordered according to the predicate
  662. //! and must be unique values.
  663. //!
  664. //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end()) .This function
  665. //! is more efficient than the normal range creation for ordered ranges.
  666. //!
  667. //! <b>Complexity</b>: Linear.
  668. //!
  669. //! <b>Note</b>: Non-standard extension. If an element is inserted it might invalidate elements.
  670. BOOST_CONTAINER_FORCEINLINE void insert(ordered_unique_range_t, std::initializer_list<value_type> il)
  671. { this->tree_t::insert_unique(ordered_unique_range, il.begin(), il.end()); }
  672. #endif
  673. //! @copydoc ::boost::container::flat_map::merge(flat_map<Key, T, C2, AllocatorOrContainer>&)
  674. template<class C2>
  675. BOOST_CONTAINER_FORCEINLINE void merge(flat_set<Key, C2, AllocatorOrContainer>& source)
  676. { this->tree_t::merge_unique(source.tree()); }
  677. //! @copydoc ::boost::container::flat_set::merge(flat_set<Key, C2, AllocatorOrContainer>&)
  678. template<class C2>
  679. BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG flat_set<Key, C2, AllocatorOrContainer> BOOST_RV_REF_END source)
  680. { return this->merge(static_cast<flat_set<Key, C2, AllocatorOrContainer>&>(source)); }
  681. //! @copydoc ::boost::container::flat_map::merge(flat_multimap<Key, T, C2, AllocatorOrContainer>&)
  682. template<class C2>
  683. BOOST_CONTAINER_FORCEINLINE void merge(flat_multiset<Key, C2, AllocatorOrContainer>& source)
  684. { this->tree_t::merge_unique(source.tree()); }
  685. //! @copydoc ::boost::container::flat_set::merge(flat_multiset<Key, C2, AllocatorOrContainer>&)
  686. template<class C2>
  687. BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG flat_multiset<Key, C2, AllocatorOrContainer> BOOST_RV_REF_END source)
  688. { return this->merge(static_cast<flat_multiset<Key, C2, AllocatorOrContainer>&>(source)); }
  689. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  690. //! <b>Effects</b>: Erases the element pointed to by p.
  691. //!
  692. //! <b>Returns</b>: Returns an iterator pointing to the element immediately
  693. //! following q prior to the element being erased. If no such element exists,
  694. //! returns end().
  695. //!
  696. //! <b>Complexity</b>: Linear to the elements with keys bigger than p
  697. //!
  698. //! <b>Note</b>: Invalidates elements with keys
  699. //! not less than the erased element.
  700. iterator erase(const_iterator p);
  701. //! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
  702. //!
  703. //! <b>Returns</b>: Returns the number of erased elements.
  704. //!
  705. //! <b>Complexity</b>: Logarithmic search time plus erasure time
  706. //! linear to the elements with bigger keys.
  707. size_type erase(const key_type& x);
  708. //! <b>Effects</b>: Erases all the elements in the range [first, last).
  709. //!
  710. //! <b>Returns</b>: Returns last.
  711. //!
  712. //! <b>Complexity</b>: size()*N where N is the distance from first to last.
  713. //!
  714. //! <b>Complexity</b>: Logarithmic search time plus erasure time
  715. //! linear to the elements with bigger keys.
  716. iterator erase(const_iterator first, const_iterator last);
  717. //! <b>Effects</b>: Swaps the contents of *this and x.
  718. //!
  719. //! <b>Throws</b>: Nothing.
  720. //!
  721. //! <b>Complexity</b>: Constant.
  722. void swap(flat_set& x)
  723. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  724. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  725. //! <b>Effects</b>: erase(a.begin(),a.end()).
  726. //!
  727. //! <b>Postcondition</b>: size() == 0.
  728. //!
  729. //! <b>Complexity</b>: linear in size().
  730. void clear() BOOST_NOEXCEPT_OR_NOTHROW;
  731. //! <b>Effects</b>: Returns the comparison object out
  732. //! of which a was constructed.
  733. //!
  734. //! <b>Complexity</b>: Constant.
  735. key_compare key_comp() const;
  736. //! <b>Effects</b>: Returns an object of value_compare constructed out
  737. //! of the comparison object.
  738. //!
  739. //! <b>Complexity</b>: Constant.
  740. value_compare value_comp() const;
  741. //! <b>Returns</b>: An iterator pointing to an element with the key
  742. //! equivalent to x, or end() if such an element is not found.
  743. //!
  744. //! <b>Complexity</b>: Logarithmic.
  745. iterator find(const key_type& x);
  746. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  747. //! equivalent to x, or end() if such an element is not found.
  748. //!
  749. //! <b>Complexity</b>: Logarithmic.
  750. const_iterator find(const key_type& x) const;
  751. //! <b>Requires</b>: This overload is available only if
  752. //! key_compare::is_transparent exists.
  753. //!
  754. //! <b>Returns</b>: An iterator pointing to an element with the key
  755. //! equivalent to x, or end() if such an element is not found.
  756. //!
  757. //! <b>Complexity</b>: Logarithmic.
  758. template<typename K>
  759. iterator find(const K& x);
  760. //! <b>Requires</b>: This overload is available only if
  761. //! key_compare::is_transparent exists.
  762. //!
  763. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  764. //! equivalent to x, or end() if such an element is not found.
  765. //!
  766. //! <b>Complexity</b>: Logarithmic.
  767. template<typename K>
  768. const_iterator find(const K& x) const;
  769. //! <b>Requires</b>: size() >= n.
  770. //!
  771. //! <b>Effects</b>: Returns an iterator to the nth element
  772. //! from the beginning of the container. Returns end()
  773. //! if n == size().
  774. //!
  775. //! <b>Throws</b>: Nothing.
  776. //!
  777. //! <b>Complexity</b>: Constant.
  778. //!
  779. //! <b>Note</b>: Non-standard extension
  780. iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW;
  781. //! <b>Requires</b>: size() >= n.
  782. //!
  783. //! <b>Effects</b>: Returns a const_iterator to the nth element
  784. //! from the beginning of the container. Returns end()
  785. //! if n == size().
  786. //!
  787. //! <b>Throws</b>: Nothing.
  788. //!
  789. //! <b>Complexity</b>: Constant.
  790. //!
  791. //! <b>Note</b>: Non-standard extension
  792. const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW;
  793. //! <b>Requires</b>: begin() <= p <= end().
  794. //!
  795. //! <b>Effects</b>: Returns the index of the element pointed by p
  796. //! and size() if p == end().
  797. //!
  798. //! <b>Throws</b>: Nothing.
  799. //!
  800. //! <b>Complexity</b>: Constant.
  801. //!
  802. //! <b>Note</b>: Non-standard extension
  803. size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW;
  804. //! <b>Requires</b>: begin() <= p <= end().
  805. //!
  806. //! <b>Effects</b>: Returns the index of the element pointed by p
  807. //! and size() if p == end().
  808. //!
  809. //! <b>Throws</b>: Nothing.
  810. //!
  811. //! <b>Complexity</b>: Constant.
  812. //!
  813. //! <b>Note</b>: Non-standard extension
  814. size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW;
  815. #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  816. //! <b>Returns</b>: The number of elements with key equivalent to x.
  817. //!
  818. //! <b>Complexity</b>: log(size())+count(k)
  819. BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const
  820. { return static_cast<size_type>(this->tree_t::find(x) != this->tree_t::cend()); }
  821. //! <b>Requires</b>: This overload is available only if
  822. //! key_compare::is_transparent exists.
  823. //!
  824. //! <b>Returns</b>: The number of elements with key equivalent to x.
  825. //!
  826. //! <b>Complexity</b>: log(size())+count(k)
  827. template<typename K>
  828. BOOST_CONTAINER_FORCEINLINE size_type count(const K& x) const
  829. { return static_cast<size_type>(this->tree_t::find(x) != this->tree_t::cend()); }
  830. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  831. //! <b>Returns</b>: Returns true if there is an element with key
  832. //! equivalent to key in the container, otherwise false.
  833. //!
  834. //! <b>Complexity</b>: log(size()).
  835. bool contains(const key_type& x) const;
  836. //! <b>Requires</b>: This overload is available only if
  837. //! key_compare::is_transparent exists.
  838. //!
  839. //! <b>Returns</b>: Returns true if there is an element with key
  840. //! equivalent to key in the container, otherwise false.
  841. //!
  842. //! <b>Complexity</b>: log(size()).
  843. template<typename K>
  844. bool contains(const K& x) const;
  845. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  846. //! than k, or a.end() if such an element is not found.
  847. //!
  848. //! <b>Complexity</b>: Logarithmic
  849. iterator lower_bound(const key_type& x);
  850. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  851. //! less than k, or a.end() if such an element is not found.
  852. //!
  853. //! <b>Complexity</b>: Logarithmic
  854. const_iterator lower_bound(const key_type& x) const;
  855. //! <b>Requires</b>: This overload is available only if
  856. //! key_compare::is_transparent exists.
  857. //!
  858. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  859. //! than k, or a.end() if such an element is not found.
  860. //!
  861. //! <b>Complexity</b>: Logarithmic
  862. template<typename K>
  863. iterator lower_bound(const K& x);
  864. //! <b>Requires</b>: This overload is available only if
  865. //! key_compare::is_transparent exists.
  866. //!
  867. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  868. //! less than k, or a.end() if such an element is not found.
  869. //!
  870. //! <b>Complexity</b>: Logarithmic
  871. template<typename K>
  872. const_iterator lower_bound(const K& x) const;
  873. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  874. //! than x, or end() if such an element is not found.
  875. //!
  876. //! <b>Complexity</b>: Logarithmic
  877. iterator upper_bound(const key_type& x);
  878. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  879. //! less than x, or end() if such an element is not found.
  880. //!
  881. //! <b>Complexity</b>: Logarithmic
  882. const_iterator upper_bound(const key_type& x) const;
  883. //! <b>Requires</b>: This overload is available only if
  884. //! key_compare::is_transparent exists.
  885. //!
  886. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  887. //! than x, or end() if such an element is not found.
  888. //!
  889. //! <b>Complexity</b>: Logarithmic
  890. template<typename K>
  891. iterator upper_bound(const K& x);
  892. //! <b>Requires</b>: This overload is available only if
  893. //! key_compare::is_transparent exists.
  894. //!
  895. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  896. //! less than x, or end() if such an element is not found.
  897. //!
  898. //! <b>Complexity</b>: Logarithmic
  899. template<typename K>
  900. const_iterator upper_bound(const K& x) const;
  901. #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  902. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  903. //!
  904. //! <b>Complexity</b>: Logarithmic
  905. BOOST_CONTAINER_FORCEINLINE std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
  906. { return this->tree_t::lower_bound_range(x); }
  907. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  908. //!
  909. //! <b>Complexity</b>: Logarithmic
  910. BOOST_CONTAINER_FORCEINLINE std::pair<iterator,iterator> equal_range(const key_type& x)
  911. { return this->tree_t::lower_bound_range(x); }
  912. //! <b>Requires</b>: This overload is available only if
  913. //! key_compare::is_transparent exists.
  914. //!
  915. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  916. //!
  917. //! <b>Complexity</b>: Logarithmic
  918. template<typename K>
  919. std::pair<iterator,iterator> equal_range(const K& x)
  920. { return this->tree_t::lower_bound_range(x); }
  921. //! <b>Requires</b>: This overload is available only if
  922. //! key_compare::is_transparent exists.
  923. //!
  924. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  925. //!
  926. //! <b>Complexity</b>: Logarithmic
  927. template<typename K>
  928. std::pair<const_iterator,const_iterator> equal_range(const K& x) const
  929. { return this->tree_t::lower_bound_range(x); }
  930. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  931. //! <b>Effects</b>: Returns true if x and y are equal
  932. //!
  933. //! <b>Complexity</b>: Linear to the number of elements in the container.
  934. friend bool operator==(const flat_set& x, const flat_set& y);
  935. //! <b>Effects</b>: Returns true if x and y are unequal
  936. //!
  937. //! <b>Complexity</b>: Linear to the number of elements in the container.
  938. friend bool operator!=(const flat_set& x, const flat_set& y);
  939. //! <b>Effects</b>: Returns true if x is less than y
  940. //!
  941. //! <b>Complexity</b>: Linear to the number of elements in the container.
  942. friend bool operator<(const flat_set& x, const flat_set& y);
  943. //! <b>Effects</b>: Returns true if x is greater than y
  944. //!
  945. //! <b>Complexity</b>: Linear to the number of elements in the container.
  946. friend bool operator>(const flat_set& x, const flat_set& y);
  947. //! <b>Effects</b>: Returns true if x is equal or less than y
  948. //!
  949. //! <b>Complexity</b>: Linear to the number of elements in the container.
  950. friend bool operator<=(const flat_set& x, const flat_set& y);
  951. //! <b>Effects</b>: Returns true if x is equal or greater than y
  952. //!
  953. //! <b>Complexity</b>: Linear to the number of elements in the container.
  954. friend bool operator>=(const flat_set& x, const flat_set& y);
  955. //! <b>Effects</b>: x.swap(y)
  956. //!
  957. //! <b>Complexity</b>: Constant.
  958. friend void swap(flat_set& x, flat_set& y);
  959. //! <b>Effects</b>: Extracts the internal sequence container.
  960. //!
  961. //! <b>Complexity</b>: Same as the move constructor of sequence_type, usually constant.
  962. //!
  963. //! <b>Postcondition</b>: this->empty()
  964. //!
  965. //! <b>Throws</b>: If secuence_type's move constructor throws
  966. sequence_type extract_sequence();
  967. #endif //#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  968. //! <b>Effects</b>: Discards the internally hold sequence container and adopts the
  969. //! one passed externally using the move assignment. Erases non-unique elements.
  970. //!
  971. //! <b>Complexity</b>: Assuming O(1) move assignment, O(NlogN) with N = seq.size()
  972. //!
  973. //! <b>Throws</b>: If the comparison or the move constructor throws
  974. BOOST_CONTAINER_FORCEINLINE void adopt_sequence(BOOST_RV_REF(sequence_type) seq)
  975. { this->tree_t::adopt_sequence_unique(boost::move(seq)); }
  976. //! <b>Requires</b>: seq shall be ordered according to this->compare()
  977. //! and shall contain unique elements.
  978. //!
  979. //! <b>Effects</b>: Discards the internally hold sequence container and adopts the
  980. //! one passed externally using the move assignment.
  981. //!
  982. //! <b>Complexity</b>: Assuming O(1) move assignment, O(1)
  983. //!
  984. //! <b>Throws</b>: If the move assignment throws
  985. BOOST_CONTAINER_FORCEINLINE void adopt_sequence(ordered_unique_range_t, BOOST_RV_REF(sequence_type) seq)
  986. { this->tree_t::adopt_sequence_unique(ordered_unique_range_t(), boost::move(seq)); }
  987. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  988. private:
  989. template<class KeyType>
  990. BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> priv_insert(BOOST_FWD_REF(KeyType) x)
  991. { return this->tree_t::insert_unique(::boost::forward<KeyType>(x)); }
  992. template<class KeyType>
  993. BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
  994. { return this->tree_t::insert_unique(p, ::boost::forward<KeyType>(x)); }
  995. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  996. };
  997. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  998. template <typename InputIterator>
  999. flat_set(InputIterator, InputIterator) ->
  1000. flat_set< it_based_value_type_t<InputIterator> >;
  1001. template < typename InputIterator, typename AllocatorOrCompare>
  1002. flat_set(InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1003. flat_set< it_based_value_type_t<InputIterator>
  1004. , typename dtl::if_c< // Compare
  1005. dtl::is_allocator<AllocatorOrCompare>::value
  1006. , std::less<it_based_value_type_t<InputIterator>>
  1007. , AllocatorOrCompare
  1008. >::type
  1009. , typename dtl::if_c< // Allocator
  1010. dtl::is_allocator<AllocatorOrCompare>::value
  1011. , AllocatorOrCompare
  1012. , new_allocator<it_based_value_type_t<InputIterator>>
  1013. >::type
  1014. >;
  1015. template < typename InputIterator, typename Compare, typename Allocator
  1016. , typename = dtl::require_nonallocator_t<Compare>
  1017. , typename = dtl::require_allocator_t<Allocator>>
  1018. flat_set(InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1019. flat_set< it_based_value_type_t<InputIterator>
  1020. , Compare
  1021. , Allocator>;
  1022. template <typename InputIterator>
  1023. flat_set(ordered_unique_range_t, InputIterator, InputIterator) ->
  1024. flat_set< it_based_value_type_t<InputIterator>>;
  1025. template < typename InputIterator, typename AllocatorOrCompare>
  1026. flat_set(ordered_unique_range_t, InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1027. flat_set< it_based_value_type_t<InputIterator>
  1028. , typename dtl::if_c< // Compare
  1029. dtl::is_allocator<AllocatorOrCompare>::value
  1030. , std::less<it_based_value_type_t<InputIterator>>
  1031. , AllocatorOrCompare
  1032. >::type
  1033. , typename dtl::if_c< // Allocator
  1034. dtl::is_allocator<AllocatorOrCompare>::value
  1035. , AllocatorOrCompare
  1036. , new_allocator<it_based_value_type_t<InputIterator>>
  1037. >::type
  1038. >;
  1039. template < typename InputIterator, typename Compare, typename Allocator
  1040. , typename = dtl::require_nonallocator_t<Compare>
  1041. , typename = dtl::require_allocator_t<Allocator>>
  1042. flat_set(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1043. flat_set< it_based_value_type_t<InputIterator>
  1044. , Compare
  1045. , Allocator>;
  1046. #endif
  1047. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1048. } //namespace container {
  1049. //!has_trivial_destructor_after_move<> == true_type
  1050. //!specialization for optimizations
  1051. template <class Key, class Compare, class AllocatorOrContainer>
  1052. struct has_trivial_destructor_after_move<boost::container::flat_set<Key, Compare, AllocatorOrContainer> >
  1053. {
  1054. typedef typename ::boost::container::allocator_traits<AllocatorOrContainer>::pointer pointer;
  1055. static const bool value = ::boost::has_trivial_destructor_after_move<AllocatorOrContainer>::value &&
  1056. ::boost::has_trivial_destructor_after_move<pointer>::value &&
  1057. ::boost::has_trivial_destructor_after_move<Compare>::value;
  1058. };
  1059. namespace container {
  1060. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1061. //! flat_multiset is a Sorted Associative Container that stores objects of type Key and
  1062. //! can store multiple copies of the same key value.
  1063. //!
  1064. //! flat_multiset is similar to std::multiset but it's implemented by as an ordered sequence container.
  1065. //! The underlying sequence container is by default <i>vector</i> but it can also work
  1066. //! user-provided vector-like SequenceContainers (like <i>static_vector</i> or <i>small_vector</i>).
  1067. //!
  1068. //! Using vector-like sequence containers means that inserting a new element into a flat_multiset might invalidate
  1069. //! previous iterators and references (unless that sequence container is <i>stable_vector</i> or a similar
  1070. //! container that offers stable pointers and references). Similarly, erasing an element might invalidate
  1071. //! iterators and references pointing to elements that come after (their keys are bigger) the erased element.
  1072. //!
  1073. //! This container provides random-access iterators.
  1074. //!
  1075. //! \tparam Key is the type to be inserted in the multiset, which is also the key_type
  1076. //! \tparam Compare is the comparison functor used to order keys
  1077. //! \tparam AllocatorOrContainer is either:
  1078. //! - The allocator to allocate <code>value_type</code>s (e.g. <i>allocator< std::pair<Key, T> > </i>).
  1079. //! (in this case <i>sequence_type</i> will be vector<value_type, AllocatorOrContainer>)
  1080. //! - The SequenceContainer to be used as the underlying <i>sequence_type</i>. It must be a vector-like
  1081. //! sequence container with random-access iterators.
  1082. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  1083. template <class Key, class Compare = std::less<Key>, class AllocatorOrContainer = new_allocator<Key> >
  1084. #else
  1085. template <class Key, class Compare, class AllocatorOrContainer>
  1086. #endif
  1087. class flat_multiset
  1088. ///@cond
  1089. : public dtl::flat_tree<Key, dtl::identity<Key>, Compare, AllocatorOrContainer>
  1090. ///@endcond
  1091. {
  1092. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1093. private:
  1094. BOOST_COPYABLE_AND_MOVABLE(flat_multiset)
  1095. typedef dtl::flat_tree<Key, dtl::identity<Key>, Compare, AllocatorOrContainer> tree_t;
  1096. public:
  1097. tree_t &tree()
  1098. { return *this; }
  1099. const tree_t &tree() const
  1100. { return *this; }
  1101. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1102. public:
  1103. //////////////////////////////////////////////
  1104. //
  1105. // types
  1106. //
  1107. //////////////////////////////////////////////
  1108. typedef Key key_type;
  1109. typedef Compare key_compare;
  1110. typedef Key value_type;
  1111. typedef typename BOOST_CONTAINER_IMPDEF(tree_t::sequence_type) sequence_type;
  1112. typedef typename sequence_type::allocator_type allocator_type;
  1113. typedef ::boost::container::allocator_traits<allocator_type> allocator_traits_type;
  1114. typedef typename sequence_type::pointer pointer;
  1115. typedef typename sequence_type::const_pointer const_pointer;
  1116. typedef typename sequence_type::reference reference;
  1117. typedef typename sequence_type::const_reference const_reference;
  1118. typedef typename sequence_type::size_type size_type;
  1119. typedef typename sequence_type::difference_type difference_type;
  1120. typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type) stored_allocator_type;
  1121. typedef typename BOOST_CONTAINER_IMPDEF(tree_t::value_compare) value_compare;
  1122. typedef typename sequence_type::iterator iterator;
  1123. typedef typename sequence_type::const_iterator const_iterator;
  1124. typedef typename sequence_type::reverse_iterator reverse_iterator;
  1125. typedef typename sequence_type::const_reverse_iterator const_reverse_iterator;
  1126. //! @copydoc ::boost::container::flat_set::flat_set()
  1127. BOOST_CONTAINER_FORCEINLINE flat_multiset() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<AllocatorOrContainer>::value &&
  1128. dtl::is_nothrow_default_constructible<Compare>::value)
  1129. : tree_t()
  1130. {}
  1131. //! @copydoc ::boost::container::flat_set::flat_set(const Compare&)
  1132. BOOST_CONTAINER_FORCEINLINE explicit flat_multiset(const Compare& comp)
  1133. : tree_t(comp)
  1134. {}
  1135. //! @copydoc ::boost::container::flat_set::flat_set(const allocator_type&)
  1136. BOOST_CONTAINER_FORCEINLINE explicit flat_multiset(const allocator_type& a)
  1137. : tree_t(a)
  1138. {}
  1139. //! @copydoc ::boost::container::flat_set::flat_set(const Compare&, const allocator_type&)
  1140. BOOST_CONTAINER_FORCEINLINE flat_multiset(const Compare& comp, const allocator_type& a)
  1141. : tree_t(comp, a)
  1142. {}
  1143. //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator)
  1144. template <class InputIterator>
  1145. BOOST_CONTAINER_FORCEINLINE flat_multiset(InputIterator first, InputIterator last)
  1146. : tree_t(false, first, last)
  1147. {}
  1148. //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator, const allocator_type&)
  1149. template <class InputIterator>
  1150. BOOST_CONTAINER_FORCEINLINE flat_multiset(InputIterator first, InputIterator last, const allocator_type& a)
  1151. : tree_t(false, first, last, a)
  1152. {}
  1153. //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator, const Compare& comp)
  1154. template <class InputIterator>
  1155. BOOST_CONTAINER_FORCEINLINE flat_multiset(InputIterator first, InputIterator last, const Compare& comp)
  1156. : tree_t(false, first, last, comp)
  1157. {}
  1158. //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator, const Compare& comp, const allocator_type&)
  1159. template <class InputIterator>
  1160. BOOST_CONTAINER_FORCEINLINE flat_multiset(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  1161. : tree_t(false, first, last, comp, a)
  1162. {}
  1163. //! <b>Effects</b>: Constructs an empty flat_multiset and
  1164. //! inserts elements from the ordered range [first ,last ). This function
  1165. //! is more efficient than the normal range creation for ordered ranges.
  1166. //!
  1167. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1168. //!
  1169. //! <b>Complexity</b>: Linear in N.
  1170. //!
  1171. //! <b>Note</b>: Non-standard extension.
  1172. template <class InputIterator>
  1173. BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, InputIterator first, InputIterator last)
  1174. : tree_t(ordered_range, first, last)
  1175. {}
  1176. //! <b>Effects</b>: Constructs an empty flat_multiset using the specified comparison object and
  1177. //! inserts elements from the ordered range [first ,last ). This function
  1178. //! is more efficient than the normal range creation for ordered ranges.
  1179. //!
  1180. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1181. //!
  1182. //! <b>Complexity</b>: Linear in N.
  1183. //!
  1184. //! <b>Note</b>: Non-standard extension.
  1185. template <class InputIterator>
  1186. BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp)
  1187. : tree_t(ordered_range, first, last, comp)
  1188. {}
  1189. //! <b>Effects</b>: Constructs an empty flat_multiset using the specified comparison object and
  1190. //! allocator, and inserts elements from the ordered range [first, last ). This function
  1191. //! is more efficient than the normal range creation for ordered ranges.
  1192. //!
  1193. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1194. //!
  1195. //! <b>Complexity</b>: Linear in N.
  1196. //!
  1197. //! <b>Note</b>: Non-standard extension.
  1198. template <class InputIterator>
  1199. BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  1200. : tree_t(ordered_range, first, last, comp, a)
  1201. {}
  1202. //! <b>Effects</b>: Constructs an empty flat_multiset using the specified allocator and
  1203. //! inserts elements from the ordered range [first ,last ). This function
  1204. //! is more efficient than the normal range creation for ordered ranges.
  1205. //!
  1206. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1207. //!
  1208. //! <b>Complexity</b>: Linear in N.
  1209. //!
  1210. //! <b>Note</b>: Non-standard extension.
  1211. template <class InputIterator>
  1212. BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, InputIterator first, InputIterator last, const allocator_type &a)
  1213. : tree_t(ordered_range, first, last, Compare(), a)
  1214. {}
  1215. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1216. //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list<value_type)
  1217. BOOST_CONTAINER_FORCEINLINE flat_multiset(std::initializer_list<value_type> il)
  1218. : tree_t(false, il.begin(), il.end())
  1219. {}
  1220. //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list<value_type>, const allocator_type&)
  1221. BOOST_CONTAINER_FORCEINLINE flat_multiset(std::initializer_list<value_type> il, const allocator_type& a)
  1222. : tree_t(false, il.begin(), il.end(), a)
  1223. {}
  1224. //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list<value_type>, const Compare& comp)
  1225. BOOST_CONTAINER_FORCEINLINE flat_multiset(std::initializer_list<value_type> il, const Compare& comp)
  1226. : tree_t(false, il.begin(), il.end(), comp)
  1227. {}
  1228. //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list<value_type>, const Compare& comp, const allocator_type&)
  1229. BOOST_CONTAINER_FORCEINLINE flat_multiset(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  1230. : tree_t(false, il.begin(), il.end(), comp, a)
  1231. {}
  1232. //! <b>Effects</b>: Constructs an empty containerand
  1233. //! inserts elements from the ordered unique range [il.begin(), il.end()). This function
  1234. //! is more efficient than the normal range creation for ordered ranges.
  1235. //!
  1236. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
  1237. //!
  1238. //! <b>Complexity</b>: Linear in N.
  1239. //!
  1240. //! <b>Note</b>: Non-standard extension.
  1241. BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, std::initializer_list<value_type> il)
  1242. : tree_t(ordered_range, il.begin(), il.end())
  1243. {}
  1244. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  1245. //! inserts elements from the ordered unique range [il.begin(), il.end()). This function
  1246. //! is more efficient than the normal range creation for ordered ranges.
  1247. //!
  1248. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
  1249. //!
  1250. //! <b>Complexity</b>: Linear in N.
  1251. //!
  1252. //! <b>Note</b>: Non-standard extension.
  1253. BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp)
  1254. : tree_t(ordered_range, il.begin(), il.end(), comp)
  1255. {}
  1256. //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
  1257. //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function
  1258. //! is more efficient than the normal range creation for ordered ranges.
  1259. //!
  1260. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
  1261. //!
  1262. //! <b>Complexity</b>: Linear in N.
  1263. //!
  1264. //! <b>Note</b>: Non-standard extension.
  1265. BOOST_CONTAINER_FORCEINLINE flat_multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  1266. : tree_t(ordered_range, il.begin(), il.end(), comp, a)
  1267. {}
  1268. #endif
  1269. //! @copydoc ::boost::container::flat_set::flat_set(const flat_set &)
  1270. BOOST_CONTAINER_FORCEINLINE flat_multiset(const flat_multiset& x)
  1271. : tree_t(static_cast<const tree_t&>(x))
  1272. {}
  1273. //! @copydoc ::boost::container::flat_set::flat_set(flat_set &&)
  1274. BOOST_CONTAINER_FORCEINLINE flat_multiset(BOOST_RV_REF(flat_multiset) x)
  1275. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value)
  1276. : tree_t(boost::move(static_cast<tree_t&>(x)))
  1277. {}
  1278. //! @copydoc ::boost::container::flat_set::flat_set(const flat_set &, const allocator_type &)
  1279. BOOST_CONTAINER_FORCEINLINE flat_multiset(const flat_multiset& x, const allocator_type &a)
  1280. : tree_t(static_cast<const tree_t&>(x), a)
  1281. {}
  1282. //! @copydoc ::boost::container::flat_set::flat_set(flat_set &&, const allocator_type &)
  1283. BOOST_CONTAINER_FORCEINLINE flat_multiset(BOOST_RV_REF(flat_multiset) x, const allocator_type &a)
  1284. : tree_t(BOOST_MOVE_BASE(tree_t, x), a)
  1285. {}
  1286. //! @copydoc ::boost::container::flat_set::operator=(const flat_set &)
  1287. BOOST_CONTAINER_FORCEINLINE flat_multiset& operator=(BOOST_COPY_ASSIGN_REF(flat_multiset) x)
  1288. { return static_cast<flat_multiset&>(this->tree_t::operator=(static_cast<const tree_t&>(x))); }
  1289. //! @copydoc ::boost::container::flat_set::operator=(flat_set &&)
  1290. BOOST_CONTAINER_FORCEINLINE flat_multiset& operator=(BOOST_RV_REF(flat_multiset) x)
  1291. BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
  1292. allocator_traits_type::is_always_equal::value) &&
  1293. boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
  1294. { return static_cast<flat_multiset&>(this->tree_t::operator=(BOOST_MOVE_BASE(tree_t, x))); }
  1295. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1296. //! @copydoc ::boost::container::flat_set::operator=(std::initializer_list<value_type>)
  1297. flat_multiset& operator=(std::initializer_list<value_type> il)
  1298. {
  1299. this->clear();
  1300. this->insert(il.begin(), il.end());
  1301. return *this;
  1302. }
  1303. #endif
  1304. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1305. //! @copydoc ::boost::container::flat_set::get_allocator()
  1306. allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
  1307. //! @copydoc ::boost::container::flat_set::get_stored_allocator()
  1308. stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW;
  1309. //! @copydoc ::boost::container::flat_set::get_stored_allocator() const
  1310. const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
  1311. //! @copydoc ::boost::container::flat_set::begin()
  1312. iterator begin() BOOST_NOEXCEPT_OR_NOTHROW;
  1313. //! @copydoc ::boost::container::flat_set::begin() const
  1314. const_iterator begin() const;
  1315. //! @copydoc ::boost::container::flat_set::cbegin() const
  1316. const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  1317. //! @copydoc ::boost::container::flat_set::end()
  1318. iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
  1319. //! @copydoc ::boost::container::flat_set::end() const
  1320. const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
  1321. //! @copydoc ::boost::container::flat_set::cend() const
  1322. const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1323. //! @copydoc ::boost::container::flat_set::rbegin()
  1324. reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
  1325. //! @copydoc ::boost::container::flat_set::rbegin() const
  1326. const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  1327. //! @copydoc ::boost::container::flat_set::crbegin() const
  1328. const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  1329. //! @copydoc ::boost::container::flat_set::rend()
  1330. reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
  1331. //! @copydoc ::boost::container::flat_set::rend() const
  1332. const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1333. //! @copydoc ::boost::container::flat_set::crend() const
  1334. const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1335. //! @copydoc ::boost::container::flat_set::empty() const
  1336. bool empty() const BOOST_NOEXCEPT_OR_NOTHROW;
  1337. //! @copydoc ::boost::container::flat_set::size() const
  1338. size_type size() const BOOST_NOEXCEPT_OR_NOTHROW;
  1339. //! @copydoc ::boost::container::flat_set::max_size() const
  1340. size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW;
  1341. //! @copydoc ::boost::container::flat_set::capacity() const
  1342. size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW;
  1343. //! @copydoc ::boost::container::flat_set::reserve(size_type)
  1344. void reserve(size_type cnt);
  1345. //! @copydoc ::boost::container::flat_set::shrink_to_fit()
  1346. void shrink_to_fit();
  1347. #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1348. //////////////////////////////////////////////
  1349. //
  1350. // modifiers
  1351. //
  1352. //////////////////////////////////////////////
  1353. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1354. //! <b>Effects</b>: Inserts an object of type Key constructed with
  1355. //! std::forward<Args>(args)... and returns the iterator pointing to the
  1356. //! newly inserted element.
  1357. //!
  1358. //! <b>Complexity</b>: Logarithmic search time plus linear insertion
  1359. //! to the elements with bigger keys than x.
  1360. //!
  1361. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  1362. template <class... Args>
  1363. BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_FWD_REF(Args)... args)
  1364. { return this->tree_t::emplace_equal(boost::forward<Args>(args)...); }
  1365. //! <b>Effects</b>: Inserts an object of type Key constructed with
  1366. //! std::forward<Args>(args)... in the container.
  1367. //! p is a hint pointing to where the insert should start to search.
  1368. //!
  1369. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1370. //! to the key of x.
  1371. //!
  1372. //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
  1373. //! right before p) plus insertion linear to the elements with bigger keys than x.
  1374. //!
  1375. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  1376. template <class... Args>
  1377. BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
  1378. { return this->tree_t::emplace_hint_equal(p, boost::forward<Args>(args)...); }
  1379. #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  1380. #define BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE(N) \
  1381. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  1382. BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_MOVE_UREF##N)\
  1383. { return this->tree_t::emplace_equal(BOOST_MOVE_FWD##N); }\
  1384. \
  1385. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  1386. BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  1387. { return this->tree_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  1388. //
  1389. BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE)
  1390. #undef BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE
  1391. #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  1392. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1393. //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
  1394. //! newly inserted element.
  1395. //!
  1396. //! <b>Complexity</b>: Logarithmic search time plus linear insertion
  1397. //! to the elements with bigger keys than x.
  1398. //!
  1399. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  1400. iterator insert(const value_type &x);
  1401. //! <b>Effects</b>: Inserts a new value_type move constructed from x
  1402. //! and returns the iterator pointing to the newly inserted element.
  1403. //!
  1404. //! <b>Complexity</b>: Logarithmic search time plus linear insertion
  1405. //! to the elements with bigger keys than x.
  1406. //!
  1407. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  1408. iterator insert(value_type &&x);
  1409. #else
  1410. BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert)
  1411. #endif
  1412. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1413. //! <b>Effects</b>: Inserts a copy of x in the container.
  1414. //! p is a hint pointing to where the insert should start to search.
  1415. //!
  1416. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1417. //! to the key of x.
  1418. //!
  1419. //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
  1420. //! right before p) plus insertion linear to the elements with bigger keys than x.
  1421. //!
  1422. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  1423. iterator insert(const_iterator p, const value_type &x);
  1424. //! <b>Effects</b>: Inserts a new value move constructed from x in the container.
  1425. //! p is a hint pointing to where the insert should start to search.
  1426. //!
  1427. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1428. //! to the key of x.
  1429. //!
  1430. //! <b>Complexity</b>: Logarithmic search time (constant if x is inserted
  1431. //! right before p) plus insertion linear to the elements with bigger keys than x.
  1432. //!
  1433. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  1434. iterator insert(const_iterator p, value_type &&x);
  1435. #else
  1436. BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator)
  1437. #endif
  1438. //! <b>Requires</b>: first, last are not iterators into *this.
  1439. //!
  1440. //! <b>Effects</b>: inserts each element from the range [first,last) .
  1441. //!
  1442. //! <b>Complexity</b>: N log(N).
  1443. //!
  1444. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  1445. template <class InputIterator>
  1446. BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last)
  1447. { this->tree_t::insert_equal(first, last); }
  1448. //! <b>Requires</b>: first, last are not iterators into *this and
  1449. //! must be ordered according to the predicate.
  1450. //!
  1451. //! <b>Effects</b>: inserts each element from the range [first,last) .This function
  1452. //! is more efficient than the normal range creation for ordered ranges.
  1453. //!
  1454. //! <b>Complexity</b>: Linear.
  1455. //!
  1456. //! <b>Note</b>: Non-standard extension. If an element is inserted it might invalidate elements.
  1457. template <class InputIterator>
  1458. BOOST_CONTAINER_FORCEINLINE void insert(ordered_range_t, InputIterator first, InputIterator last)
  1459. { this->tree_t::insert_equal(ordered_range, first, last); }
  1460. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1461. //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end()).
  1462. //!
  1463. //! <b>Complexity</b>: N log(N).
  1464. //!
  1465. //! <b>Note</b>: If an element is inserted it might invalidate elements.
  1466. BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list<value_type> il)
  1467. { this->tree_t::insert_equal(il.begin(), il.end()); }
  1468. //! <b>Requires</b>: Range [il.begin(), il.end()) must be ordered according to the predicate.
  1469. //!
  1470. //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end()). This function
  1471. //! is more efficient than the normal range creation for ordered ranges.
  1472. //!
  1473. //! <b>Complexity</b>: Linear.
  1474. //!
  1475. //! <b>Note</b>: Non-standard extension. If an element is inserted it might invalidate elements.
  1476. BOOST_CONTAINER_FORCEINLINE void insert(ordered_range_t, std::initializer_list<value_type> il)
  1477. { this->tree_t::insert_equal(ordered_range, il.begin(), il.end()); }
  1478. #endif
  1479. //! @copydoc ::boost::container::flat_multimap::merge(flat_multimap<Key, T, C2, AllocatorOrContainer>&)
  1480. template<class C2>
  1481. BOOST_CONTAINER_FORCEINLINE void merge(flat_multiset<Key, C2, AllocatorOrContainer>& source)
  1482. { this->tree_t::merge_equal(source.tree()); }
  1483. //! @copydoc ::boost::container::flat_multiset::merge(flat_multiset<Key, C2, AllocatorOrContainer>&)
  1484. template<class C2>
  1485. BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG flat_multiset<Key, C2, AllocatorOrContainer> BOOST_RV_REF_END source)
  1486. { return this->merge(static_cast<flat_multiset<Key, C2, AllocatorOrContainer>&>(source)); }
  1487. //! @copydoc ::boost::container::flat_multimap::merge(flat_map<Key, T, C2, AllocatorOrContainer>&)
  1488. template<class C2>
  1489. BOOST_CONTAINER_FORCEINLINE void merge(flat_set<Key, C2, AllocatorOrContainer>& source)
  1490. { this->tree_t::merge_equal(source.tree()); }
  1491. //! @copydoc ::boost::container::flat_multiset::merge(flat_set<Key, C2, AllocatorOrContainer>&)
  1492. template<class C2>
  1493. BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG flat_set<Key, C2, AllocatorOrContainer> BOOST_RV_REF_END source)
  1494. { return this->merge(static_cast<flat_set<Key, C2, AllocatorOrContainer>&>(source)); }
  1495. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1496. //! @copydoc ::boost::container::flat_set::erase(const_iterator)
  1497. iterator erase(const_iterator p);
  1498. //! @copydoc ::boost::container::flat_set::erase(const key_type&)
  1499. size_type erase(const key_type& x);
  1500. //! @copydoc ::boost::container::flat_set::erase(const_iterator,const_iterator)
  1501. iterator erase(const_iterator first, const_iterator last);
  1502. //! @copydoc ::boost::container::flat_set::swap
  1503. void swap(flat_multiset& x)
  1504. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1505. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1506. //! @copydoc ::boost::container::flat_set::clear
  1507. void clear() BOOST_NOEXCEPT_OR_NOTHROW;
  1508. //! @copydoc ::boost::container::flat_set::key_comp
  1509. key_compare key_comp() const;
  1510. //! @copydoc ::boost::container::flat_set::value_comp
  1511. value_compare value_comp() const;
  1512. //! @copydoc ::boost::container::flat_set::find(const key_type& )
  1513. iterator find(const key_type& x);
  1514. //! @copydoc ::boost::container::flat_set::find(const key_type& ) const
  1515. const_iterator find(const key_type& x) const;
  1516. //! @copydoc ::boost::container::flat_set::nth(size_type)
  1517. iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW;
  1518. //! @copydoc ::boost::container::flat_set::nth(size_type) const
  1519. const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW;
  1520. //! @copydoc ::boost::container::flat_set::index_of(iterator)
  1521. size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW;
  1522. //! @copydoc ::boost::container::flat_set::index_of(const_iterator) const
  1523. size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW;
  1524. //! @copydoc ::boost::container::flat_set::count(const key_type& ) const
  1525. size_type count(const key_type& x) const;
  1526. //! @copydoc ::boost::container::flat_set::contains(const key_type& ) const
  1527. bool contains(const key_type& x) const;
  1528. //! @copydoc ::boost::container::flat_set::contains(const K& ) const
  1529. template<typename K>
  1530. bool contains(const K& x) const;
  1531. //! @copydoc ::boost::container::flat_set::lower_bound(const key_type& )
  1532. iterator lower_bound(const key_type& x);
  1533. //! @copydoc ::boost::container::flat_set::lower_bound(const key_type& ) const
  1534. const_iterator lower_bound(const key_type& x) const;
  1535. //! @copydoc ::boost::container::flat_set::upper_bound(const key_type& )
  1536. iterator upper_bound(const key_type& x);
  1537. //! @copydoc ::boost::container::flat_set::upper_bound(const key_type& ) const
  1538. const_iterator upper_bound(const key_type& x) const;
  1539. //! @copydoc ::boost::container::flat_set::equal_range(const key_type& ) const
  1540. std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
  1541. //! @copydoc ::boost::container::flat_set::equal_range(const key_type& )
  1542. std::pair<iterator,iterator> equal_range(const key_type& x);
  1543. //! <b>Effects</b>: Returns true if x and y are equal
  1544. //!
  1545. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1546. friend bool operator==(const flat_multiset& x, const flat_multiset& y);
  1547. //! <b>Effects</b>: Returns true if x and y are unequal
  1548. //!
  1549. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1550. friend bool operator!=(const flat_multiset& x, const flat_multiset& y);
  1551. //! <b>Effects</b>: Returns true if x is less than y
  1552. //!
  1553. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1554. friend bool operator<(const flat_multiset& x, const flat_multiset& y);
  1555. //! <b>Effects</b>: Returns true if x is greater than y
  1556. //!
  1557. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1558. friend bool operator>(const flat_multiset& x, const flat_multiset& y);
  1559. //! <b>Effects</b>: Returns true if x is equal or less than y
  1560. //!
  1561. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1562. friend bool operator<=(const flat_multiset& x, const flat_multiset& y);
  1563. //! <b>Effects</b>: Returns true if x is equal or greater than y
  1564. //!
  1565. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1566. friend bool operator>=(const flat_multiset& x, const flat_multiset& y);
  1567. //! <b>Effects</b>: x.swap(y)
  1568. //!
  1569. //! <b>Complexity</b>: Constant.
  1570. friend void swap(flat_multiset& x, flat_multiset& y);
  1571. //! <b>Effects</b>: Extracts the internal sequence container.
  1572. //!
  1573. //! <b>Complexity</b>: Same as the move constructor of sequence_type, usually constant.
  1574. //!
  1575. //! <b>Postcondition</b>: this->empty()
  1576. //!
  1577. //! <b>Throws</b>: If secuence_type's move constructor throws
  1578. sequence_type extract_sequence();
  1579. #endif //#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  1580. //! <b>Effects</b>: Discards the internally hold sequence container and adopts the
  1581. //! one passed externally using the move assignment.
  1582. //!
  1583. //! <b>Complexity</b>: Assuming O(1) move assignment, O(NlogN) with N = seq.size()
  1584. //!
  1585. //! <b>Throws</b>: If the comparison or the move constructor throws
  1586. BOOST_CONTAINER_FORCEINLINE void adopt_sequence(BOOST_RV_REF(sequence_type) seq)
  1587. { this->tree_t::adopt_sequence_equal(boost::move(seq)); }
  1588. //! <b>Requires</b>: seq shall be ordered according to this->compare()
  1589. //!
  1590. //! <b>Effects</b>: Discards the internally hold sequence container and adopts the
  1591. //! one passed externally using the move assignment.
  1592. //!
  1593. //! <b>Complexity</b>: Assuming O(1) move assignment, O(1)
  1594. //!
  1595. //! <b>Throws</b>: If the move assignment throws
  1596. BOOST_CONTAINER_FORCEINLINE void adopt_sequence(ordered_range_t, BOOST_RV_REF(sequence_type) seq)
  1597. { this->tree_t::adopt_sequence_equal(ordered_range_t(), boost::move(seq)); }
  1598. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1599. private:
  1600. template <class KeyType>
  1601. BOOST_CONTAINER_FORCEINLINE iterator priv_insert(BOOST_FWD_REF(KeyType) x)
  1602. { return this->tree_t::insert_equal(::boost::forward<KeyType>(x)); }
  1603. template <class KeyType>
  1604. BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
  1605. { return this->tree_t::insert_equal(p, ::boost::forward<KeyType>(x)); }
  1606. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1607. };
  1608. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  1609. template <typename InputIterator>
  1610. flat_multiset(InputIterator, InputIterator) ->
  1611. flat_multiset< it_based_value_type_t<InputIterator> >;
  1612. template < typename InputIterator, typename AllocatorOrCompare>
  1613. flat_multiset(InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1614. flat_multiset < it_based_value_type_t<InputIterator>
  1615. , typename dtl::if_c< // Compare
  1616. dtl::is_allocator<AllocatorOrCompare>::value
  1617. , std::less<it_based_value_type_t<InputIterator>>
  1618. , AllocatorOrCompare
  1619. >::type
  1620. , typename dtl::if_c< // Allocator
  1621. dtl::is_allocator<AllocatorOrCompare>::value
  1622. , AllocatorOrCompare
  1623. , new_allocator<it_based_value_type_t<InputIterator>>
  1624. >::type
  1625. >;
  1626. template < typename InputIterator, typename Compare, typename Allocator
  1627. , typename = dtl::require_nonallocator_t<Compare>
  1628. , typename = dtl::require_allocator_t<Allocator>>
  1629. flat_multiset(InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1630. flat_multiset< it_based_value_type_t<InputIterator>
  1631. , Compare
  1632. , Allocator>;
  1633. template <typename InputIterator>
  1634. flat_multiset(ordered_range_t, InputIterator, InputIterator) ->
  1635. flat_multiset< it_based_value_type_t<InputIterator>>;
  1636. template < typename InputIterator, typename AllocatorOrCompare>
  1637. flat_multiset(ordered_range_t, InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1638. flat_multiset < it_based_value_type_t<InputIterator>
  1639. , typename dtl::if_c< // Compare
  1640. dtl::is_allocator<AllocatorOrCompare>::value
  1641. , std::less<it_based_value_type_t<InputIterator>>
  1642. , AllocatorOrCompare
  1643. >::type
  1644. , typename dtl::if_c< // Allocator
  1645. dtl::is_allocator<AllocatorOrCompare>::value
  1646. , AllocatorOrCompare
  1647. , new_allocator<it_based_value_type_t<InputIterator>>
  1648. >::type
  1649. >;
  1650. template < typename InputIterator, typename Compare, typename Allocator
  1651. , typename = dtl::require_nonallocator_t<Compare>
  1652. , typename = dtl::require_allocator_t<Allocator>>
  1653. flat_multiset(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1654. flat_multiset< it_based_value_type_t<InputIterator>
  1655. , Compare
  1656. , Allocator>;
  1657. #endif
  1658. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1659. } //namespace container {
  1660. //!has_trivial_destructor_after_move<> == true_type
  1661. //!specialization for optimizations
  1662. template <class Key, class Compare, class AllocatorOrContainer>
  1663. struct has_trivial_destructor_after_move<boost::container::flat_multiset<Key, Compare, AllocatorOrContainer> >
  1664. {
  1665. typedef typename ::boost::container::allocator_traits<AllocatorOrContainer>::pointer pointer;
  1666. static const bool value = ::boost::has_trivial_destructor_after_move<AllocatorOrContainer>::value &&
  1667. ::boost::has_trivial_destructor_after_move<pointer>::value &&
  1668. ::boost::has_trivial_destructor_after_move<Compare>::value;
  1669. };
  1670. namespace container {
  1671. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1672. }}
  1673. #include <boost/container/detail/config_end.hpp>
  1674. #endif // BOOST_CONTAINER_FLAT_SET_HPP