flat_set.hpp 83 KB

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