set.hpp 44 KB

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