flat_set.hpp 82 KB

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