flat_set.hpp 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966
  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