sg_set.hpp 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2007-2014
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/intrusive for documentation.
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef BOOST_INTRUSIVE_SG_SET_HPP
  13. #define BOOST_INTRUSIVE_SG_SET_HPP
  14. #include <boost/intrusive/detail/config_begin.hpp>
  15. #include <boost/intrusive/intrusive_fwd.hpp>
  16. #include <boost/intrusive/detail/mpl.hpp>
  17. #include <boost/intrusive/sgtree.hpp>
  18. #include <boost/static_assert.hpp>
  19. #include <boost/move/utility_core.hpp>
  20. #if defined(BOOST_HAS_PRAGMA_ONCE)
  21. # pragma once
  22. #endif
  23. namespace boost {
  24. namespace intrusive {
  25. //! The class template sg_set is an intrusive container, that mimics most of
  26. //! the interface of std::sg_set as described in the C++ standard.
  27. //!
  28. //! The template parameter \c T is the type to be managed by the container.
  29. //! The user can specify additional options and if no options are provided
  30. //! default options are used.
  31. //!
  32. //! The container supports the following options:
  33. //! \c base_hook<>/member_hook<>/value_traits<>,
  34. //! \c floating_point<>, \c size_type<> and
  35. //! \c compare<>.
  36. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  37. template<class T, class ...Options>
  38. #else
  39. template<class ValueTraits, class VoidOrKeyOfValue, class Compare, class SizeType, bool FloatingPoint, typename HeaderHolder>
  40. #endif
  41. class sg_set_impl
  42. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  43. : public sgtree_impl<ValueTraits, VoidOrKeyOfValue, Compare, SizeType, FloatingPoint, HeaderHolder>
  44. #endif
  45. {
  46. /// @cond
  47. typedef sgtree_impl<ValueTraits, VoidOrKeyOfValue, Compare, SizeType, FloatingPoint, HeaderHolder> tree_type;
  48. BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_set_impl)
  49. typedef tree_type implementation_defined;
  50. /// @endcond
  51. public:
  52. typedef typename implementation_defined::value_type value_type;
  53. typedef typename implementation_defined::key_type key_type;
  54. typedef typename implementation_defined::key_of_value key_of_value;
  55. typedef typename implementation_defined::value_traits value_traits;
  56. typedef typename implementation_defined::pointer pointer;
  57. typedef typename implementation_defined::const_pointer const_pointer;
  58. typedef typename implementation_defined::reference reference;
  59. typedef typename implementation_defined::const_reference const_reference;
  60. typedef typename implementation_defined::difference_type difference_type;
  61. typedef typename implementation_defined::size_type size_type;
  62. typedef typename implementation_defined::value_compare value_compare;
  63. typedef typename implementation_defined::key_compare key_compare;
  64. typedef typename implementation_defined::iterator iterator;
  65. typedef typename implementation_defined::const_iterator const_iterator;
  66. typedef typename implementation_defined::reverse_iterator reverse_iterator;
  67. typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
  68. typedef typename implementation_defined::insert_commit_data insert_commit_data;
  69. typedef typename implementation_defined::node_traits node_traits;
  70. typedef typename implementation_defined::node node;
  71. typedef typename implementation_defined::node_ptr node_ptr;
  72. typedef typename implementation_defined::const_node_ptr const_node_ptr;
  73. typedef typename implementation_defined::node_algorithms node_algorithms;
  74. static const bool constant_time_size = tree_type::constant_time_size;
  75. public:
  76. //! @copydoc ::boost::intrusive::sgtree::sgtree()
  77. sg_set_impl()
  78. : tree_type()
  79. {}
  80. //! @copydoc ::boost::intrusive::sgtree::sgtree(const key_compare &,const value_traits &)
  81. explicit sg_set_impl( const key_compare &cmp, const value_traits &v_traits = value_traits())
  82. : tree_type(cmp, v_traits)
  83. {}
  84. //! @copydoc ::boost::intrusive::sgtree::sgtree(bool,Iterator,Iterator,const key_compare &,const value_traits &)
  85. template<class Iterator>
  86. sg_set_impl( Iterator b, Iterator e
  87. , const key_compare &cmp = key_compare()
  88. , const value_traits &v_traits = value_traits())
  89. : tree_type(true, b, e, cmp, v_traits)
  90. {}
  91. //! @copydoc ::boost::intrusive::sgtree::sgtree(sgtree &&)
  92. sg_set_impl(BOOST_RV_REF(sg_set_impl) x)
  93. : tree_type(BOOST_MOVE_BASE(tree_type, x))
  94. {}
  95. //! @copydoc ::boost::intrusive::sgtree::operator=(sgtree &&)
  96. sg_set_impl& operator=(BOOST_RV_REF(sg_set_impl) x)
  97. { return static_cast<sg_set_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }
  98. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  99. //! @copydoc ::boost::intrusive::sgtree::~sgtree()
  100. ~sg_set_impl();
  101. //! @copydoc ::boost::intrusive::sgtree::begin()
  102. iterator begin();
  103. //! @copydoc ::boost::intrusive::sgtree::begin()const
  104. const_iterator begin() const;
  105. //! @copydoc ::boost::intrusive::sgtree::cbegin()const
  106. const_iterator cbegin() const;
  107. //! @copydoc ::boost::intrusive::sgtree::end()
  108. iterator end();
  109. //! @copydoc ::boost::intrusive::sgtree::end()const
  110. const_iterator end() const;
  111. //! @copydoc ::boost::intrusive::sgtree::cend()const
  112. const_iterator cend() const;
  113. //! @copydoc ::boost::intrusive::sgtree::rbegin()
  114. reverse_iterator rbegin();
  115. //! @copydoc ::boost::intrusive::sgtree::rbegin()const
  116. const_reverse_iterator rbegin() const;
  117. //! @copydoc ::boost::intrusive::sgtree::crbegin()const
  118. const_reverse_iterator crbegin() const;
  119. //! @copydoc ::boost::intrusive::sgtree::rend()
  120. reverse_iterator rend();
  121. //! @copydoc ::boost::intrusive::sgtree::rend()const
  122. const_reverse_iterator rend() const;
  123. //! @copydoc ::boost::intrusive::sgtree::crend()const
  124. const_reverse_iterator crend() const;
  125. //! @copydoc ::boost::intrusive::sgtree::container_from_end_iterator(iterator)
  126. static sg_set_impl &container_from_end_iterator(iterator end_iterator);
  127. //! @copydoc ::boost::intrusive::sgtree::container_from_end_iterator(const_iterator)
  128. static const sg_set_impl &container_from_end_iterator(const_iterator end_iterator);
  129. //! @copydoc ::boost::intrusive::sgtree::container_from_iterator(iterator)
  130. static sg_set_impl &container_from_iterator(iterator it);
  131. //! @copydoc ::boost::intrusive::sgtree::container_from_iterator(const_iterator)
  132. static const sg_set_impl &container_from_iterator(const_iterator it);
  133. //! @copydoc ::boost::intrusive::sgtree::key_comp()const
  134. key_compare key_comp() const;
  135. //! @copydoc ::boost::intrusive::sgtree::value_comp()const
  136. value_compare value_comp() const;
  137. //! @copydoc ::boost::intrusive::sgtree::empty()const
  138. bool empty() const;
  139. //! @copydoc ::boost::intrusive::sgtree::size()const
  140. size_type size() const;
  141. //! @copydoc ::boost::intrusive::sgtree::swap
  142. void swap(sg_set_impl& other);
  143. //! @copydoc ::boost::intrusive::sgtree::clone_from(const sgtree&,Cloner,Disposer)
  144. template <class Cloner, class Disposer>
  145. void clone_from(const sg_set_impl &src, Cloner cloner, Disposer disposer);
  146. #else
  147. using tree_type::clone_from;
  148. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  149. //! @copydoc ::boost::intrusive::sgtree::clone_from(sgtree&&,Cloner,Disposer)
  150. template <class Cloner, class Disposer>
  151. void clone_from(BOOST_RV_REF(sg_set_impl) src, Cloner cloner, Disposer disposer)
  152. { tree_type::clone_from(BOOST_MOVE_BASE(tree_type, src), cloner, disposer); }
  153. //! @copydoc ::boost::intrusive::sgtree::insert_unique(reference)
  154. std::pair<iterator, bool> insert(reference value)
  155. { return tree_type::insert_unique(value); }
  156. //! @copydoc ::boost::intrusive::sgtree::insert_unique(const_iterator,reference)
  157. iterator insert(const_iterator hint, reference value)
  158. { return tree_type::insert_unique(hint, value); }
  159. //! @copydoc ::boost::intrusive::sgtree::insert_unique_check(const key_type&,insert_commit_data&)
  160. std::pair<iterator, bool> insert_check
  161. (const key_type &key, insert_commit_data &commit_data)
  162. { return tree_type::insert_unique_check(key, commit_data); }
  163. //! @copydoc ::boost::intrusive::sgtree::insert_unique_check(const_iterator,const key_type&,insert_commit_data&)
  164. std::pair<iterator, bool> insert_check
  165. (const_iterator hint, const key_type &key
  166. ,insert_commit_data &commit_data)
  167. { return tree_type::insert_unique_check(hint, key, commit_data); }
  168. //! @copydoc ::boost::intrusive::sgtree::insert_unique_check(const KeyType&,KeyTypeKeyCompare,insert_commit_data&)
  169. template<class KeyType, class KeyTypeKeyCompare>
  170. std::pair<iterator, bool> insert_check
  171. (const KeyType &key, KeyTypeKeyCompare comp, insert_commit_data &commit_data)
  172. { return tree_type::insert_unique_check(key, comp, commit_data); }
  173. //! @copydoc ::boost::intrusive::sgtree::insert_unique_check(const_iterator,const KeyType&,KeyTypeKeyCompare,insert_commit_data&)
  174. template<class KeyType, class KeyTypeKeyCompare>
  175. std::pair<iterator, bool> insert_check
  176. (const_iterator hint, const KeyType &key
  177. ,KeyTypeKeyCompare comp, insert_commit_data &commit_data)
  178. { return tree_type::insert_unique_check(hint, key, comp, commit_data); }
  179. //! @copydoc ::boost::intrusive::sgtree::insert_unique(Iterator,Iterator)
  180. template<class Iterator>
  181. void insert(Iterator b, Iterator e)
  182. { tree_type::insert_unique(b, e); }
  183. //! @copydoc ::boost::intrusive::sgtree::insert_unique_commit
  184. iterator insert_commit(reference value, const insert_commit_data &commit_data)
  185. { return tree_type::insert_unique_commit(value, commit_data); }
  186. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  187. //! @copydoc ::boost::intrusive::sgtree::insert_before
  188. iterator insert_before(const_iterator pos, reference value);
  189. //! @copydoc ::boost::intrusive::sgtree::push_back
  190. void push_back(reference value);
  191. //! @copydoc ::boost::intrusive::sgtree::push_front
  192. void push_front(reference value);
  193. //! @copydoc ::boost::intrusive::sgtree::erase(const_iterator)
  194. iterator erase(const_iterator i);
  195. //! @copydoc ::boost::intrusive::sgtree::erase(const_iterator,const_iterator)
  196. iterator erase(const_iterator b, const_iterator e);
  197. //! @copydoc ::boost::intrusive::sgtree::erase(const key_type &)
  198. size_type erase(const key_type &key);
  199. //! @copydoc ::boost::intrusive::sgtree::erase(const KeyType&,KeyTypeKeyCompare)
  200. template<class KeyType, class KeyTypeKeyCompare>
  201. size_type erase(const KeyType& key, KeyTypeKeyCompare comp);
  202. //! @copydoc ::boost::intrusive::sgtree::erase_and_dispose(const_iterator,Disposer)
  203. template<class Disposer>
  204. iterator erase_and_dispose(const_iterator i, Disposer disposer);
  205. //! @copydoc ::boost::intrusive::sgtree::erase_and_dispose(const_iterator,const_iterator,Disposer)
  206. template<class Disposer>
  207. iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
  208. //! @copydoc ::boost::intrusive::sgtree::erase_and_dispose(const key_type &, Disposer)
  209. template<class Disposer>
  210. size_type erase_and_dispose(const key_type &key, Disposer disposer);
  211. //! @copydoc ::boost::intrusive::sgtree::erase_and_dispose(const KeyType&,KeyTypeKeyCompare,Disposer)
  212. template<class KeyType, class KeyTypeKeyCompare, class Disposer>
  213. size_type erase_and_dispose(const KeyType& key, KeyTypeKeyCompare comp, Disposer disposer);
  214. //! @copydoc ::boost::intrusive::sgtree::clear
  215. void clear();
  216. //! @copydoc ::boost::intrusive::sgtree::clear_and_dispose
  217. template<class Disposer>
  218. void clear_and_dispose(Disposer disposer);
  219. #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  220. //! @copydoc ::boost::intrusive::sgtree::count(const key_type &)const
  221. size_type count(const key_type &key) const
  222. { return static_cast<size_type>(this->tree_type::find(key) != this->tree_type::cend()); }
  223. //! @copydoc ::boost::intrusive::sgtree::count(const KeyType&,KeyTypeKeyCompare)const
  224. template<class KeyType, class KeyTypeKeyCompare>
  225. size_type count(const KeyType& key, KeyTypeKeyCompare comp) const
  226. { return static_cast<size_type>(this->tree_type::find(key, comp) != this->tree_type::cend()); }
  227. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  228. //! @copydoc ::boost::intrusive::sgtree::lower_bound(const key_type &)
  229. iterator lower_bound(const key_type &key);
  230. //! @copydoc ::boost::intrusive::sgtree::lower_bound(const KeyType&,KeyTypeKeyCompare)
  231. template<class KeyType, class KeyTypeKeyCompare>
  232. iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp);
  233. //! @copydoc ::boost::intrusive::sgtree::lower_bound(const key_type &)const
  234. const_iterator lower_bound(const key_type &key) const;
  235. //! @copydoc ::boost::intrusive::sgtree::lower_bound(const KeyType&,KeyTypeKeyCompare)const
  236. template<class KeyType, class KeyTypeKeyCompare>
  237. const_iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  238. //! @copydoc ::boost::intrusive::sgtree::upper_bound(const key_type &)
  239. iterator upper_bound(const key_type &key);
  240. //! @copydoc ::boost::intrusive::sgtree::upper_bound(const KeyType&,KeyTypeKeyCompare)
  241. template<class KeyType, class KeyTypeKeyCompare>
  242. iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp);
  243. //! @copydoc ::boost::intrusive::sgtree::upper_bound(const key_type &)const
  244. const_iterator upper_bound(const key_type &key) const;
  245. //! @copydoc ::boost::intrusive::sgtree::upper_bound(const KeyType&,KeyTypeKeyCompare)const
  246. template<class KeyType, class KeyTypeKeyCompare>
  247. const_iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  248. //! @copydoc ::boost::intrusive::sgtree::find(const key_type &)
  249. iterator find(const key_type &key);
  250. //! @copydoc ::boost::intrusive::sgtree::find(const KeyType&,KeyTypeKeyCompare)
  251. template<class KeyType, class KeyTypeKeyCompare>
  252. iterator find(const KeyType& key, KeyTypeKeyCompare comp);
  253. //! @copydoc ::boost::intrusive::sgtree::find(const key_type &)const
  254. const_iterator find(const key_type &key) const;
  255. //! @copydoc ::boost::intrusive::sgtree::find(const KeyType&,KeyTypeKeyCompare)const
  256. template<class KeyType, class KeyTypeKeyCompare>
  257. const_iterator find(const KeyType& key, KeyTypeKeyCompare comp) const;
  258. #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  259. //! @copydoc ::boost::intrusive::sgtree::equal_range(const key_type &)
  260. std::pair<iterator,iterator> equal_range(const key_type &key)
  261. { return this->tree_type::lower_bound_range(key); }
  262. //! @copydoc ::boost::intrusive::sgtree::equal_range(const KeyType&,KeyTypeKeyCompare)
  263. template<class KeyType, class KeyTypeKeyCompare>
  264. std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp)
  265. { return this->tree_type::equal_range(key, comp); }
  266. //! @copydoc ::boost::intrusive::sgtree::equal_range(const key_type &)const
  267. std::pair<const_iterator, const_iterator>
  268. equal_range(const key_type &key) const
  269. { return this->tree_type::lower_bound_range(key); }
  270. //! @copydoc ::boost::intrusive::sgtree::equal_range(const KeyType&,KeyTypeKeyCompare)const
  271. template<class KeyType, class KeyTypeKeyCompare>
  272. std::pair<const_iterator, const_iterator>
  273. equal_range(const KeyType& key, KeyTypeKeyCompare comp) const
  274. { return this->tree_type::equal_range(key, comp); }
  275. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  276. //! @copydoc ::boost::intrusive::sgtree::bounded_range(const key_type &,const key_type &,bool,bool)
  277. std::pair<iterator,iterator> bounded_range
  278. (const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed);
  279. //! @copydoc ::boost::intrusive::sgtree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)
  280. template<class KeyType, class KeyTypeKeyCompare>
  281. std::pair<iterator,iterator> bounded_range
  282. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed);
  283. //! @copydoc ::boost::intrusive::sgtree::bounded_range(const key_type &,const key_type &,bool,bool)const
  284. std::pair<const_iterator, const_iterator>
  285. bounded_range(const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const;
  286. //! @copydoc ::boost::intrusive::sgtree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)const
  287. template<class KeyType, class KeyTypeKeyCompare>
  288. std::pair<const_iterator, const_iterator> bounded_range
  289. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const;
  290. //! @copydoc ::boost::intrusive::sgtree::s_iterator_to(reference)
  291. static iterator s_iterator_to(reference value);
  292. //! @copydoc ::boost::intrusive::sgtree::s_iterator_to(const_reference)
  293. static const_iterator s_iterator_to(const_reference value);
  294. //! @copydoc ::boost::intrusive::sgtree::iterator_to(reference)
  295. iterator iterator_to(reference value);
  296. //! @copydoc ::boost::intrusive::sgtree::iterator_to(const_reference)const
  297. const_iterator iterator_to(const_reference value) const;
  298. //! @copydoc ::boost::intrusive::sgtree::init_node(reference)
  299. static void init_node(reference value);
  300. //! @copydoc ::boost::intrusive::sgtree::unlink_leftmost_without_rebalance
  301. pointer unlink_leftmost_without_rebalance();
  302. //! @copydoc ::boost::intrusive::sgtree::replace_node
  303. void replace_node(iterator replace_this, reference with_this);
  304. //! @copydoc ::boost::intrusive::sgtree::remove_node
  305. void remove_node(reference value);
  306. //! @copydoc ::boost::intrusive::sgtree::rebalance
  307. void rebalance();
  308. //! @copydoc ::boost::intrusive::sgtree::rebalance_subtree
  309. iterator rebalance_subtree(iterator root);
  310. //! @copydoc ::boost::intrusive::sgtree::balance_factor()
  311. float balance_factor() const;
  312. //! @copydoc ::boost::intrusive::sgtree::balance_factor(float)
  313. void balance_factor(float new_alpha);
  314. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  315. };
  316. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  317. template<class T, class ...Options>
  318. bool operator!= (const sg_set_impl<T, Options...> &x, const sg_set_impl<T, Options...> &y);
  319. template<class T, class ...Options>
  320. bool operator>(const sg_set_impl<T, Options...> &x, const sg_set_impl<T, Options...> &y);
  321. template<class T, class ...Options>
  322. bool operator<=(const sg_set_impl<T, Options...> &x, const sg_set_impl<T, Options...> &y);
  323. template<class T, class ...Options>
  324. bool operator>=(const sg_set_impl<T, Options...> &x, const sg_set_impl<T, Options...> &y);
  325. template<class T, class ...Options>
  326. void swap(sg_set_impl<T, Options...> &x, sg_set_impl<T, Options...> &y);
  327. #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  328. //! Helper metafunction to define a \c sg_set that yields to the same type when the
  329. //! same options (either explicitly or implicitly) are used.
  330. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  331. template<class T, class ...Options>
  332. #else
  333. template<class T, class O1 = void, class O2 = void
  334. , class O3 = void, class O4 = void
  335. , class O5 = void, class O6 = void>
  336. #endif
  337. struct make_sg_set
  338. {
  339. /// @cond
  340. typedef typename pack_options
  341. < sgtree_defaults,
  342. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  343. O1, O2, O3, O4, O5, O6
  344. #else
  345. Options...
  346. #endif
  347. >::type packed_options;
  348. typedef typename detail::get_value_traits
  349. <T, typename packed_options::proto_value_traits>::type value_traits;
  350. typedef sg_set_impl
  351. < value_traits
  352. , typename packed_options::key_of_value
  353. , typename packed_options::compare
  354. , typename packed_options::size_type
  355. , packed_options::floating_point
  356. , typename packed_options::header_holder_type
  357. > implementation_defined;
  358. /// @endcond
  359. typedef implementation_defined type;
  360. };
  361. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  362. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  363. template<class T, class O1, class O2, class O3, class O4, class O5, class O6>
  364. #else
  365. template<class T, class ...Options>
  366. #endif
  367. class sg_set
  368. : public make_sg_set<T,
  369. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  370. O1, O2, O3, O4, O5, O6
  371. #else
  372. Options...
  373. #endif
  374. >::type
  375. {
  376. typedef typename make_sg_set
  377. <T,
  378. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  379. O1, O2, O3, O4, O5, O6
  380. #else
  381. Options...
  382. #endif
  383. >::type Base;
  384. BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_set)
  385. public:
  386. typedef typename Base::key_compare key_compare;
  387. typedef typename Base::value_traits value_traits;
  388. typedef typename Base::iterator iterator;
  389. typedef typename Base::const_iterator const_iterator;
  390. //Assert if passed value traits are compatible with the type
  391. BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
  392. sg_set()
  393. : Base()
  394. {}
  395. explicit sg_set( const key_compare &cmp, const value_traits &v_traits = value_traits())
  396. : Base(cmp, v_traits)
  397. {}
  398. template<class Iterator>
  399. sg_set( Iterator b, Iterator e
  400. , const key_compare &cmp = key_compare()
  401. , const value_traits &v_traits = value_traits())
  402. : Base(b, e, cmp, v_traits)
  403. {}
  404. sg_set(BOOST_RV_REF(sg_set) x)
  405. : Base(BOOST_MOVE_BASE(Base, x))
  406. {}
  407. sg_set& operator=(BOOST_RV_REF(sg_set) x)
  408. { return static_cast<sg_set &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  409. template <class Cloner, class Disposer>
  410. void clone_from(const sg_set &src, Cloner cloner, Disposer disposer)
  411. { Base::clone_from(src, cloner, disposer); }
  412. template <class Cloner, class Disposer>
  413. void clone_from(BOOST_RV_REF(sg_set) src, Cloner cloner, Disposer disposer)
  414. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  415. static sg_set &container_from_end_iterator(iterator end_iterator)
  416. { return static_cast<sg_set &>(Base::container_from_end_iterator(end_iterator)); }
  417. static const sg_set &container_from_end_iterator(const_iterator end_iterator)
  418. { return static_cast<const sg_set &>(Base::container_from_end_iterator(end_iterator)); }
  419. static sg_set &container_from_iterator(iterator it)
  420. { return static_cast<sg_set &>(Base::container_from_iterator(it)); }
  421. static const sg_set &container_from_iterator(const_iterator it)
  422. { return static_cast<const sg_set &>(Base::container_from_iterator(it)); }
  423. };
  424. #endif
  425. //! The class template sg_multiset is an intrusive container, that mimics most of
  426. //! the interface of std::sg_multiset as described in the C++ standard.
  427. //!
  428. //! The template parameter \c T is the type to be managed by the container.
  429. //! The user can specify additional options and if no options are provided
  430. //! default options are used.
  431. //!
  432. //! The container supports the following options:
  433. //! \c base_hook<>/member_hook<>/value_traits<>,
  434. //! \c floating_point<>, \c size_type<> and
  435. //! \c compare<>.
  436. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  437. template<class T, class ...Options>
  438. #else
  439. template<class ValueTraits, class VoidOrKeyOfValue, class Compare, class SizeType, bool FloatingPoint, typename HeaderHolder>
  440. #endif
  441. class sg_multiset_impl
  442. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  443. : public sgtree_impl<ValueTraits, VoidOrKeyOfValue, Compare, SizeType, FloatingPoint, HeaderHolder>
  444. #endif
  445. {
  446. /// @cond
  447. typedef sgtree_impl<ValueTraits, VoidOrKeyOfValue, Compare, SizeType, FloatingPoint, HeaderHolder> tree_type;
  448. BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_multiset_impl)
  449. typedef tree_type implementation_defined;
  450. /// @endcond
  451. public:
  452. typedef typename implementation_defined::value_type value_type;
  453. typedef typename implementation_defined::key_type key_type;
  454. typedef typename implementation_defined::key_of_value key_of_value;
  455. typedef typename implementation_defined::value_traits value_traits;
  456. typedef typename implementation_defined::pointer pointer;
  457. typedef typename implementation_defined::const_pointer const_pointer;
  458. typedef typename implementation_defined::reference reference;
  459. typedef typename implementation_defined::const_reference const_reference;
  460. typedef typename implementation_defined::difference_type difference_type;
  461. typedef typename implementation_defined::size_type size_type;
  462. typedef typename implementation_defined::value_compare value_compare;
  463. typedef typename implementation_defined::key_compare key_compare;
  464. typedef typename implementation_defined::iterator iterator;
  465. typedef typename implementation_defined::const_iterator const_iterator;
  466. typedef typename implementation_defined::reverse_iterator reverse_iterator;
  467. typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
  468. typedef typename implementation_defined::insert_commit_data insert_commit_data;
  469. typedef typename implementation_defined::node_traits node_traits;
  470. typedef typename implementation_defined::node node;
  471. typedef typename implementation_defined::node_ptr node_ptr;
  472. typedef typename implementation_defined::const_node_ptr const_node_ptr;
  473. typedef typename implementation_defined::node_algorithms node_algorithms;
  474. static const bool constant_time_size = tree_type::constant_time_size;
  475. public:
  476. //! @copydoc ::boost::intrusive::sgtree::sgtree()
  477. sg_multiset_impl()
  478. : tree_type()
  479. {}
  480. //! @copydoc ::boost::intrusive::sgtree::sgtree(const key_compare &,const value_traits &)
  481. explicit sg_multiset_impl( const key_compare &cmp, const value_traits &v_traits = value_traits())
  482. : tree_type(cmp, v_traits)
  483. {}
  484. //! @copydoc ::boost::intrusive::sgtree::sgtree(bool,Iterator,Iterator,const key_compare &,const value_traits &)
  485. template<class Iterator>
  486. sg_multiset_impl( Iterator b, Iterator e
  487. , const key_compare &cmp = key_compare()
  488. , const value_traits &v_traits = value_traits())
  489. : tree_type(false, b, e, cmp, v_traits)
  490. {}
  491. //! @copydoc ::boost::intrusive::sgtree::sgtree(sgtree &&)
  492. sg_multiset_impl(BOOST_RV_REF(sg_multiset_impl) x)
  493. : tree_type(BOOST_MOVE_BASE(tree_type, x))
  494. {}
  495. //! @copydoc ::boost::intrusive::sgtree::operator=(sgtree &&)
  496. sg_multiset_impl& operator=(BOOST_RV_REF(sg_multiset_impl) x)
  497. { return static_cast<sg_multiset_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }
  498. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  499. //! @copydoc ::boost::intrusive::sgtree::~sgtree()
  500. ~sg_multiset_impl();
  501. //! @copydoc ::boost::intrusive::sgtree::begin()
  502. iterator begin();
  503. //! @copydoc ::boost::intrusive::sgtree::begin()const
  504. const_iterator begin() const;
  505. //! @copydoc ::boost::intrusive::sgtree::cbegin()const
  506. const_iterator cbegin() const;
  507. //! @copydoc ::boost::intrusive::sgtree::end()
  508. iterator end();
  509. //! @copydoc ::boost::intrusive::sgtree::end()const
  510. const_iterator end() const;
  511. //! @copydoc ::boost::intrusive::sgtree::cend()const
  512. const_iterator cend() const;
  513. //! @copydoc ::boost::intrusive::sgtree::rbegin()
  514. reverse_iterator rbegin();
  515. //! @copydoc ::boost::intrusive::sgtree::rbegin()const
  516. const_reverse_iterator rbegin() const;
  517. //! @copydoc ::boost::intrusive::sgtree::crbegin()const
  518. const_reverse_iterator crbegin() const;
  519. //! @copydoc ::boost::intrusive::sgtree::rend()
  520. reverse_iterator rend();
  521. //! @copydoc ::boost::intrusive::sgtree::rend()const
  522. const_reverse_iterator rend() const;
  523. //! @copydoc ::boost::intrusive::sgtree::crend()const
  524. const_reverse_iterator crend() const;
  525. //! @copydoc ::boost::intrusive::sgtree::container_from_end_iterator(iterator)
  526. static sg_multiset_impl &container_from_end_iterator(iterator end_iterator);
  527. //! @copydoc ::boost::intrusive::sgtree::container_from_end_iterator(const_iterator)
  528. static const sg_multiset_impl &container_from_end_iterator(const_iterator end_iterator);
  529. //! @copydoc ::boost::intrusive::sgtree::container_from_iterator(iterator)
  530. static sg_multiset_impl &container_from_iterator(iterator it);
  531. //! @copydoc ::boost::intrusive::sgtree::container_from_iterator(const_iterator)
  532. static const sg_multiset_impl &container_from_iterator(const_iterator it);
  533. //! @copydoc ::boost::intrusive::sgtree::key_comp()const
  534. key_compare key_comp() const;
  535. //! @copydoc ::boost::intrusive::sgtree::value_comp()const
  536. value_compare value_comp() const;
  537. //! @copydoc ::boost::intrusive::sgtree::empty()const
  538. bool empty() const;
  539. //! @copydoc ::boost::intrusive::sgtree::size()const
  540. size_type size() const;
  541. //! @copydoc ::boost::intrusive::sgtree::swap
  542. void swap(sg_multiset_impl& other);
  543. //! @copydoc ::boost::intrusive::sgtree::clone_from(const sgtree&,Cloner,Disposer)
  544. template <class Cloner, class Disposer>
  545. void clone_from(const sg_multiset_impl &src, Cloner cloner, Disposer disposer);
  546. #else
  547. using tree_type::clone_from;
  548. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  549. //! @copydoc ::boost::intrusive::sgtree::clone_from(sgtree&&,Cloner,Disposer)
  550. template <class Cloner, class Disposer>
  551. void clone_from(BOOST_RV_REF(sg_multiset_impl) src, Cloner cloner, Disposer disposer)
  552. { tree_type::clone_from(BOOST_MOVE_BASE(tree_type, src), cloner, disposer); }
  553. //! @copydoc ::boost::intrusive::sgtree::insert_equal(reference)
  554. iterator insert(reference value)
  555. { return tree_type::insert_equal(value); }
  556. //! @copydoc ::boost::intrusive::sgtree::insert_equal(const_iterator,reference)
  557. iterator insert(const_iterator hint, reference value)
  558. { return tree_type::insert_equal(hint, value); }
  559. //! @copydoc ::boost::intrusive::sgtree::insert_equal(Iterator,Iterator)
  560. template<class Iterator>
  561. void insert(Iterator b, Iterator e)
  562. { tree_type::insert_equal(b, e); }
  563. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  564. //! @copydoc ::boost::intrusive::sgtree::insert_before
  565. iterator insert_before(const_iterator pos, reference value);
  566. //! @copydoc ::boost::intrusive::sgtree::push_back
  567. void push_back(reference value);
  568. //! @copydoc ::boost::intrusive::sgtree::push_front
  569. void push_front(reference value);
  570. //! @copydoc ::boost::intrusive::sgtree::erase(const_iterator)
  571. iterator erase(const_iterator i);
  572. //! @copydoc ::boost::intrusive::sgtree::erase(const_iterator,const_iterator)
  573. iterator erase(const_iterator b, const_iterator e);
  574. //! @copydoc ::boost::intrusive::sgtree::erase(const key_type &)
  575. size_type erase(const key_type &key);
  576. //! @copydoc ::boost::intrusive::sgtree::erase(const KeyType&,KeyTypeKeyCompare)
  577. template<class KeyType, class KeyTypeKeyCompare>
  578. size_type erase(const KeyType& key, KeyTypeKeyCompare comp);
  579. //! @copydoc ::boost::intrusive::sgtree::erase_and_dispose(const_iterator,Disposer)
  580. template<class Disposer>
  581. iterator erase_and_dispose(const_iterator i, Disposer disposer);
  582. //! @copydoc ::boost::intrusive::sgtree::erase_and_dispose(const_iterator,const_iterator,Disposer)
  583. template<class Disposer>
  584. iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
  585. //! @copydoc ::boost::intrusive::sgtree::erase_and_dispose(const key_type &, Disposer)
  586. template<class Disposer>
  587. size_type erase_and_dispose(const key_type &key, Disposer disposer);
  588. //! @copydoc ::boost::intrusive::sgtree::erase_and_dispose(const KeyType&,KeyTypeKeyCompare,Disposer)
  589. template<class KeyType, class KeyTypeKeyCompare, class Disposer>
  590. size_type erase_and_dispose(const KeyType& key, KeyTypeKeyCompare comp, Disposer disposer);
  591. //! @copydoc ::boost::intrusive::sgtree::clear
  592. void clear();
  593. //! @copydoc ::boost::intrusive::sgtree::clear_and_dispose
  594. template<class Disposer>
  595. void clear_and_dispose(Disposer disposer);
  596. //! @copydoc ::boost::intrusive::sgtree::count(const key_type &)const
  597. size_type count(const key_type &key) const;
  598. //! @copydoc ::boost::intrusive::sgtree::count(const KeyType&,KeyTypeKeyCompare)const
  599. template<class KeyType, class KeyTypeKeyCompare>
  600. size_type count(const KeyType& key, KeyTypeKeyCompare comp) const;
  601. //! @copydoc ::boost::intrusive::sgtree::lower_bound(const key_type &)
  602. iterator lower_bound(const key_type &key);
  603. //! @copydoc ::boost::intrusive::sgtree::lower_bound(const KeyType&,KeyTypeKeyCompare)
  604. template<class KeyType, class KeyTypeKeyCompare>
  605. iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp);
  606. //! @copydoc ::boost::intrusive::sgtree::lower_bound(const key_type &)const
  607. const_iterator lower_bound(const key_type &key) const;
  608. //! @copydoc ::boost::intrusive::sgtree::lower_bound(const KeyType&,KeyTypeKeyCompare)const
  609. template<class KeyType, class KeyTypeKeyCompare>
  610. const_iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  611. //! @copydoc ::boost::intrusive::sgtree::upper_bound(const key_type &)
  612. iterator upper_bound(const key_type &key);
  613. //! @copydoc ::boost::intrusive::sgtree::upper_bound(const KeyType&,KeyTypeKeyCompare)
  614. template<class KeyType, class KeyTypeKeyCompare>
  615. iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp);
  616. //! @copydoc ::boost::intrusive::sgtree::upper_bound(const key_type &)const
  617. const_iterator upper_bound(const key_type &key) const;
  618. //! @copydoc ::boost::intrusive::sgtree::upper_bound(const KeyType&,KeyTypeKeyCompare)const
  619. template<class KeyType, class KeyTypeKeyCompare>
  620. const_iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  621. //! @copydoc ::boost::intrusive::sgtree::find(const key_type &)
  622. iterator find(const key_type &key);
  623. //! @copydoc ::boost::intrusive::sgtree::find(const KeyType&,KeyTypeKeyCompare)
  624. template<class KeyType, class KeyTypeKeyCompare>
  625. iterator find(const KeyType& key, KeyTypeKeyCompare comp);
  626. //! @copydoc ::boost::intrusive::sgtree::find(const key_type &)const
  627. const_iterator find(const key_type &key) const;
  628. //! @copydoc ::boost::intrusive::sgtree::find(const KeyType&,KeyTypeKeyCompare)const
  629. template<class KeyType, class KeyTypeKeyCompare>
  630. const_iterator find(const KeyType& key, KeyTypeKeyCompare comp) const;
  631. //! @copydoc ::boost::intrusive::sgtree::equal_range(const key_type &)
  632. std::pair<iterator,iterator> equal_range(const key_type &key);
  633. //! @copydoc ::boost::intrusive::sgtree::equal_range(const KeyType&,KeyTypeKeyCompare)
  634. template<class KeyType, class KeyTypeKeyCompare>
  635. std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp);
  636. //! @copydoc ::boost::intrusive::sgtree::equal_range(const key_type &)const
  637. std::pair<const_iterator, const_iterator>
  638. equal_range(const key_type &key) const;
  639. //! @copydoc ::boost::intrusive::sgtree::equal_range(const KeyType&,KeyTypeKeyCompare)const
  640. template<class KeyType, class KeyTypeKeyCompare>
  641. std::pair<const_iterator, const_iterator>
  642. equal_range(const KeyType& key, KeyTypeKeyCompare comp) const;
  643. //! @copydoc ::boost::intrusive::sgtree::bounded_range(const key_type &,const key_type &,bool,bool)
  644. std::pair<iterator,iterator> bounded_range
  645. (const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed);
  646. //! @copydoc ::boost::intrusive::sgtree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)
  647. template<class KeyType, class KeyTypeKeyCompare>
  648. std::pair<iterator,iterator> bounded_range
  649. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed);
  650. //! @copydoc ::boost::intrusive::sgtree::bounded_range(const key_type &,const key_type &,bool,bool)const
  651. std::pair<const_iterator, const_iterator>
  652. bounded_range(const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const;
  653. //! @copydoc ::boost::intrusive::sgtree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)const
  654. template<class KeyType, class KeyTypeKeyCompare>
  655. std::pair<const_iterator, const_iterator> bounded_range
  656. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const;
  657. //! @copydoc ::boost::intrusive::sgtree::s_iterator_to(reference)
  658. static iterator s_iterator_to(reference value);
  659. //! @copydoc ::boost::intrusive::sgtree::s_iterator_to(const_reference)
  660. static const_iterator s_iterator_to(const_reference value);
  661. //! @copydoc ::boost::intrusive::sgtree::iterator_to(reference)
  662. iterator iterator_to(reference value);
  663. //! @copydoc ::boost::intrusive::sgtree::iterator_to(const_reference)const
  664. const_iterator iterator_to(const_reference value) const;
  665. //! @copydoc ::boost::intrusive::sgtree::init_node(reference)
  666. static void init_node(reference value);
  667. //! @copydoc ::boost::intrusive::sgtree::unlink_leftmost_without_rebalance
  668. pointer unlink_leftmost_without_rebalance();
  669. //! @copydoc ::boost::intrusive::sgtree::replace_node
  670. void replace_node(iterator replace_this, reference with_this);
  671. //! @copydoc ::boost::intrusive::sgtree::remove_node
  672. void remove_node(reference value);
  673. //! @copydoc ::boost::intrusive::sgtree::rebalance
  674. void rebalance();
  675. //! @copydoc ::boost::intrusive::sgtree::rebalance_subtree
  676. iterator rebalance_subtree(iterator root);
  677. //! @copydoc ::boost::intrusive::sgtree::balance_factor()
  678. float balance_factor() const;
  679. //! @copydoc ::boost::intrusive::sgtree::balance_factor(float)
  680. void balance_factor(float new_alpha);
  681. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  682. };
  683. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  684. template<class T, class ...Options>
  685. bool operator!= (const sg_multiset_impl<T, Options...> &x, const sg_multiset_impl<T, Options...> &y);
  686. template<class T, class ...Options>
  687. bool operator>(const sg_multiset_impl<T, Options...> &x, const sg_multiset_impl<T, Options...> &y);
  688. template<class T, class ...Options>
  689. bool operator<=(const sg_multiset_impl<T, Options...> &x, const sg_multiset_impl<T, Options...> &y);
  690. template<class T, class ...Options>
  691. bool operator>=(const sg_multiset_impl<T, Options...> &x, const sg_multiset_impl<T, Options...> &y);
  692. template<class T, class ...Options>
  693. void swap(sg_multiset_impl<T, Options...> &x, sg_multiset_impl<T, Options...> &y);
  694. #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  695. //! Helper metafunction to define a \c sg_multiset that yields to the same type when the
  696. //! same options (either explicitly or implicitly) are used.
  697. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  698. template<class T, class ...Options>
  699. #else
  700. template<class T, class O1 = void, class O2 = void
  701. , class O3 = void, class O4 = void
  702. , class O5 = void, class O6 = void>
  703. #endif
  704. struct make_sg_multiset
  705. {
  706. /// @cond
  707. typedef typename pack_options
  708. < sgtree_defaults,
  709. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  710. O1, O2, O3, O4, O5, O6
  711. #else
  712. Options...
  713. #endif
  714. >::type packed_options;
  715. typedef typename detail::get_value_traits
  716. <T, typename packed_options::proto_value_traits>::type value_traits;
  717. typedef sg_multiset_impl
  718. < value_traits
  719. , typename packed_options::key_of_value
  720. , typename packed_options::compare
  721. , typename packed_options::size_type
  722. , packed_options::floating_point
  723. , typename packed_options::header_holder_type
  724. > implementation_defined;
  725. /// @endcond
  726. typedef implementation_defined type;
  727. };
  728. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  729. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  730. template<class T, class O1, class O2, class O3, class O4, class O5, class O6>
  731. #else
  732. template<class T, class ...Options>
  733. #endif
  734. class sg_multiset
  735. : public make_sg_multiset<T,
  736. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  737. O1, O2, O3, O4, O5, O6
  738. #else
  739. Options...
  740. #endif
  741. >::type
  742. {
  743. typedef typename make_sg_multiset<T,
  744. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  745. O1, O2, O3, O4, O5, O6
  746. #else
  747. Options...
  748. #endif
  749. >::type Base;
  750. BOOST_MOVABLE_BUT_NOT_COPYABLE(sg_multiset)
  751. public:
  752. typedef typename Base::key_compare key_compare;
  753. typedef typename Base::value_traits value_traits;
  754. typedef typename Base::iterator iterator;
  755. typedef typename Base::const_iterator const_iterator;
  756. //Assert if passed value traits are compatible with the type
  757. BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
  758. sg_multiset()
  759. : Base()
  760. {}
  761. explicit sg_multiset( const key_compare &cmp, const value_traits &v_traits = value_traits())
  762. : Base(cmp, v_traits)
  763. {}
  764. template<class Iterator>
  765. sg_multiset( Iterator b, Iterator e
  766. , const key_compare &cmp = key_compare()
  767. , const value_traits &v_traits = value_traits())
  768. : Base(b, e, cmp, v_traits)
  769. {}
  770. sg_multiset(BOOST_RV_REF(sg_multiset) x)
  771. : Base(BOOST_MOVE_BASE(Base, x))
  772. {}
  773. sg_multiset& operator=(BOOST_RV_REF(sg_multiset) x)
  774. { return static_cast<sg_multiset &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  775. template <class Cloner, class Disposer>
  776. void clone_from(const sg_multiset &src, Cloner cloner, Disposer disposer)
  777. { Base::clone_from(src, cloner, disposer); }
  778. template <class Cloner, class Disposer>
  779. void clone_from(BOOST_RV_REF(sg_multiset) src, Cloner cloner, Disposer disposer)
  780. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  781. static sg_multiset &container_from_end_iterator(iterator end_iterator)
  782. { return static_cast<sg_multiset &>(Base::container_from_end_iterator(end_iterator)); }
  783. static const sg_multiset &container_from_end_iterator(const_iterator end_iterator)
  784. { return static_cast<const sg_multiset &>(Base::container_from_end_iterator(end_iterator)); }
  785. static sg_multiset &container_from_iterator(iterator it)
  786. { return static_cast<sg_multiset &>(Base::container_from_iterator(it)); }
  787. static const sg_multiset &container_from_iterator(const_iterator it)
  788. { return static_cast<const sg_multiset &>(Base::container_from_iterator(it)); }
  789. };
  790. #endif
  791. } //namespace intrusive
  792. } //namespace boost
  793. #include <boost/intrusive/detail/config_end.hpp>
  794. #endif //BOOST_INTRUSIVE_SG_SET_HPP