set.hpp 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692
  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_SET_HPP
  11. #define BOOST_CONTAINER_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/container_fwd.hpp>
  22. // container/detail
  23. #include <boost/container/detail/mpl.hpp>
  24. #include <boost/container/detail/tree.hpp>
  25. #include <boost/container/new_allocator.hpp> //new_allocator
  26. // intrusive/detail
  27. #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
  28. #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
  29. // move
  30. #include <boost/move/traits.hpp>
  31. #include <boost/move/utility_core.hpp>
  32. // move/detail
  33. #include <boost/move/detail/move_helpers.hpp>
  34. #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  35. #include <boost/move/detail/fwd_macros.hpp>
  36. #endif
  37. // std
  38. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  39. #include <initializer_list>
  40. #endif
  41. namespace boost {
  42. namespace container {
  43. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  44. //! A set is a kind of associative container that supports unique keys (contains at
  45. //! most one of each key value) and provides for fast retrieval of the keys themselves.
  46. //! Class set supports bidirectional iterators.
  47. //!
  48. //! A set satisfies all of the requirements of a container and of a reversible container
  49. //! , and of an associative container. A set also provides most operations described in
  50. //! for unique keys.
  51. //!
  52. //! \tparam Key is the type to be inserted in the set, which is also the key_type
  53. //! \tparam Compare is the comparison functor used to order keys
  54. //! \tparam Allocator is the allocator to be used to allocate memory for this container
  55. //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options.
  56. template <class Key, class Compare = std::less<Key>, class Allocator = new_allocator<Key>, class Options = void>
  57. #else
  58. template <class Key, class Compare, class Allocator, class Options>
  59. #endif
  60. class set
  61. ///@cond
  62. : public dtl::tree
  63. < Key, void, Compare, Allocator, Options>
  64. ///@endcond
  65. {
  66. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  67. private:
  68. BOOST_COPYABLE_AND_MOVABLE(set)
  69. typedef dtl::tree
  70. < Key, void, Compare, Allocator, Options> base_t;
  71. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  72. public:
  73. //////////////////////////////////////////////
  74. //
  75. // types
  76. //
  77. //////////////////////////////////////////////
  78. typedef Key key_type;
  79. typedef Key value_type;
  80. typedef Compare key_compare;
  81. typedef key_compare value_compare;
  82. typedef typename base_t::allocator_type allocator_type;
  83. typedef ::boost::container::allocator_traits<allocator_type> allocator_traits_type;
  84. typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
  85. typedef typename ::boost::container::allocator_traits<allocator_type>::const_pointer const_pointer;
  86. typedef typename ::boost::container::allocator_traits<allocator_type>::reference reference;
  87. typedef typename ::boost::container::allocator_traits<allocator_type>::const_reference const_reference;
  88. typedef typename ::boost::container::allocator_traits<allocator_type>::size_type size_type;
  89. typedef typename ::boost::container::allocator_traits<allocator_type>::difference_type difference_type;
  90. typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
  91. typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
  92. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
  93. typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
  94. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
  95. typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type;
  96. typedef typename BOOST_CONTAINER_IMPDEF(base_t::insert_return_type) insert_return_type;
  97. //////////////////////////////////////////////
  98. //
  99. // construct/copy/destroy
  100. //
  101. //////////////////////////////////////////////
  102. //! <b>Effects</b>: Default constructs an empty set.
  103. //!
  104. //! <b>Complexity</b>: Constant.
  105. BOOST_CONTAINER_FORCEINLINE set()
  106. BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<allocator_type>::value &&
  107. dtl::is_nothrow_default_constructible<Compare>::value)
  108. : base_t()
  109. {}
  110. //! <b>Effects</b>: Constructs an empty set using the specified allocator object.
  111. //!
  112. //! <b>Complexity</b>: Constant.
  113. BOOST_CONTAINER_FORCEINLINE explicit set(const allocator_type& a)
  114. : base_t(a)
  115. {}
  116. //! <b>Effects</b>: Constructs an empty set using the specified comparison object.
  117. //!
  118. //! <b>Complexity</b>: Constant.
  119. BOOST_CONTAINER_FORCEINLINE explicit set(const Compare& comp)
  120. : base_t(comp)
  121. {}
  122. //! <b>Effects</b>: Constructs an empty set using the specified comparison object
  123. //! and allocator.
  124. //!
  125. //! <b>Complexity</b>: Constant.
  126. BOOST_CONTAINER_FORCEINLINE set(const Compare& comp, const allocator_type& a)
  127. : base_t(comp, a)
  128. {}
  129. //! <b>Effects</b>: Constructs an empty set using and
  130. //! inserts elements from the range [first ,last ).
  131. //!
  132. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  133. //! the predicate and otherwise N logN, where N is last - first.
  134. template <class InputIterator>
  135. BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last)
  136. : base_t(true, first, last)
  137. {}
  138. //! <b>Effects</b>: Constructs an empty set using the specified
  139. //! allocator, and inserts elements from the range [first ,last ).
  140. //!
  141. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  142. //! the predicate and otherwise N logN, where N is last - first.
  143. template <class InputIterator>
  144. BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last, const allocator_type& a)
  145. : base_t(true, first, last, key_compare(), a)
  146. {}
  147. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  148. //! inserts elements from the range [first ,last ).
  149. //!
  150. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  151. //! the predicate and otherwise N logN, where N is last - first.
  152. template <class InputIterator>
  153. BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last, const Compare& comp)
  154. : base_t(true, first, last, comp)
  155. {}
  156. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  157. //! allocator, and inserts elements from the range [first ,last ).
  158. //!
  159. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  160. //! the predicate and otherwise N logN, where N is last - first.
  161. template <class InputIterator>
  162. BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  163. : base_t(true, first, last, comp, a)
  164. {}
  165. //! <b>Effects</b>: Constructs an empty set and
  166. //! inserts elements from the ordered unique range [first ,last). This function
  167. //! is more efficient than the normal range creation for ordered ranges.
  168. //!
  169. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  170. //! unique values.
  171. //!
  172. //! <b>Complexity</b>: Linear in N.
  173. //!
  174. //! <b>Note</b>: Non-standard extension.
  175. template <class InputIterator>
  176. BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, InputIterator first, InputIterator last)
  177. : base_t(ordered_range, first, last)
  178. {}
  179. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  180. //! inserts elements from the ordered unique range [first ,last). This function
  181. //! is more efficient than the normal range creation for ordered ranges.
  182. //!
  183. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  184. //! unique values.
  185. //!
  186. //! <b>Complexity</b>: Linear in N.
  187. //!
  188. //! <b>Note</b>: Non-standard extension.
  189. template <class InputIterator>
  190. BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp )
  191. : base_t(ordered_range, first, last, comp)
  192. {}
  193. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  194. //! allocator, and inserts elements from the ordered unique range [first ,last). This function
  195. //! is more efficient than the normal range creation for ordered ranges.
  196. //!
  197. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  198. //! unique values.
  199. //!
  200. //! <b>Complexity</b>: Linear in N.
  201. //!
  202. //! <b>Note</b>: Non-standard extension.
  203. template <class InputIterator>
  204. BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, InputIterator first, InputIterator last
  205. , const Compare& comp, const allocator_type& a)
  206. : base_t(ordered_range, first, last, comp, a)
  207. {}
  208. //! <b>Effects</b>: Constructs an empty set using the specified allocator and
  209. //! inserts elements from the ordered unique range [first ,last). This function
  210. //! is more efficient than the normal range creation for ordered ranges.
  211. //!
  212. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  213. //! unique values.
  214. //!
  215. //! <b>Complexity</b>: Linear in N.
  216. //!
  217. //! <b>Note</b>: Non-standard extension.
  218. template <class InputIterator>
  219. BOOST_CONTAINER_FORCEINLINE set(ordered_unique_range_t, InputIterator first, InputIterator last, const allocator_type& a)
  220. : base_t(ordered_range, first, last, Compare(), a)
  221. {}
  222. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  223. //! <b>Effects</b>: Constructs an empty set and
  224. //! inserts elements from the range [il.begin(), il.end()).
  225. //!
  226. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  227. //! the predicate and otherwise N logN, where N is il.begin() - il.end().
  228. BOOST_CONTAINER_FORCEINLINE set(std::initializer_list<value_type> il)
  229. : base_t(true, il.begin(), il.end())
  230. {}
  231. //! <b>Effects</b>: Constructs an empty set using the specified
  232. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  233. //!
  234. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  235. //! the predicate and otherwise N logN, where N is il.begin() - il.end().
  236. BOOST_CONTAINER_FORCEINLINE set(std::initializer_list<value_type> il, const allocator_type& a)
  237. : base_t(true, il.begin(), il.end(), Compare(), a)
  238. {}
  239. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  240. //! inserts elements from the range [il.begin(), il.end()).
  241. //!
  242. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  243. //! the predicate and otherwise N logN, where N is il.begin() - il.end().
  244. BOOST_CONTAINER_FORCEINLINE set(std::initializer_list<value_type> il, const Compare& comp )
  245. : base_t(true, il.begin(), il.end(), comp)
  246. {}
  247. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  248. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  249. //!
  250. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  251. //! the predicate and otherwise N logN, where N is il.begin() - il.end().
  252. BOOST_CONTAINER_FORCEINLINE set(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  253. : base_t(true, il.begin(), il.end(), comp, a)
  254. {}
  255. //! <b>Effects</b>: Constructs an empty set and
  256. //! inserts elements from the ordered unique range [il.begin(), il.end()). This function
  257. //! is more efficient than the normal range creation for ordered ranges.
  258. //!
  259. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  260. //! unique values.
  261. //!
  262. //! <b>Complexity</b>: Linear in N.
  263. //!
  264. //! <b>Note</b>: Non-standard extension.
  265. BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, std::initializer_list<value_type> il)
  266. : base_t(ordered_range, il.begin(), il.end())
  267. {}
  268. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  269. //! inserts elements from the ordered unique range [il.begin(), il.end()). This function
  270. //! is more efficient than the normal range creation for ordered ranges.
  271. //!
  272. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  273. //! unique values.
  274. //!
  275. //! <b>Complexity</b>: Linear in N.
  276. //!
  277. //! <b>Note</b>: Non-standard extension.
  278. BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp)
  279. : base_t(ordered_range, il.begin(), il.end(), comp)
  280. {}
  281. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  282. //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function
  283. //! is more efficient than the normal range creation for ordered ranges.
  284. //!
  285. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  286. //! unique values.
  287. //!
  288. //! <b>Complexity</b>: Linear in N.
  289. //!
  290. //! <b>Note</b>: Non-standard extension.
  291. BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  292. : base_t(ordered_range, il.begin(), il.end(), comp, a)
  293. {}
  294. #endif
  295. //! <b>Effects</b>: Copy constructs a set.
  296. //!
  297. //! <b>Complexity</b>: Linear in x.size().
  298. BOOST_CONTAINER_FORCEINLINE set(const set& x)
  299. : base_t(static_cast<const base_t&>(x))
  300. {}
  301. //! <b>Effects</b>: Move constructs a set. Constructs *this using x's resources.
  302. //!
  303. //! <b>Complexity</b>: Constant.
  304. //!
  305. //! <b>Postcondition</b>: x is emptied.
  306. BOOST_CONTAINER_FORCEINLINE set(BOOST_RV_REF(set) x)
  307. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value)
  308. : base_t(BOOST_MOVE_BASE(base_t, x))
  309. {}
  310. //! <b>Effects</b>: Copy constructs a set using the specified allocator.
  311. //!
  312. //! <b>Complexity</b>: Linear in x.size().
  313. BOOST_CONTAINER_FORCEINLINE set(const set& x, const allocator_type &a)
  314. : base_t(static_cast<const base_t&>(x), a)
  315. {}
  316. //! <b>Effects</b>: Move constructs a set using the specified allocator.
  317. //! Constructs *this using x's resources.
  318. //!
  319. //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
  320. BOOST_CONTAINER_FORCEINLINE set(BOOST_RV_REF(set) x, const allocator_type &a)
  321. : base_t(BOOST_MOVE_BASE(base_t, x), a)
  322. {}
  323. //! <b>Effects</b>: Makes *this a copy of x.
  324. //!
  325. //! <b>Complexity</b>: Linear in x.size().
  326. BOOST_CONTAINER_FORCEINLINE set& operator=(BOOST_COPY_ASSIGN_REF(set) x)
  327. { return static_cast<set&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
  328. //! <b>Effects</b>: this->swap(x.get()).
  329. //!
  330. //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
  331. //! is false and (allocation throws or value_type's move constructor throws)
  332. //!
  333. //! <b>Complexity</b>: Constant if allocator_traits_type::
  334. //! propagate_on_container_move_assignment is true or
  335. //! this->get>allocator() == x.get_allocator(). Linear otherwise.
  336. BOOST_CONTAINER_FORCEINLINE set& operator=(BOOST_RV_REF(set) x)
  337. BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
  338. allocator_traits_type::is_always_equal::value) &&
  339. boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
  340. { return static_cast<set&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
  341. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  342. //! <b>Effects</b>: Copy all elements from il to *this.
  343. //!
  344. //! <b>Complexity</b>: Linear in il.size().
  345. set& operator=(std::initializer_list<value_type> il)
  346. {
  347. this->clear();
  348. insert(il.begin(), il.end());
  349. return *this;
  350. }
  351. #endif
  352. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  353. //! <b>Effects</b>: Returns a copy of the allocator that
  354. //! was passed to the object's constructor.
  355. //!
  356. //! <b>Complexity</b>: Constant.
  357. allocator_type get_allocator() const;
  358. //! <b>Effects</b>: Returns a reference to the internal allocator.
  359. //!
  360. //! <b>Throws</b>: Nothing
  361. //!
  362. //! <b>Complexity</b>: Constant.
  363. //!
  364. //! <b>Note</b>: Non-standard extension.
  365. stored_allocator_type &get_stored_allocator();
  366. //! <b>Effects</b>: Returns a reference to the internal allocator.
  367. //!
  368. //! <b>Throws</b>: Nothing
  369. //!
  370. //! <b>Complexity</b>: Constant.
  371. //!
  372. //! <b>Note</b>: Non-standard extension.
  373. const stored_allocator_type &get_stored_allocator() const;
  374. //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
  375. //!
  376. //! <b>Throws</b>: Nothing.
  377. //!
  378. //! <b>Complexity</b>: Constant
  379. iterator begin();
  380. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
  381. //!
  382. //! <b>Throws</b>: Nothing.
  383. //!
  384. //! <b>Complexity</b>: Constant.
  385. const_iterator begin() const;
  386. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
  387. //!
  388. //! <b>Throws</b>: Nothing.
  389. //!
  390. //! <b>Complexity</b>: Constant.
  391. const_iterator cbegin() const;
  392. //! <b>Effects</b>: Returns an iterator to the end of the container.
  393. //!
  394. //! <b>Throws</b>: Nothing.
  395. //!
  396. //! <b>Complexity</b>: Constant.
  397. iterator end();
  398. //! <b>Effects</b>: Returns a const_iterator to the end of the container.
  399. //!
  400. //! <b>Throws</b>: Nothing.
  401. //!
  402. //! <b>Complexity</b>: Constant.
  403. const_iterator end() const;
  404. //! <b>Effects</b>: Returns a const_iterator to the end of the container.
  405. //!
  406. //! <b>Throws</b>: Nothing.
  407. //!
  408. //! <b>Complexity</b>: Constant.
  409. const_iterator cend() const;
  410. //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
  411. //! of the reversed container.
  412. //!
  413. //! <b>Throws</b>: Nothing.
  414. //!
  415. //! <b>Complexity</b>: Constant.
  416. reverse_iterator rbegin();
  417. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  418. //! of the reversed container.
  419. //!
  420. //! <b>Throws</b>: Nothing.
  421. //!
  422. //! <b>Complexity</b>: Constant.
  423. const_reverse_iterator rbegin() const;
  424. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  425. //! of the reversed container.
  426. //!
  427. //! <b>Throws</b>: Nothing.
  428. //!
  429. //! <b>Complexity</b>: Constant.
  430. const_reverse_iterator crbegin() const;
  431. //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
  432. //! of the reversed container.
  433. //!
  434. //! <b>Throws</b>: Nothing.
  435. //!
  436. //! <b>Complexity</b>: Constant.
  437. reverse_iterator rend();
  438. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
  439. //! of the reversed container.
  440. //!
  441. //! <b>Throws</b>: Nothing.
  442. //!
  443. //! <b>Complexity</b>: Constant.
  444. const_reverse_iterator rend() const;
  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 crend() const;
  452. //! <b>Effects</b>: Returns true if the container contains no elements.
  453. //!
  454. //! <b>Throws</b>: Nothing.
  455. //!
  456. //! <b>Complexity</b>: Constant.
  457. bool empty() const;
  458. //! <b>Effects</b>: Returns the number of the elements contained in the container.
  459. //!
  460. //! <b>Throws</b>: Nothing.
  461. //!
  462. //! <b>Complexity</b>: Constant.
  463. size_type size() const;
  464. //! <b>Effects</b>: Returns the largest possible size of the container.
  465. //!
  466. //! <b>Throws</b>: Nothing.
  467. //!
  468. //! <b>Complexity</b>: Constant.
  469. size_type max_size() const;
  470. #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  471. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  472. //! <b>Effects</b>: Inserts an object x of type Key constructed with
  473. //! std::forward<Args>(args)... if and only if there is
  474. //! no element in the container with equivalent value.
  475. //! and returns the iterator pointing to the
  476. //! newly inserted element.
  477. //!
  478. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  479. //! if the insertion takes place, and the iterator component of the pair
  480. //! points to the element with key equivalent to the key of x.
  481. //!
  482. //! <b>Throws</b>: If memory allocation throws or
  483. //! Key's in-place constructor throws.
  484. //!
  485. //! <b>Complexity</b>: Logarithmic.
  486. template <class... Args>
  487. BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> emplace(BOOST_FWD_REF(Args)... args)
  488. { return this->base_t::emplace_unique(boost::forward<Args>(args)...); }
  489. //! <b>Effects</b>: Inserts an object of type Key constructed with
  490. //! std::forward<Args>(args)... if and only if there is
  491. //! no element in the container with equivalent value.
  492. //! p is a hint pointing to where the insert
  493. //! should start to search.
  494. //!
  495. //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
  496. //!
  497. //! <b>Complexity</b>: Logarithmic.
  498. template <class... Args>
  499. BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
  500. { return this->base_t::emplace_hint_unique(p, boost::forward<Args>(args)...); }
  501. #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  502. #define BOOST_CONTAINER_SET_EMPLACE_CODE(N) \
  503. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  504. BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> emplace(BOOST_MOVE_UREF##N)\
  505. { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\
  506. \
  507. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  508. BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  509. { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  510. //
  511. BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SET_EMPLACE_CODE)
  512. #undef BOOST_CONTAINER_SET_EMPLACE_CODE
  513. #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  514. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  515. //! <b>Effects</b>: Inserts x if and only if there is no element in the container
  516. //! with key equivalent to the key of x.
  517. //!
  518. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  519. //! if the insertion takes place, and the iterator component of the pair
  520. //! points to the element with key equivalent to the key of x.
  521. //!
  522. //! <b>Complexity</b>: Logarithmic.
  523. std::pair<iterator, bool> insert(const value_type &x);
  524. //! <b>Effects</b>: Move constructs a new value from x if and only if there is
  525. //! no element in the container with key equivalent to the key of x.
  526. //!
  527. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  528. //! if the insertion takes place, and the iterator component of the pair
  529. //! points to the element with key equivalent to the key of x.
  530. //!
  531. //! <b>Complexity</b>: Logarithmic.
  532. std::pair<iterator, bool> insert(value_type &&x);
  533. #else
  534. private:
  535. typedef std::pair<iterator, bool> insert_return_pair;
  536. public:
  537. BOOST_MOVE_CONVERSION_AWARE_CATCH
  538. (insert, value_type, insert_return_pair, this->base_t::insert_unique_convertible)
  539. #endif
  540. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  541. //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
  542. //! no element in the container with key equivalent to the key of x.
  543. //! p is a hint pointing to where the insert should start to search.
  544. //!
  545. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  546. //! to the key of x.
  547. //!
  548. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  549. //! is inserted right before p.
  550. iterator insert(const_iterator p, const value_type &x);
  551. //! <b>Effects</b>: Inserts an element move constructed from x in the container.
  552. //! p is a hint pointing to where the insert should start to search.
  553. //!
  554. //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
  555. //!
  556. //! <b>Complexity</b>: Logarithmic.
  557. iterator insert(const_iterator p, value_type &&x);
  558. #else
  559. BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG
  560. (insert, value_type, iterator, this->base_t::insert_unique_hint_convertible, const_iterator, const_iterator)
  561. #endif
  562. //! <b>Requires</b>: first, last are not iterators into *this.
  563. //!
  564. //! <b>Effects</b>: inserts each element from the range [first,last) if and only
  565. //! if there is no element with key equivalent to the key of that element.
  566. //!
  567. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
  568. template <class InputIterator>
  569. BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last)
  570. { this->base_t::insert_unique_range(first, last); }
  571. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  572. //! <b>Effects</b>: inserts each element from the range [il.begin(),il.end()) if and only
  573. //! if there is no element with key equivalent to the key of that element.
  574. //!
  575. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end())
  576. BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list<value_type> il)
  577. { this->base_t::insert_unique_range(il.begin(), il.end()); }
  578. #endif
  579. //! @copydoc ::boost::container::map::insert(node_type&&)
  580. BOOST_CONTAINER_FORCEINLINE insert_return_type insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  581. { return this->base_t::insert_unique_node(boost::move(nh)); }
  582. //! @copydoc ::boost::container::map::insert(const_iterator, node_type&&)
  583. BOOST_CONTAINER_FORCEINLINE insert_return_type insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  584. { return this->base_t::insert_unique_node(hint, boost::move(nh)); }
  585. //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&)
  586. template<class C2>
  587. BOOST_CONTAINER_FORCEINLINE void merge(set<Key, C2, Allocator, Options>& source)
  588. {
  589. typedef dtl::tree
  590. <Key, void, C2, Allocator, Options> base2_t;
  591. this->base_t::merge_unique(static_cast<base2_t&>(source));
  592. }
  593. //! @copydoc ::boost::container::set::merge(set<Key, C2, Allocator, Options>&)
  594. template<class C2>
  595. BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG set<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  596. { return this->merge(static_cast<set<Key, C2, Allocator, Options>&>(source)); }
  597. //! @copydoc ::boost::container::map::merge(multimap<Key, T, C2, Allocator, Options>&)
  598. template<class C2>
  599. BOOST_CONTAINER_FORCEINLINE void merge(multiset<Key, C2, Allocator, Options>& source)
  600. {
  601. typedef dtl::tree
  602. <Key, void, C2, Allocator, Options> base2_t;
  603. this->base_t::merge_unique(static_cast<base2_t&>(source));
  604. }
  605. //! @copydoc ::boost::container::set::merge(multiset<Key, C2, Allocator, Options>&)
  606. template<class C2>
  607. BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG multiset<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  608. { return this->merge(static_cast<multiset<Key, C2, Allocator, Options>&>(source)); }
  609. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  610. //! <b>Effects</b>: Erases the element pointed to by p.
  611. //!
  612. //! <b>Returns</b>: Returns an iterator pointing to the element immediately
  613. //! following q prior to the element being erased. If no such element exists,
  614. //! returns end().
  615. //!
  616. //! <b>Complexity</b>: Amortized constant time
  617. iterator erase(const_iterator p);
  618. //! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
  619. //!
  620. //! <b>Returns</b>: Returns the number of erased elements.
  621. //!
  622. //! <b>Complexity</b>: log(size()) + count(k)
  623. size_type erase(const key_type& x);
  624. //! <b>Effects</b>: Erases all the elements in the range [first, last).
  625. //!
  626. //! <b>Returns</b>: Returns last.
  627. //!
  628. //! <b>Complexity</b>: log(size())+N where N is the distance from first to last.
  629. iterator erase(const_iterator first, const_iterator last);
  630. //! @copydoc ::boost::container::map::extract(const_iterator)
  631. node_type extract(const_iterator p);
  632. //! @copydoc ::boost::container::map::extract(const key_type&)
  633. node_type extract(const key_type& x);
  634. //! <b>Effects</b>: Swaps the contents of *this and x.
  635. //!
  636. //! <b>Throws</b>: Nothing.
  637. //!
  638. //! <b>Complexity</b>: Constant.
  639. void swap(set& x)
  640. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  641. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  642. //! <b>Effects</b>: erase(begin(),end()).
  643. //!
  644. //! <b>Postcondition</b>: size() == 0.
  645. //!
  646. //! <b>Complexity</b>: linear in size().
  647. void clear();
  648. //! <b>Effects</b>: Returns the comparison object out
  649. //! of which a was constructed.
  650. //!
  651. //! <b>Complexity</b>: Constant.
  652. key_compare key_comp() const;
  653. //! <b>Effects</b>: Returns an object of value_compare constructed out
  654. //! of the comparison object.
  655. //!
  656. //! <b>Complexity</b>: Constant.
  657. value_compare value_comp() const;
  658. //! <b>Returns</b>: An iterator pointing to an element with the key
  659. //! equivalent to x, or end() if such an element is not found.
  660. //!
  661. //! <b>Complexity</b>: Logarithmic.
  662. iterator find(const key_type& x);
  663. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  664. //! equivalent to x, or end() if such an element is not found.
  665. //!
  666. //! <b>Complexity</b>: Logarithmic.
  667. const_iterator find(const key_type& x) const;
  668. //! <b>Requires</b>: This overload is available only if
  669. //! key_compare::is_transparent exists.
  670. //!
  671. //! <b>Returns</b>: An iterator pointing to an element with the key
  672. //! equivalent to x, or end() if such an element is not found.
  673. //!
  674. //! <b>Complexity</b>: Logarithmic.
  675. template<typename K>
  676. iterator find(const K& x);
  677. //! <b>Requires</b>: This overload is available only if
  678. //! key_compare::is_transparent exists.
  679. //!
  680. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  681. //! equivalent to x, or end() if such an element is not found.
  682. //!
  683. //! <b>Complexity</b>: Logarithmic.
  684. template<typename K>
  685. const_iterator find(const K& x) const;
  686. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  687. //! <b>Returns</b>: The number of elements with key equivalent to x.
  688. //!
  689. //! <b>Complexity</b>: log(size())+count(k)
  690. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  691. size_type count(const key_type& x) const
  692. { return static_cast<size_type>(this->base_t::find(x) != this->base_t::cend()); }
  693. //! <b>Requires</b>: This overload is available only if
  694. //! key_compare::is_transparent exists.
  695. //!
  696. //! <b>Returns</b>: The number of elements with key equivalent to x.
  697. //!
  698. //! <b>Complexity</b>: log(size())+count(k)
  699. template<typename K>
  700. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  701. size_type count(const K& x) const
  702. { return static_cast<size_type>(this->find(x) != this->cend()); }
  703. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  704. //! <b>Returns</b>: Returns true if there is an element with key
  705. //! equivalent to key in the container, otherwise false.
  706. //!
  707. //! <b>Complexity</b>: log(size()).
  708. bool contains(const key_type& x) const;
  709. //! <b>Requires</b>: This overload is available only if
  710. //! key_compare::is_transparent exists.
  711. //!
  712. //! <b>Returns</b>: Returns true if there is an element with key
  713. //! equivalent to key in the container, otherwise false.
  714. //!
  715. //! <b>Complexity</b>: log(size()).
  716. template<typename K>
  717. bool contains(const K& x) const;
  718. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  719. //! than x, or end() if such an element is not found.
  720. //!
  721. //! <b>Complexity</b>: Logarithmic
  722. iterator lower_bound(const key_type& x);
  723. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  724. //! less than x, or end() if such an element is not found.
  725. //!
  726. //! <b>Complexity</b>: Logarithmic
  727. const_iterator lower_bound(const key_type& x) const;
  728. //! <b>Requires</b>: This overload is available only if
  729. //! key_compare::is_transparent exists.
  730. //!
  731. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  732. //! than x, or end() if such an element is not found.
  733. //!
  734. //! <b>Complexity</b>: Logarithmic
  735. template<typename K>
  736. iterator lower_bound(const K& x);
  737. //! <b>Requires</b>: This overload is available only if
  738. //! key_compare::is_transparent exists.
  739. //!
  740. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  741. //! less than x, or end() if such an element is not found.
  742. //!
  743. //! <b>Complexity</b>: Logarithmic
  744. template<typename K>
  745. const_iterator lower_bound(const K& x) const;
  746. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  747. //! than x, or end() if such an element is not found.
  748. //!
  749. //! <b>Complexity</b>: Logarithmic
  750. iterator upper_bound(const key_type& x);
  751. //! <b>Returns</b>: A const iterator pointing to the first element with key
  752. //! greater than x, or end() if such an element is not found.
  753. //!
  754. //! <b>Complexity</b>: Logarithmic
  755. const_iterator upper_bound(const key_type& x) const;
  756. //! <b>Requires</b>: This overload is available only if
  757. //! key_compare::is_transparent exists.
  758. //!
  759. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  760. //! than x, or end() if such an element is not found.
  761. //!
  762. //! <b>Complexity</b>: Logarithmic
  763. template<typename K>
  764. iterator upper_bound(const K& x);
  765. //! <b>Requires</b>: This overload is available only if
  766. //! key_compare::is_transparent exists.
  767. //!
  768. //! <b>Returns</b>: A const iterator pointing to the first element with key
  769. //! greater than x, or end() if such an element is not found.
  770. //!
  771. //! <b>Complexity</b>: Logarithmic
  772. template<typename K>
  773. const_iterator upper_bound(const K& x) const;
  774. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  775. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  776. //!
  777. //! <b>Complexity</b>: Logarithmic
  778. BOOST_CONTAINER_FORCEINLINE std::pair<iterator,iterator> equal_range(const key_type& x)
  779. { return this->base_t::lower_bound_range(x); }
  780. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  781. //!
  782. //! <b>Complexity</b>: Logarithmic
  783. BOOST_CONTAINER_FORCEINLINE std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
  784. { return this->base_t::lower_bound_range(x); }
  785. //! <b>Requires</b>: This overload is available only if
  786. //! key_compare::is_transparent exists.
  787. //!
  788. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  789. //!
  790. //! <b>Complexity</b>: Logarithmic
  791. template<typename K>
  792. BOOST_CONTAINER_FORCEINLINE std::pair<iterator,iterator> equal_range(const K& x)
  793. { return this->base_t::lower_bound_range(x); }
  794. //! <b>Requires</b>: This overload is available only if
  795. //! key_compare::is_transparent exists.
  796. //!
  797. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  798. //!
  799. //! <b>Complexity</b>: Logarithmic
  800. template<typename K>
  801. BOOST_CONTAINER_FORCEINLINE std::pair<const_iterator,const_iterator> equal_range(const K& x) const
  802. { return this->base_t::lower_bound_range(x); }
  803. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  804. //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees.
  805. //!
  806. //! <b>Complexity</b>: Linear
  807. void rebalance();
  808. //! <b>Effects</b>: Returns true if x and y are equal
  809. //!
  810. //! <b>Complexity</b>: Linear to the number of elements in the container.
  811. friend bool operator==(const set& x, const set& y);
  812. //! <b>Effects</b>: Returns true if x and y are unequal
  813. //!
  814. //! <b>Complexity</b>: Linear to the number of elements in the container.
  815. friend bool operator!=(const set& x, const set& y);
  816. //! <b>Effects</b>: Returns true if x is less than y
  817. //!
  818. //! <b>Complexity</b>: Linear to the number of elements in the container.
  819. friend bool operator<(const set& x, const set& y);
  820. //! <b>Effects</b>: Returns true if x is greater than y
  821. //!
  822. //! <b>Complexity</b>: Linear to the number of elements in the container.
  823. friend bool operator>(const set& x, const set& y);
  824. //! <b>Effects</b>: Returns true if x is equal or less than y
  825. //!
  826. //! <b>Complexity</b>: Linear to the number of elements in the container.
  827. friend bool operator<=(const set& x, const set& y);
  828. //! <b>Effects</b>: Returns true if x is equal or greater than y
  829. //!
  830. //! <b>Complexity</b>: Linear to the number of elements in the container.
  831. friend bool operator>=(const set& x, const set& y);
  832. //! <b>Effects</b>: x.swap(y)
  833. //!
  834. //! <b>Complexity</b>: Constant.
  835. friend void swap(set& x, set& y)
  836. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  837. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  838. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  839. };
  840. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  841. template <typename InputIterator>
  842. set(InputIterator, InputIterator) ->
  843. set< it_based_value_type_t<InputIterator> >;
  844. template < typename InputIterator, typename AllocatorOrCompare>
  845. set(InputIterator, InputIterator, AllocatorOrCompare const&) ->
  846. set< it_based_value_type_t<InputIterator>
  847. , typename dtl::if_c< // Compare
  848. dtl::is_allocator<AllocatorOrCompare>::value
  849. , std::less<it_based_value_type_t<InputIterator>>
  850. , AllocatorOrCompare
  851. >::type
  852. , typename dtl::if_c< // Allocator
  853. dtl::is_allocator<AllocatorOrCompare>::value
  854. , AllocatorOrCompare
  855. , new_allocator<it_based_value_type_t<InputIterator>>
  856. >::type
  857. >;
  858. template < typename InputIterator, typename Compare, typename Allocator
  859. , typename = dtl::require_nonallocator_t<Compare>
  860. , typename = dtl::require_allocator_t<Allocator>>
  861. set(InputIterator, InputIterator, Compare const&, Allocator const&) ->
  862. set< it_based_value_type_t<InputIterator>
  863. , Compare
  864. , Allocator>;
  865. template <typename InputIterator>
  866. set(ordered_unique_range_t, InputIterator, InputIterator) ->
  867. set< it_based_value_type_t<InputIterator>>;
  868. template < typename InputIterator, typename AllocatorOrCompare>
  869. set(ordered_unique_range_t, InputIterator, InputIterator, AllocatorOrCompare const&) ->
  870. set< it_based_value_type_t<InputIterator>
  871. , typename dtl::if_c< // Compare
  872. dtl::is_allocator<AllocatorOrCompare>::value
  873. , std::less<it_based_value_type_t<InputIterator>>
  874. , AllocatorOrCompare
  875. >::type
  876. , typename dtl::if_c< // Allocator
  877. dtl::is_allocator<AllocatorOrCompare>::value
  878. , AllocatorOrCompare
  879. , new_allocator<it_based_value_type_t<InputIterator>>
  880. >::type
  881. >;
  882. template < typename InputIterator, typename Compare, typename Allocator
  883. , typename = dtl::require_nonallocator_t<Compare>
  884. , typename = dtl::require_allocator_t<Allocator>>
  885. set(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
  886. set< it_based_value_type_t<InputIterator>
  887. , Compare
  888. , Allocator>;
  889. #endif
  890. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  891. } //namespace container {
  892. //!has_trivial_destructor_after_move<> == true_type
  893. //!specialization for optimizations
  894. template <class Key, class Compare, class Allocator, class Options>
  895. struct has_trivial_destructor_after_move<boost::container::set<Key, Compare, Allocator, Options> >
  896. {
  897. typedef ::boost::container::dtl::tree<Key, void, Compare, Allocator, Options> tree;
  898. static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
  899. };
  900. namespace container {
  901. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  902. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  903. //! A multiset is a kind of associative container that supports equivalent keys
  904. //! (possibly contains multiple copies of the same key value) and provides for
  905. //! fast retrieval of the keys themselves. Class multiset supports bidirectional iterators.
  906. //!
  907. //! A multiset satisfies all of the requirements of a container and of a reversible
  908. //! container, and of an associative container). multiset also provides most operations
  909. //! described for duplicate keys.
  910. //!
  911. //! \tparam Key is the type to be inserted in the set, which is also the key_type
  912. //! \tparam Compare is the comparison functor used to order keys
  913. //! \tparam Allocator is the allocator to be used to allocate memory for this container
  914. //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options.
  915. template <class Key, class Compare = std::less<Key>, class Allocator = new_allocator<Key>, class Options = tree_assoc_defaults >
  916. #else
  917. template <class Key, class Compare, class Allocator, class Options>
  918. #endif
  919. class multiset
  920. /// @cond
  921. : public dtl::tree
  922. <Key, void, Compare, Allocator, Options>
  923. /// @endcond
  924. {
  925. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  926. private:
  927. BOOST_COPYABLE_AND_MOVABLE(multiset)
  928. typedef dtl::tree
  929. <Key, void, Compare, Allocator, Options> base_t;
  930. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  931. public:
  932. //////////////////////////////////////////////
  933. //
  934. // types
  935. //
  936. //////////////////////////////////////////////
  937. typedef Key key_type;
  938. typedef Key value_type;
  939. typedef Compare key_compare;
  940. typedef key_compare value_compare;
  941. typedef typename base_t::allocator_type allocator_type;
  942. typedef ::boost::container::allocator_traits<allocator_type> allocator_traits_type;
  943. typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
  944. typedef typename ::boost::container::allocator_traits<allocator_type>::const_pointer const_pointer;
  945. typedef typename ::boost::container::allocator_traits<allocator_type>::reference reference;
  946. typedef typename ::boost::container::allocator_traits<allocator_type>::const_reference const_reference;
  947. typedef typename ::boost::container::allocator_traits<allocator_type>::size_type size_type;
  948. typedef typename ::boost::container::allocator_traits<allocator_type>::difference_type difference_type;
  949. typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
  950. typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
  951. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
  952. typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
  953. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
  954. typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type;
  955. //////////////////////////////////////////////
  956. //
  957. // construct/copy/destroy
  958. //
  959. //////////////////////////////////////////////
  960. //! @copydoc ::boost::container::set::set()
  961. BOOST_CONTAINER_FORCEINLINE multiset()
  962. BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<allocator_type>::value &&
  963. dtl::is_nothrow_default_constructible<Compare>::value)
  964. : base_t()
  965. {}
  966. //! @copydoc ::boost::container::set::set(const allocator_type&)
  967. BOOST_CONTAINER_FORCEINLINE explicit multiset(const allocator_type& a)
  968. : base_t(a)
  969. {}
  970. //! @copydoc ::boost::container::set::set(const Compare&)
  971. BOOST_CONTAINER_FORCEINLINE explicit multiset(const Compare& comp)
  972. : base_t(comp)
  973. {}
  974. //! @copydoc ::boost::container::set::set(const Compare&, const allocator_type&)
  975. BOOST_CONTAINER_FORCEINLINE multiset(const Compare& comp, const allocator_type& a)
  976. : base_t(comp, a)
  977. {}
  978. //! @copydoc ::boost::container::set::set(InputIterator, InputIterator)
  979. template <class InputIterator>
  980. BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last)
  981. : base_t(false, first, last)
  982. {}
  983. //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const allocator_type&)
  984. template <class InputIterator>
  985. BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const allocator_type& a)
  986. : base_t(false, first, last, key_compare(), a)
  987. {}
  988. //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&)
  989. template <class InputIterator>
  990. BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const Compare& comp)
  991. : base_t(false, first, last, comp)
  992. {}
  993. //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&, const allocator_type&)
  994. template <class InputIterator>
  995. BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  996. : base_t(false, first, last, comp, a)
  997. {}
  998. //! <b>Effects</b>: Constructs an empty multiset and
  999. //! and inserts elements from the ordered range [first ,last ). This function
  1000. //! is more efficient than the normal range creation for ordered ranges.
  1001. //!
  1002. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1003. //!
  1004. //! <b>Complexity</b>: Linear in N.
  1005. //!
  1006. //! <b>Note</b>: Non-standard extension.
  1007. template <class InputIterator>
  1008. BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last )
  1009. : base_t(ordered_range, first, last)
  1010. {}
  1011. //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and
  1012. //! inserts elements from the ordered range [first ,last ). This function
  1013. //! is more efficient than the normal range creation for ordered ranges.
  1014. //!
  1015. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1016. //!
  1017. //! <b>Complexity</b>: Linear in N.
  1018. //!
  1019. //! <b>Note</b>: Non-standard extension.
  1020. template <class InputIterator>
  1021. BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp)
  1022. : base_t(ordered_range, first, last, comp)
  1023. {}
  1024. //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and
  1025. //! allocator, and inserts elements from the ordered range [first ,last ). This function
  1026. //! is more efficient than the normal range creation for ordered ranges.
  1027. //!
  1028. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1029. //!
  1030. //! <b>Complexity</b>: Linear in N.
  1031. //!
  1032. //! <b>Note</b>: Non-standard extension.
  1033. template <class InputIterator>
  1034. BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  1035. : base_t(ordered_range, first, last, comp, a)
  1036. {}
  1037. //! <b>Effects</b>: Constructs an empty multiset using the specified allocator and
  1038. //! inserts elements from the ordered range [first ,last ). This function
  1039. //! is more efficient than the normal range creation for ordered ranges.
  1040. //!
  1041. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1042. //!
  1043. //! <b>Complexity</b>: Linear in N.
  1044. //!
  1045. //! <b>Note</b>: Non-standard extension.
  1046. template <class InputIterator>
  1047. BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, InputIterator first, InputIterator last, const allocator_type &a)
  1048. : base_t(ordered_range, first, last, Compare(), a)
  1049. {}
  1050. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1051. //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>)
  1052. BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il)
  1053. : base_t(false, il.begin(), il.end())
  1054. {}
  1055. //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const allocator_type&)
  1056. BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il, const allocator_type& a)
  1057. : base_t(false, il.begin(), il.end(), Compare(), a)
  1058. {}
  1059. //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const Compare&)
  1060. BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il, const Compare& comp)
  1061. : base_t(false, il.begin(), il.end(), comp)
  1062. {}
  1063. //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const Compare&, const allocator_type&)
  1064. BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  1065. : base_t(false, il.begin(), il.end(), comp, a)
  1066. {}
  1067. //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>)
  1068. BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list<value_type> il)
  1069. : base_t(ordered_range, il.begin(), il.end())
  1070. {}
  1071. //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>, const Compare&)
  1072. BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp)
  1073. : base_t(ordered_range, il.begin(), il.end(), comp)
  1074. {}
  1075. //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>, const Compare&, const allocator_type&)
  1076. BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  1077. : base_t(ordered_range, il.begin(), il.end(), comp, a)
  1078. {}
  1079. #endif
  1080. //! @copydoc ::boost::container::set::set(const set &)
  1081. BOOST_CONTAINER_FORCEINLINE multiset(const multiset& x)
  1082. : base_t(static_cast<const base_t&>(x))
  1083. {}
  1084. //! @copydoc ::boost::container::set::set(set &&)
  1085. BOOST_CONTAINER_FORCEINLINE multiset(BOOST_RV_REF(multiset) x)
  1086. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value)
  1087. : base_t(BOOST_MOVE_BASE(base_t, x))
  1088. {}
  1089. //! @copydoc ::boost::container::set::set(const set &, const allocator_type &)
  1090. BOOST_CONTAINER_FORCEINLINE multiset(const multiset& x, const allocator_type &a)
  1091. : base_t(static_cast<const base_t&>(x), a)
  1092. {}
  1093. //! @copydoc ::boost::container::set::set(set &&, const allocator_type &)
  1094. BOOST_CONTAINER_FORCEINLINE multiset(BOOST_RV_REF(multiset) x, const allocator_type &a)
  1095. : base_t(BOOST_MOVE_BASE(base_t, x), a)
  1096. {}
  1097. //! @copydoc ::boost::container::set::operator=(const set &)
  1098. BOOST_CONTAINER_FORCEINLINE multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x)
  1099. { return static_cast<multiset&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
  1100. //! @copydoc ::boost::container::set::operator=(set &&)
  1101. BOOST_CONTAINER_FORCEINLINE multiset& operator=(BOOST_RV_REF(multiset) x)
  1102. BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
  1103. allocator_traits_type::is_always_equal::value) &&
  1104. boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
  1105. { return static_cast<multiset&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
  1106. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1107. //! @copydoc ::boost::container::set::operator=(std::initializer_list<value_type>)
  1108. multiset& operator=(std::initializer_list<value_type> il)
  1109. {
  1110. this->clear();
  1111. insert(il.begin(), il.end());
  1112. return *this;
  1113. }
  1114. #endif
  1115. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1116. //! @copydoc ::boost::container::set::get_allocator()
  1117. allocator_type get_allocator() const;
  1118. //! @copydoc ::boost::container::set::get_stored_allocator()
  1119. stored_allocator_type &get_stored_allocator();
  1120. //! @copydoc ::boost::container::set::get_stored_allocator() const
  1121. const stored_allocator_type &get_stored_allocator() const;
  1122. //! @copydoc ::boost::container::set::begin()
  1123. iterator begin();
  1124. //! @copydoc ::boost::container::set::begin() const
  1125. const_iterator begin() const;
  1126. //! @copydoc ::boost::container::set::cbegin() const
  1127. const_iterator cbegin() const;
  1128. //! @copydoc ::boost::container::set::end()
  1129. iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
  1130. //! @copydoc ::boost::container::set::end() const
  1131. const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
  1132. //! @copydoc ::boost::container::set::cend() const
  1133. const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1134. //! @copydoc ::boost::container::set::rbegin()
  1135. reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
  1136. //! @copydoc ::boost::container::set::rbegin() const
  1137. const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  1138. //! @copydoc ::boost::container::set::crbegin() const
  1139. const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  1140. //! @copydoc ::boost::container::set::rend()
  1141. reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
  1142. //! @copydoc ::boost::container::set::rend() const
  1143. const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1144. //! @copydoc ::boost::container::set::crend() const
  1145. const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1146. //! @copydoc ::boost::container::set::empty() const
  1147. bool empty() const;
  1148. //! @copydoc ::boost::container::set::size() const
  1149. size_type size() const;
  1150. //! @copydoc ::boost::container::set::max_size() const
  1151. size_type max_size() const;
  1152. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1153. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1154. //! <b>Effects</b>: Inserts an object of type Key constructed with
  1155. //! std::forward<Args>(args)... and returns the iterator pointing to the
  1156. //! newly inserted element.
  1157. //!
  1158. //! <b>Complexity</b>: Logarithmic.
  1159. template <class... Args>
  1160. BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_FWD_REF(Args)... args)
  1161. { return this->base_t::emplace_equal(boost::forward<Args>(args)...); }
  1162. //! <b>Effects</b>: Inserts an object of type Key constructed with
  1163. //! std::forward<Args>(args)...
  1164. //!
  1165. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1166. //! to the key of x.
  1167. //!
  1168. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1169. //! is inserted right before p.
  1170. template <class... Args>
  1171. BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
  1172. { return this->base_t::emplace_hint_equal(p, boost::forward<Args>(args)...); }
  1173. #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  1174. #define BOOST_CONTAINER_MULTISET_EMPLACE_CODE(N) \
  1175. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  1176. BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_MOVE_UREF##N)\
  1177. { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\
  1178. \
  1179. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  1180. BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  1181. { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  1182. //
  1183. BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MULTISET_EMPLACE_CODE)
  1184. #undef BOOST_CONTAINER_MULTISET_EMPLACE_CODE
  1185. #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  1186. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1187. //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
  1188. //! newly inserted element.
  1189. //!
  1190. //! <b>Complexity</b>: Logarithmic.
  1191. iterator insert(const value_type &x);
  1192. //! <b>Effects</b>: Inserts a copy of x in the container.
  1193. //!
  1194. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1195. //! to the key of x.
  1196. //!
  1197. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1198. //! is inserted right before p.
  1199. iterator insert(value_type &&x);
  1200. #else
  1201. BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->base_t::insert_equal_convertible)
  1202. #endif
  1203. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1204. //! <b>Effects</b>: Inserts a copy of x in the container.
  1205. //! p is a hint pointing to where the insert should start to search.
  1206. //!
  1207. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1208. //! to the key of x.
  1209. //!
  1210. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1211. //! is inserted right before p.
  1212. iterator insert(const_iterator p, const value_type &x);
  1213. //! <b>Effects</b>: Inserts a value move constructed from x in the container.
  1214. //! p is a hint pointing to where the insert should start to search.
  1215. //!
  1216. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1217. //! to the key of x.
  1218. //!
  1219. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1220. //! is inserted right before p.
  1221. iterator insert(const_iterator p, value_type &&x);
  1222. #else
  1223. BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG
  1224. (insert, value_type, iterator, this->base_t::insert_equal_hint_convertible, const_iterator, const_iterator)
  1225. #endif
  1226. //! <b>Requires</b>: first, last are not iterators into *this.
  1227. //!
  1228. //! <b>Effects</b>: inserts each element from the range [first,last) .
  1229. //!
  1230. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
  1231. template <class InputIterator>
  1232. BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last)
  1233. { this->base_t::insert_equal_range(first, last); }
  1234. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1235. //! @copydoc ::boost::container::set::insert(std::initializer_list<value_type>)
  1236. BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list<value_type> il)
  1237. { this->base_t::insert_equal_range(il.begin(), il.end()); }
  1238. #endif
  1239. //! @copydoc ::boost::container::multimap::insert(node_type&&)
  1240. BOOST_CONTAINER_FORCEINLINE iterator insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  1241. { return this->base_t::insert_equal_node(boost::move(nh)); }
  1242. //! @copydoc ::boost::container::multimap::insert(const_iterator, node_type&&)
  1243. BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  1244. { return this->base_t::insert_equal_node(hint, boost::move(nh)); }
  1245. //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&)
  1246. template<class C2>
  1247. BOOST_CONTAINER_FORCEINLINE void merge(multiset<Key, C2, Allocator, Options>& source)
  1248. {
  1249. typedef dtl::tree
  1250. <Key, void, C2, Allocator, Options> base2_t;
  1251. this->base_t::merge_equal(static_cast<base2_t&>(source));
  1252. }
  1253. //! @copydoc ::boost::container::multiset::merge(multiset<Key, C2, Allocator, Options>&)
  1254. template<class C2>
  1255. BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG multiset<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  1256. { return this->merge(static_cast<multiset<Key, C2, Allocator, Options>&>(source)); }
  1257. //! @copydoc ::boost::container::multimap::merge(map<Key, T, C2, Allocator, Options>&)
  1258. template<class C2>
  1259. BOOST_CONTAINER_FORCEINLINE void merge(set<Key, C2, Allocator, Options>& source)
  1260. {
  1261. typedef dtl::tree
  1262. <Key, void, C2, Allocator, Options> base2_t;
  1263. this->base_t::merge_equal(static_cast<base2_t&>(source));
  1264. }
  1265. //! @copydoc ::boost::container::multiset::merge(set<Key, C2, Allocator, Options>&)
  1266. template<class C2>
  1267. BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG set<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  1268. { return this->merge(static_cast<set<Key, C2, Allocator, Options>&>(source)); }
  1269. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1270. //! @copydoc ::boost::container::set::erase(const_iterator)
  1271. iterator erase(const_iterator p);
  1272. //! @copydoc ::boost::container::set::erase(const key_type&)
  1273. size_type erase(const key_type& x);
  1274. //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator)
  1275. iterator erase(const_iterator first, const_iterator last);
  1276. //! @copydoc ::boost::container::multimap::extract(const_iterator)
  1277. node_type extract(const_iterator p);
  1278. //! @copydoc ::boost::container::multimap::extract(const key_type&)
  1279. node_type extract(const key_type& x);
  1280. //! @copydoc ::boost::container::set::swap
  1281. void swap(multiset& x)
  1282. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1283. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1284. //! @copydoc ::boost::container::set::clear
  1285. void clear() BOOST_NOEXCEPT_OR_NOTHROW;
  1286. //! @copydoc ::boost::container::set::key_comp
  1287. key_compare key_comp() const;
  1288. //! @copydoc ::boost::container::set::value_comp
  1289. value_compare value_comp() const;
  1290. //! @copydoc ::boost::container::set::find(const key_type& )
  1291. iterator find(const key_type& x);
  1292. //! @copydoc ::boost::container::set::find(const key_type& ) const
  1293. const_iterator find(const key_type& x) const;
  1294. //! @copydoc ::boost::container::set::find(const K& )
  1295. template<typename K>
  1296. iterator find(const K& x);
  1297. //! @copydoc ::boost::container::set::find(const K& )
  1298. template<typename K>
  1299. const_iterator find(const K& x) const;
  1300. //! @copydoc ::boost::container::set::count(const key_type& ) const
  1301. size_type count(const key_type& x) const;
  1302. //! @copydoc ::boost::container::set::count(const K& ) const
  1303. template<typename K>
  1304. size_type count(const K& x) const;
  1305. //! @copydoc ::boost::container::set::contains(const key_type& ) const
  1306. bool contains(const key_type& x) const;
  1307. //! @copydoc ::boost::container::set::contains(const K& ) const
  1308. template<typename K>
  1309. bool contains(const K& x) const;
  1310. //! @copydoc ::boost::container::set::lower_bound(const key_type& )
  1311. iterator lower_bound(const key_type& x);
  1312. //! @copydoc ::boost::container::set::lower_bound(const key_type& ) const
  1313. const_iterator lower_bound(const key_type& x) const;
  1314. //! @copydoc ::boost::container::set::lower_bound(const K& )
  1315. template<typename K>
  1316. iterator lower_bound(const K& x);
  1317. //! @copydoc ::boost::container::set::lower_bound(const K& ) const
  1318. template<typename K>
  1319. const_iterator lower_bound(const K& x) const;
  1320. //! @copydoc ::boost::container::set::upper_bound(const key_type& )
  1321. iterator upper_bound(const key_type& x);
  1322. //! @copydoc ::boost::container::set::upper_bound(const key_type& ) const
  1323. const_iterator upper_bound(const key_type& x) const;
  1324. //! @copydoc ::boost::container::set::upper_bound(const K& )
  1325. template<typename K>
  1326. iterator upper_bound(const K& x);
  1327. //! @copydoc ::boost::container::set::upper_bound(const K& ) const
  1328. template<typename K>
  1329. const_iterator upper_bound(const K& x) const;
  1330. //! @copydoc ::boost::container::set::equal_range(const key_type& ) const
  1331. std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
  1332. //! @copydoc ::boost::container::set::equal_range(const key_type& )
  1333. std::pair<iterator,iterator> equal_range(const key_type& x);
  1334. //! @copydoc ::boost::container::set::equal_range(const K& ) const
  1335. template<typename K>
  1336. std::pair<const_iterator, const_iterator> equal_range(const K& x) const;
  1337. //! @copydoc ::boost::container::set::equal_range(const K& )
  1338. template<typename K>
  1339. std::pair<iterator,iterator> equal_range(const K& x);
  1340. //! @copydoc ::boost::container::set::rebalance()
  1341. void rebalance();
  1342. //! <b>Effects</b>: Returns true if x and y are equal
  1343. //!
  1344. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1345. friend bool operator==(const multiset& x, const multiset& y);
  1346. //! <b>Effects</b>: Returns true if x and y are unequal
  1347. //!
  1348. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1349. friend bool operator!=(const multiset& x, const multiset& y);
  1350. //! <b>Effects</b>: Returns true if x is less than y
  1351. //!
  1352. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1353. friend bool operator<(const multiset& x, const multiset& y);
  1354. //! <b>Effects</b>: Returns true if x is greater than y
  1355. //!
  1356. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1357. friend bool operator>(const multiset& x, const multiset& y);
  1358. //! <b>Effects</b>: Returns true if x is equal or less than y
  1359. //!
  1360. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1361. friend bool operator<=(const multiset& x, const multiset& y);
  1362. //! <b>Effects</b>: Returns true if x is equal or greater than y
  1363. //!
  1364. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1365. friend bool operator>=(const multiset& x, const multiset& y);
  1366. //! <b>Effects</b>: x.swap(y)
  1367. //!
  1368. //! <b>Complexity</b>: Constant.
  1369. friend void swap(multiset& x, multiset& y)
  1370. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1371. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1372. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1373. };
  1374. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  1375. template <typename InputIterator>
  1376. multiset(InputIterator, InputIterator) ->
  1377. multiset< it_based_value_type_t<InputIterator> >;
  1378. template < typename InputIterator, typename AllocatorOrCompare>
  1379. multiset(InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1380. multiset < it_based_value_type_t<InputIterator>
  1381. , typename dtl::if_c< // Compare
  1382. dtl::is_allocator<AllocatorOrCompare>::value
  1383. , std::less<it_based_value_type_t<InputIterator>>
  1384. , AllocatorOrCompare
  1385. >::type
  1386. , typename dtl::if_c< // Allocator
  1387. dtl::is_allocator<AllocatorOrCompare>::value
  1388. , AllocatorOrCompare
  1389. , new_allocator<it_based_value_type_t<InputIterator>>
  1390. >::type
  1391. >;
  1392. template < typename InputIterator, typename Compare, typename Allocator
  1393. , typename = dtl::require_nonallocator_t<Compare>
  1394. , typename = dtl::require_allocator_t<Allocator>>
  1395. multiset(InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1396. multiset< it_based_value_type_t<InputIterator>
  1397. , Compare
  1398. , Allocator>;
  1399. template <typename InputIterator>
  1400. multiset(ordered_range_t, InputIterator, InputIterator) ->
  1401. multiset< it_based_value_type_t<InputIterator>>;
  1402. template < typename InputIterator, typename AllocatorOrCompare>
  1403. multiset(ordered_range_t, InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1404. multiset < it_based_value_type_t<InputIterator>
  1405. , typename dtl::if_c< // Compare
  1406. dtl::is_allocator<AllocatorOrCompare>::value
  1407. , std::less<it_based_value_type_t<InputIterator>>
  1408. , AllocatorOrCompare
  1409. >::type
  1410. , typename dtl::if_c< // Allocator
  1411. dtl::is_allocator<AllocatorOrCompare>::value
  1412. , AllocatorOrCompare
  1413. , new_allocator<it_based_value_type_t<InputIterator>>
  1414. >::type
  1415. >;
  1416. template < typename InputIterator, typename Compare, typename Allocator
  1417. , typename = dtl::require_nonallocator_t<Compare>
  1418. , typename = dtl::require_allocator_t<Allocator>>
  1419. multiset(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1420. multiset< it_based_value_type_t<InputIterator>
  1421. , Compare
  1422. , Allocator>;
  1423. #endif
  1424. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1425. } //namespace container {
  1426. //!has_trivial_destructor_after_move<> == true_type
  1427. //!specialization for optimizations
  1428. template <class Key, class Compare, class Allocator, class Options>
  1429. struct has_trivial_destructor_after_move<boost::container::multiset<Key, Compare, Allocator, Options> >
  1430. {
  1431. typedef ::boost::container::dtl::tree<Key, void, Compare, Allocator, Options> tree;
  1432. static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
  1433. };
  1434. namespace container {
  1435. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1436. }}
  1437. #include <boost/container/detail/config_end.hpp>
  1438. #endif // BOOST_CONTAINER_SET_HPP