flat_set.hpp 82 KB

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