bs_set.hpp 44 KB

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