set 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_SET
  10. #define _LIBCPP_SET
  11. /*
  12. set synopsis
  13. namespace std
  14. {
  15. template <class Key, class Compare = less<Key>,
  16. class Allocator = allocator<Key>>
  17. class set
  18. {
  19. public:
  20. // types:
  21. typedef Key key_type;
  22. typedef key_type value_type;
  23. typedef Compare key_compare;
  24. typedef key_compare value_compare;
  25. typedef Allocator allocator_type;
  26. typedef typename allocator_type::reference reference;
  27. typedef typename allocator_type::const_reference const_reference;
  28. typedef typename allocator_type::size_type size_type;
  29. typedef typename allocator_type::difference_type difference_type;
  30. typedef typename allocator_type::pointer pointer;
  31. typedef typename allocator_type::const_pointer const_pointer;
  32. typedef implementation-defined iterator;
  33. typedef implementation-defined const_iterator;
  34. typedef std::reverse_iterator<iterator> reverse_iterator;
  35. typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
  36. typedef unspecified node_type; // C++17
  37. typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
  38. // construct/copy/destroy:
  39. set()
  40. noexcept(
  41. is_nothrow_default_constructible<allocator_type>::value &&
  42. is_nothrow_default_constructible<key_compare>::value &&
  43. is_nothrow_copy_constructible<key_compare>::value);
  44. explicit set(const value_compare& comp);
  45. set(const value_compare& comp, const allocator_type& a);
  46. template <class InputIterator>
  47. set(InputIterator first, InputIterator last,
  48. const value_compare& comp = value_compare());
  49. template <class InputIterator>
  50. set(InputIterator first, InputIterator last, const value_compare& comp,
  51. const allocator_type& a);
  52. set(const set& s);
  53. set(set&& s)
  54. noexcept(
  55. is_nothrow_move_constructible<allocator_type>::value &&
  56. is_nothrow_move_constructible<key_compare>::value);
  57. explicit set(const allocator_type& a);
  58. set(const set& s, const allocator_type& a);
  59. set(set&& s, const allocator_type& a);
  60. set(initializer_list<value_type> il, const value_compare& comp = value_compare());
  61. set(initializer_list<value_type> il, const value_compare& comp,
  62. const allocator_type& a);
  63. template <class InputIterator>
  64. set(InputIterator first, InputIterator last, const allocator_type& a)
  65. : set(first, last, Compare(), a) {} // C++14
  66. set(initializer_list<value_type> il, const allocator_type& a)
  67. : set(il, Compare(), a) {} // C++14
  68. ~set();
  69. set& operator=(const set& s);
  70. set& operator=(set&& s)
  71. noexcept(
  72. allocator_type::propagate_on_container_move_assignment::value &&
  73. is_nothrow_move_assignable<allocator_type>::value &&
  74. is_nothrow_move_assignable<key_compare>::value);
  75. set& operator=(initializer_list<value_type> il);
  76. // iterators:
  77. iterator begin() noexcept;
  78. const_iterator begin() const noexcept;
  79. iterator end() noexcept;
  80. const_iterator end() const noexcept;
  81. reverse_iterator rbegin() noexcept;
  82. const_reverse_iterator rbegin() const noexcept;
  83. reverse_iterator rend() noexcept;
  84. const_reverse_iterator rend() const noexcept;
  85. const_iterator cbegin() const noexcept;
  86. const_iterator cend() const noexcept;
  87. const_reverse_iterator crbegin() const noexcept;
  88. const_reverse_iterator crend() const noexcept;
  89. // capacity:
  90. bool empty() const noexcept;
  91. size_type size() const noexcept;
  92. size_type max_size() const noexcept;
  93. // modifiers:
  94. template <class... Args>
  95. pair<iterator, bool> emplace(Args&&... args);
  96. template <class... Args>
  97. iterator emplace_hint(const_iterator position, Args&&... args);
  98. pair<iterator,bool> insert(const value_type& v);
  99. pair<iterator,bool> insert(value_type&& v);
  100. iterator insert(const_iterator position, const value_type& v);
  101. iterator insert(const_iterator position, value_type&& v);
  102. template <class InputIterator>
  103. void insert(InputIterator first, InputIterator last);
  104. void insert(initializer_list<value_type> il);
  105. node_type extract(const_iterator position); // C++17
  106. node_type extract(const key_type& x); // C++17
  107. insert_return_type insert(node_type&& nh); // C++17
  108. iterator insert(const_iterator hint, node_type&& nh); // C++17
  109. iterator erase(const_iterator position);
  110. iterator erase(iterator position); // C++14
  111. size_type erase(const key_type& k);
  112. iterator erase(const_iterator first, const_iterator last);
  113. void clear() noexcept;
  114. template<class C2>
  115. void merge(set<Key, C2, Allocator>& source); // C++17
  116. template<class C2>
  117. void merge(set<Key, C2, Allocator>&& source); // C++17
  118. template<class C2>
  119. void merge(multiset<Key, C2, Allocator>& source); // C++17
  120. template<class C2>
  121. void merge(multiset<Key, C2, Allocator>&& source); // C++17
  122. void swap(set& s)
  123. noexcept(
  124. __is_nothrow_swappable<key_compare>::value &&
  125. (!allocator_type::propagate_on_container_swap::value ||
  126. __is_nothrow_swappable<allocator_type>::value));
  127. // observers:
  128. allocator_type get_allocator() const noexcept;
  129. key_compare key_comp() const;
  130. value_compare value_comp() const;
  131. // set operations:
  132. iterator find(const key_type& k);
  133. const_iterator find(const key_type& k) const;
  134. template<typename K>
  135. iterator find(const K& x);
  136. template<typename K>
  137. const_iterator find(const K& x) const; // C++14
  138. template<typename K>
  139. size_type count(const K& x) const; // C++14
  140. size_type count(const key_type& k) const;
  141. bool contains(const key_type& x) const; // C++20
  142. template<class K> bool contains(const K& x) const; // C++20
  143. iterator lower_bound(const key_type& k);
  144. const_iterator lower_bound(const key_type& k) const;
  145. template<typename K>
  146. iterator lower_bound(const K& x); // C++14
  147. template<typename K>
  148. const_iterator lower_bound(const K& x) const; // C++14
  149. iterator upper_bound(const key_type& k);
  150. const_iterator upper_bound(const key_type& k) const;
  151. template<typename K>
  152. iterator upper_bound(const K& x); // C++14
  153. template<typename K>
  154. const_iterator upper_bound(const K& x) const; // C++14
  155. pair<iterator,iterator> equal_range(const key_type& k);
  156. pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
  157. template<typename K>
  158. pair<iterator,iterator> equal_range(const K& x); // C++14
  159. template<typename K>
  160. pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
  161. };
  162. template <class InputIterator,
  163. class Compare = less<typename iterator_traits<InputIterator>::value_type>,
  164. class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
  165. set(InputIterator, InputIterator,
  166. Compare = Compare(), Allocator = Allocator())
  167. -> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17
  168. template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
  169. set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
  170. -> set<Key, Compare, Allocator>; // C++17
  171. template<class InputIterator, class Allocator>
  172. set(InputIterator, InputIterator, Allocator)
  173. -> set<typename iterator_traits<InputIterator>::value_type,
  174. less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
  175. template<class Key, class Allocator>
  176. set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>; // C++17
  177. template <class Key, class Compare, class Allocator>
  178. bool
  179. operator==(const set<Key, Compare, Allocator>& x,
  180. const set<Key, Compare, Allocator>& y);
  181. template <class Key, class Compare, class Allocator>
  182. bool
  183. operator< (const set<Key, Compare, Allocator>& x,
  184. const set<Key, Compare, Allocator>& y);
  185. template <class Key, class Compare, class Allocator>
  186. bool
  187. operator!=(const set<Key, Compare, Allocator>& x,
  188. const set<Key, Compare, Allocator>& y);
  189. template <class Key, class Compare, class Allocator>
  190. bool
  191. operator> (const set<Key, Compare, Allocator>& x,
  192. const set<Key, Compare, Allocator>& y);
  193. template <class Key, class Compare, class Allocator>
  194. bool
  195. operator>=(const set<Key, Compare, Allocator>& x,
  196. const set<Key, Compare, Allocator>& y);
  197. template <class Key, class Compare, class Allocator>
  198. bool
  199. operator<=(const set<Key, Compare, Allocator>& x,
  200. const set<Key, Compare, Allocator>& y);
  201. // specialized algorithms:
  202. template <class Key, class Compare, class Allocator>
  203. void
  204. swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
  205. noexcept(noexcept(x.swap(y)));
  206. template <class Key, class Compare, class Allocator, class Predicate>
  207. typename set<Key, Compare, Allocator>::size_type
  208. erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20
  209. template <class Key, class Compare = less<Key>,
  210. class Allocator = allocator<Key>>
  211. class multiset
  212. {
  213. public:
  214. // types:
  215. typedef Key key_type;
  216. typedef key_type value_type;
  217. typedef Compare key_compare;
  218. typedef key_compare value_compare;
  219. typedef Allocator allocator_type;
  220. typedef typename allocator_type::reference reference;
  221. typedef typename allocator_type::const_reference const_reference;
  222. typedef typename allocator_type::size_type size_type;
  223. typedef typename allocator_type::difference_type difference_type;
  224. typedef typename allocator_type::pointer pointer;
  225. typedef typename allocator_type::const_pointer const_pointer;
  226. typedef implementation-defined iterator;
  227. typedef implementation-defined const_iterator;
  228. typedef std::reverse_iterator<iterator> reverse_iterator;
  229. typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
  230. typedef unspecified node_type; // C++17
  231. // construct/copy/destroy:
  232. multiset()
  233. noexcept(
  234. is_nothrow_default_constructible<allocator_type>::value &&
  235. is_nothrow_default_constructible<key_compare>::value &&
  236. is_nothrow_copy_constructible<key_compare>::value);
  237. explicit multiset(const value_compare& comp);
  238. multiset(const value_compare& comp, const allocator_type& a);
  239. template <class InputIterator>
  240. multiset(InputIterator first, InputIterator last,
  241. const value_compare& comp = value_compare());
  242. template <class InputIterator>
  243. multiset(InputIterator first, InputIterator last,
  244. const value_compare& comp, const allocator_type& a);
  245. multiset(const multiset& s);
  246. multiset(multiset&& s)
  247. noexcept(
  248. is_nothrow_move_constructible<allocator_type>::value &&
  249. is_nothrow_move_constructible<key_compare>::value);
  250. explicit multiset(const allocator_type& a);
  251. multiset(const multiset& s, const allocator_type& a);
  252. multiset(multiset&& s, const allocator_type& a);
  253. multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
  254. multiset(initializer_list<value_type> il, const value_compare& comp,
  255. const allocator_type& a);
  256. template <class InputIterator>
  257. multiset(InputIterator first, InputIterator last, const allocator_type& a)
  258. : set(first, last, Compare(), a) {} // C++14
  259. multiset(initializer_list<value_type> il, const allocator_type& a)
  260. : set(il, Compare(), a) {} // C++14
  261. ~multiset();
  262. multiset& operator=(const multiset& s);
  263. multiset& operator=(multiset&& s)
  264. noexcept(
  265. allocator_type::propagate_on_container_move_assignment::value &&
  266. is_nothrow_move_assignable<allocator_type>::value &&
  267. is_nothrow_move_assignable<key_compare>::value);
  268. multiset& operator=(initializer_list<value_type> il);
  269. // iterators:
  270. iterator begin() noexcept;
  271. const_iterator begin() const noexcept;
  272. iterator end() noexcept;
  273. const_iterator end() const noexcept;
  274. reverse_iterator rbegin() noexcept;
  275. const_reverse_iterator rbegin() const noexcept;
  276. reverse_iterator rend() noexcept;
  277. const_reverse_iterator rend() const noexcept;
  278. const_iterator cbegin() const noexcept;
  279. const_iterator cend() const noexcept;
  280. const_reverse_iterator crbegin() const noexcept;
  281. const_reverse_iterator crend() const noexcept;
  282. // capacity:
  283. bool empty() const noexcept;
  284. size_type size() const noexcept;
  285. size_type max_size() const noexcept;
  286. // modifiers:
  287. template <class... Args>
  288. iterator emplace(Args&&... args);
  289. template <class... Args>
  290. iterator emplace_hint(const_iterator position, Args&&... args);
  291. iterator insert(const value_type& v);
  292. iterator insert(value_type&& v);
  293. iterator insert(const_iterator position, const value_type& v);
  294. iterator insert(const_iterator position, value_type&& v);
  295. template <class InputIterator>
  296. void insert(InputIterator first, InputIterator last);
  297. void insert(initializer_list<value_type> il);
  298. node_type extract(const_iterator position); // C++17
  299. node_type extract(const key_type& x); // C++17
  300. iterator insert(node_type&& nh); // C++17
  301. iterator insert(const_iterator hint, node_type&& nh); // C++17
  302. iterator erase(const_iterator position);
  303. iterator erase(iterator position); // C++14
  304. size_type erase(const key_type& k);
  305. iterator erase(const_iterator first, const_iterator last);
  306. void clear() noexcept;
  307. template<class C2>
  308. void merge(multiset<Key, C2, Allocator>& source); // C++17
  309. template<class C2>
  310. void merge(multiset<Key, C2, Allocator>&& source); // C++17
  311. template<class C2>
  312. void merge(set<Key, C2, Allocator>& source); // C++17
  313. template<class C2>
  314. void merge(set<Key, C2, Allocator>&& source); // C++17
  315. void swap(multiset& s)
  316. noexcept(
  317. __is_nothrow_swappable<key_compare>::value &&
  318. (!allocator_type::propagate_on_container_swap::value ||
  319. __is_nothrow_swappable<allocator_type>::value));
  320. // observers:
  321. allocator_type get_allocator() const noexcept;
  322. key_compare key_comp() const;
  323. value_compare value_comp() const;
  324. // set operations:
  325. iterator find(const key_type& k);
  326. const_iterator find(const key_type& k) const;
  327. template<typename K>
  328. iterator find(const K& x);
  329. template<typename K>
  330. const_iterator find(const K& x) const; // C++14
  331. template<typename K>
  332. size_type count(const K& x) const; // C++14
  333. size_type count(const key_type& k) const;
  334. bool contains(const key_type& x) const; // C++20
  335. template<class K> bool contains(const K& x) const; // C++20
  336. iterator lower_bound(const key_type& k);
  337. const_iterator lower_bound(const key_type& k) const;
  338. template<typename K>
  339. iterator lower_bound(const K& x); // C++14
  340. template<typename K>
  341. const_iterator lower_bound(const K& x) const; // C++14
  342. iterator upper_bound(const key_type& k);
  343. const_iterator upper_bound(const key_type& k) const;
  344. template<typename K>
  345. iterator upper_bound(const K& x); // C++14
  346. template<typename K>
  347. const_iterator upper_bound(const K& x) const; // C++14
  348. pair<iterator,iterator> equal_range(const key_type& k);
  349. pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
  350. template<typename K>
  351. pair<iterator,iterator> equal_range(const K& x); // C++14
  352. template<typename K>
  353. pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
  354. };
  355. template <class InputIterator,
  356. class Compare = less<typename iterator_traits<InputIterator>::value_type>,
  357. class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
  358. multiset(InputIterator, InputIterator,
  359. Compare = Compare(), Allocator = Allocator())
  360. -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17
  361. template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
  362. multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
  363. -> multiset<Key, Compare, Allocator>; // C++17
  364. template<class InputIterator, class Allocator>
  365. multiset(InputIterator, InputIterator, Allocator)
  366. -> multiset<typename iterator_traits<InputIterator>::value_type,
  367. less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
  368. template<class Key, class Allocator>
  369. multiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>; // C++17
  370. template <class Key, class Compare, class Allocator>
  371. bool
  372. operator==(const multiset<Key, Compare, Allocator>& x,
  373. const multiset<Key, Compare, Allocator>& y);
  374. template <class Key, class Compare, class Allocator>
  375. bool
  376. operator< (const multiset<Key, Compare, Allocator>& x,
  377. const multiset<Key, Compare, Allocator>& y);
  378. template <class Key, class Compare, class Allocator>
  379. bool
  380. operator!=(const multiset<Key, Compare, Allocator>& x,
  381. const multiset<Key, Compare, Allocator>& y);
  382. template <class Key, class Compare, class Allocator>
  383. bool
  384. operator> (const multiset<Key, Compare, Allocator>& x,
  385. const multiset<Key, Compare, Allocator>& y);
  386. template <class Key, class Compare, class Allocator>
  387. bool
  388. operator>=(const multiset<Key, Compare, Allocator>& x,
  389. const multiset<Key, Compare, Allocator>& y);
  390. template <class Key, class Compare, class Allocator>
  391. bool
  392. operator<=(const multiset<Key, Compare, Allocator>& x,
  393. const multiset<Key, Compare, Allocator>& y);
  394. // specialized algorithms:
  395. template <class Key, class Compare, class Allocator>
  396. void
  397. swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
  398. noexcept(noexcept(x.swap(y)));
  399. template <class Key, class Compare, class Allocator, class Predicate>
  400. typename multiset<Key, Compare, Allocator>::size_type
  401. erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
  402. } // std
  403. */
  404. #include <__algorithm/equal.h>
  405. #include <__algorithm/lexicographical_compare.h>
  406. #include <__assert>
  407. #include <__config>
  408. #include <__functional/is_transparent.h>
  409. #include <__iterator/iterator_traits.h>
  410. #include <__node_handle>
  411. #include <__tree>
  412. #include <__utility/forward.h>
  413. #include <compare>
  414. #include <functional>
  415. #include <initializer_list>
  416. #include <iterator> // __libcpp_erase_if_container
  417. #include <version>
  418. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  419. # pragma GCC system_header
  420. #endif
  421. _LIBCPP_BEGIN_NAMESPACE_STD
  422. template <class _Key, class _Compare, class _Allocator>
  423. class multiset;
  424. template <class _Key, class _Compare = less<_Key>,
  425. class _Allocator = allocator<_Key> >
  426. class _LIBCPP_TEMPLATE_VIS set
  427. {
  428. public:
  429. // types:
  430. typedef _Key key_type;
  431. typedef key_type value_type;
  432. typedef __identity_t<_Compare> key_compare;
  433. typedef key_compare value_compare;
  434. typedef __identity_t<_Allocator> allocator_type;
  435. typedef value_type& reference;
  436. typedef const value_type& const_reference;
  437. static_assert((is_same<typename allocator_type::value_type, value_type>::value),
  438. "Allocator::value_type must be same type as value_type");
  439. private:
  440. typedef __tree<value_type, value_compare, allocator_type> __base;
  441. typedef allocator_traits<allocator_type> __alloc_traits;
  442. __base __tree_;
  443. public:
  444. typedef typename __base::pointer pointer;
  445. typedef typename __base::const_pointer const_pointer;
  446. typedef typename __base::size_type size_type;
  447. typedef typename __base::difference_type difference_type;
  448. typedef typename __base::const_iterator iterator;
  449. typedef typename __base::const_iterator const_iterator;
  450. typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
  451. typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
  452. #if _LIBCPP_STD_VER > 14
  453. typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
  454. typedef __insert_return_type<iterator, node_type> insert_return_type;
  455. #endif
  456. template <class _Key2, class _Compare2, class _Alloc2>
  457. friend class _LIBCPP_TEMPLATE_VIS set;
  458. template <class _Key2, class _Compare2, class _Alloc2>
  459. friend class _LIBCPP_TEMPLATE_VIS multiset;
  460. _LIBCPP_INLINE_VISIBILITY
  461. set()
  462. _NOEXCEPT_(
  463. is_nothrow_default_constructible<allocator_type>::value &&
  464. is_nothrow_default_constructible<key_compare>::value &&
  465. is_nothrow_copy_constructible<key_compare>::value)
  466. : __tree_(value_compare()) {}
  467. _LIBCPP_INLINE_VISIBILITY
  468. explicit set(const value_compare& __comp)
  469. _NOEXCEPT_(
  470. is_nothrow_default_constructible<allocator_type>::value &&
  471. is_nothrow_copy_constructible<key_compare>::value)
  472. : __tree_(__comp) {}
  473. _LIBCPP_INLINE_VISIBILITY
  474. explicit set(const value_compare& __comp, const allocator_type& __a)
  475. : __tree_(__comp, __a) {}
  476. template <class _InputIterator>
  477. _LIBCPP_INLINE_VISIBILITY
  478. set(_InputIterator __f, _InputIterator __l,
  479. const value_compare& __comp = value_compare())
  480. : __tree_(__comp)
  481. {
  482. insert(__f, __l);
  483. }
  484. template <class _InputIterator>
  485. _LIBCPP_INLINE_VISIBILITY
  486. set(_InputIterator __f, _InputIterator __l, const value_compare& __comp,
  487. const allocator_type& __a)
  488. : __tree_(__comp, __a)
  489. {
  490. insert(__f, __l);
  491. }
  492. #if _LIBCPP_STD_VER > 11
  493. template <class _InputIterator>
  494. _LIBCPP_INLINE_VISIBILITY
  495. set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
  496. : set(__f, __l, key_compare(), __a) {}
  497. #endif
  498. _LIBCPP_INLINE_VISIBILITY
  499. set(const set& __s)
  500. : __tree_(__s.__tree_)
  501. {
  502. insert(__s.begin(), __s.end());
  503. }
  504. _LIBCPP_INLINE_VISIBILITY
  505. set& operator=(const set& __s)
  506. {
  507. __tree_ = __s.__tree_;
  508. return *this;
  509. }
  510. #ifndef _LIBCPP_CXX03_LANG
  511. _LIBCPP_INLINE_VISIBILITY
  512. set(set&& __s)
  513. _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
  514. : __tree_(_VSTD::move(__s.__tree_)) {}
  515. #endif // _LIBCPP_CXX03_LANG
  516. _LIBCPP_INLINE_VISIBILITY
  517. explicit set(const allocator_type& __a)
  518. : __tree_(__a) {}
  519. _LIBCPP_INLINE_VISIBILITY
  520. set(const set& __s, const allocator_type& __a)
  521. : __tree_(__s.__tree_.value_comp(), __a)
  522. {
  523. insert(__s.begin(), __s.end());
  524. }
  525. #ifndef _LIBCPP_CXX03_LANG
  526. set(set&& __s, const allocator_type& __a);
  527. _LIBCPP_INLINE_VISIBILITY
  528. set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
  529. : __tree_(__comp)
  530. {
  531. insert(__il.begin(), __il.end());
  532. }
  533. _LIBCPP_INLINE_VISIBILITY
  534. set(initializer_list<value_type> __il, const value_compare& __comp,
  535. const allocator_type& __a)
  536. : __tree_(__comp, __a)
  537. {
  538. insert(__il.begin(), __il.end());
  539. }
  540. #if _LIBCPP_STD_VER > 11
  541. _LIBCPP_INLINE_VISIBILITY
  542. set(initializer_list<value_type> __il, const allocator_type& __a)
  543. : set(__il, key_compare(), __a) {}
  544. #endif
  545. _LIBCPP_INLINE_VISIBILITY
  546. set& operator=(initializer_list<value_type> __il)
  547. {
  548. __tree_.__assign_unique(__il.begin(), __il.end());
  549. return *this;
  550. }
  551. _LIBCPP_INLINE_VISIBILITY
  552. set& operator=(set&& __s)
  553. _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
  554. {
  555. __tree_ = _VSTD::move(__s.__tree_);
  556. return *this;
  557. }
  558. #endif // _LIBCPP_CXX03_LANG
  559. _LIBCPP_INLINE_VISIBILITY
  560. ~set() {
  561. static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
  562. }
  563. _LIBCPP_INLINE_VISIBILITY
  564. iterator begin() _NOEXCEPT {return __tree_.begin();}
  565. _LIBCPP_INLINE_VISIBILITY
  566. const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
  567. _LIBCPP_INLINE_VISIBILITY
  568. iterator end() _NOEXCEPT {return __tree_.end();}
  569. _LIBCPP_INLINE_VISIBILITY
  570. const_iterator end() const _NOEXCEPT {return __tree_.end();}
  571. _LIBCPP_INLINE_VISIBILITY
  572. reverse_iterator rbegin() _NOEXCEPT
  573. {return reverse_iterator(end());}
  574. _LIBCPP_INLINE_VISIBILITY
  575. const_reverse_iterator rbegin() const _NOEXCEPT
  576. {return const_reverse_iterator(end());}
  577. _LIBCPP_INLINE_VISIBILITY
  578. reverse_iterator rend() _NOEXCEPT
  579. {return reverse_iterator(begin());}
  580. _LIBCPP_INLINE_VISIBILITY
  581. const_reverse_iterator rend() const _NOEXCEPT
  582. {return const_reverse_iterator(begin());}
  583. _LIBCPP_INLINE_VISIBILITY
  584. const_iterator cbegin() const _NOEXCEPT {return begin();}
  585. _LIBCPP_INLINE_VISIBILITY
  586. const_iterator cend() const _NOEXCEPT {return end();}
  587. _LIBCPP_INLINE_VISIBILITY
  588. const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
  589. _LIBCPP_INLINE_VISIBILITY
  590. const_reverse_iterator crend() const _NOEXCEPT {return rend();}
  591. _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
  592. bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
  593. _LIBCPP_INLINE_VISIBILITY
  594. size_type size() const _NOEXCEPT {return __tree_.size();}
  595. _LIBCPP_INLINE_VISIBILITY
  596. size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
  597. // modifiers:
  598. #ifndef _LIBCPP_CXX03_LANG
  599. template <class... _Args>
  600. _LIBCPP_INLINE_VISIBILITY
  601. pair<iterator, bool> emplace(_Args&&... __args)
  602. {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
  603. template <class... _Args>
  604. _LIBCPP_INLINE_VISIBILITY
  605. iterator emplace_hint(const_iterator __p, _Args&&... __args)
  606. {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);}
  607. #endif // _LIBCPP_CXX03_LANG
  608. _LIBCPP_INLINE_VISIBILITY
  609. pair<iterator,bool> insert(const value_type& __v)
  610. {return __tree_.__insert_unique(__v);}
  611. _LIBCPP_INLINE_VISIBILITY
  612. iterator insert(const_iterator __p, const value_type& __v)
  613. {return __tree_.__insert_unique(__p, __v);}
  614. template <class _InputIterator>
  615. _LIBCPP_INLINE_VISIBILITY
  616. void insert(_InputIterator __f, _InputIterator __l)
  617. {
  618. for (const_iterator __e = cend(); __f != __l; ++__f)
  619. __tree_.__insert_unique(__e, *__f);
  620. }
  621. #ifndef _LIBCPP_CXX03_LANG
  622. _LIBCPP_INLINE_VISIBILITY
  623. pair<iterator,bool> insert(value_type&& __v)
  624. {return __tree_.__insert_unique(_VSTD::move(__v));}
  625. _LIBCPP_INLINE_VISIBILITY
  626. iterator insert(const_iterator __p, value_type&& __v)
  627. {return __tree_.__insert_unique(__p, _VSTD::move(__v));}
  628. _LIBCPP_INLINE_VISIBILITY
  629. void insert(initializer_list<value_type> __il)
  630. {insert(__il.begin(), __il.end());}
  631. #endif // _LIBCPP_CXX03_LANG
  632. _LIBCPP_INLINE_VISIBILITY
  633. iterator erase(const_iterator __p) {return __tree_.erase(__p);}
  634. _LIBCPP_INLINE_VISIBILITY
  635. size_type erase(const key_type& __k)
  636. {return __tree_.__erase_unique(__k);}
  637. _LIBCPP_INLINE_VISIBILITY
  638. iterator erase(const_iterator __f, const_iterator __l)
  639. {return __tree_.erase(__f, __l);}
  640. _LIBCPP_REINITIALIZES_OBJECT _LIBCPP_INLINE_VISIBILITY
  641. void clear() _NOEXCEPT {__tree_.clear();}
  642. #if _LIBCPP_STD_VER > 14
  643. _LIBCPP_INLINE_VISIBILITY
  644. insert_return_type insert(node_type&& __nh)
  645. {
  646. _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
  647. "node_type with incompatible allocator passed to set::insert()");
  648. return __tree_.template __node_handle_insert_unique<
  649. node_type, insert_return_type>(_VSTD::move(__nh));
  650. }
  651. _LIBCPP_INLINE_VISIBILITY
  652. iterator insert(const_iterator __hint, node_type&& __nh)
  653. {
  654. _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
  655. "node_type with incompatible allocator passed to set::insert()");
  656. return __tree_.template __node_handle_insert_unique<node_type>(
  657. __hint, _VSTD::move(__nh));
  658. }
  659. _LIBCPP_INLINE_VISIBILITY
  660. node_type extract(key_type const& __key)
  661. {
  662. return __tree_.template __node_handle_extract<node_type>(__key);
  663. }
  664. _LIBCPP_INLINE_VISIBILITY
  665. node_type extract(const_iterator __it)
  666. {
  667. return __tree_.template __node_handle_extract<node_type>(__it);
  668. }
  669. template <class _Compare2>
  670. _LIBCPP_INLINE_VISIBILITY
  671. void merge(set<key_type, _Compare2, allocator_type>& __source)
  672. {
  673. _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
  674. "merging container with incompatible allocator");
  675. __tree_.__node_handle_merge_unique(__source.__tree_);
  676. }
  677. template <class _Compare2>
  678. _LIBCPP_INLINE_VISIBILITY
  679. void merge(set<key_type, _Compare2, allocator_type>&& __source)
  680. {
  681. _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
  682. "merging container with incompatible allocator");
  683. __tree_.__node_handle_merge_unique(__source.__tree_);
  684. }
  685. template <class _Compare2>
  686. _LIBCPP_INLINE_VISIBILITY
  687. void merge(multiset<key_type, _Compare2, allocator_type>& __source)
  688. {
  689. _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
  690. "merging container with incompatible allocator");
  691. __tree_.__node_handle_merge_unique(__source.__tree_);
  692. }
  693. template <class _Compare2>
  694. _LIBCPP_INLINE_VISIBILITY
  695. void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
  696. {
  697. _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
  698. "merging container with incompatible allocator");
  699. __tree_.__node_handle_merge_unique(__source.__tree_);
  700. }
  701. #endif
  702. _LIBCPP_INLINE_VISIBILITY
  703. void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
  704. {__tree_.swap(__s.__tree_);}
  705. _LIBCPP_INLINE_VISIBILITY
  706. allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
  707. _LIBCPP_INLINE_VISIBILITY
  708. key_compare key_comp() const {return __tree_.value_comp();}
  709. _LIBCPP_INLINE_VISIBILITY
  710. value_compare value_comp() const {return __tree_.value_comp();}
  711. // set operations:
  712. _LIBCPP_INLINE_VISIBILITY
  713. iterator find(const key_type& __k) {return __tree_.find(__k);}
  714. _LIBCPP_INLINE_VISIBILITY
  715. const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
  716. #if _LIBCPP_STD_VER > 11
  717. template <typename _K2>
  718. _LIBCPP_INLINE_VISIBILITY
  719. typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
  720. find(const _K2& __k) {return __tree_.find(__k);}
  721. template <typename _K2>
  722. _LIBCPP_INLINE_VISIBILITY
  723. typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
  724. find(const _K2& __k) const {return __tree_.find(__k);}
  725. #endif
  726. _LIBCPP_INLINE_VISIBILITY
  727. size_type count(const key_type& __k) const
  728. {return __tree_.__count_unique(__k);}
  729. #if _LIBCPP_STD_VER > 11
  730. template <typename _K2>
  731. _LIBCPP_INLINE_VISIBILITY
  732. typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
  733. count(const _K2& __k) const {return __tree_.__count_multi(__k);}
  734. #endif
  735. #if _LIBCPP_STD_VER > 17
  736. _LIBCPP_INLINE_VISIBILITY
  737. bool contains(const key_type& __k) const {return find(__k) != end();}
  738. template <typename _K2>
  739. _LIBCPP_INLINE_VISIBILITY
  740. typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
  741. contains(const _K2& __k) const { return find(__k) != end(); }
  742. #endif // _LIBCPP_STD_VER > 17
  743. _LIBCPP_INLINE_VISIBILITY
  744. iterator lower_bound(const key_type& __k)
  745. {return __tree_.lower_bound(__k);}
  746. _LIBCPP_INLINE_VISIBILITY
  747. const_iterator lower_bound(const key_type& __k) const
  748. {return __tree_.lower_bound(__k);}
  749. #if _LIBCPP_STD_VER > 11
  750. template <typename _K2>
  751. _LIBCPP_INLINE_VISIBILITY
  752. typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
  753. lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
  754. template <typename _K2>
  755. _LIBCPP_INLINE_VISIBILITY
  756. typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
  757. lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
  758. #endif
  759. _LIBCPP_INLINE_VISIBILITY
  760. iterator upper_bound(const key_type& __k)
  761. {return __tree_.upper_bound(__k);}
  762. _LIBCPP_INLINE_VISIBILITY
  763. const_iterator upper_bound(const key_type& __k) const
  764. {return __tree_.upper_bound(__k);}
  765. #if _LIBCPP_STD_VER > 11
  766. template <typename _K2>
  767. _LIBCPP_INLINE_VISIBILITY
  768. typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
  769. upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
  770. template <typename _K2>
  771. _LIBCPP_INLINE_VISIBILITY
  772. typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
  773. upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
  774. #endif
  775. _LIBCPP_INLINE_VISIBILITY
  776. pair<iterator,iterator> equal_range(const key_type& __k)
  777. {return __tree_.__equal_range_unique(__k);}
  778. _LIBCPP_INLINE_VISIBILITY
  779. pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
  780. {return __tree_.__equal_range_unique(__k);}
  781. #if _LIBCPP_STD_VER > 11
  782. template <typename _K2>
  783. _LIBCPP_INLINE_VISIBILITY
  784. typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
  785. equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
  786. template <typename _K2>
  787. _LIBCPP_INLINE_VISIBILITY
  788. typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
  789. equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
  790. #endif
  791. };
  792. #if _LIBCPP_STD_VER >= 17
  793. template<class _InputIterator,
  794. class _Compare = less<__iter_value_type<_InputIterator>>,
  795. class _Allocator = allocator<__iter_value_type<_InputIterator>>,
  796. class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
  797. class = enable_if_t<__is_allocator<_Allocator>::value, void>,
  798. class = enable_if_t<!__is_allocator<_Compare>::value, void>>
  799. set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
  800. -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
  801. template<class _Key, class _Compare = less<_Key>,
  802. class _Allocator = allocator<_Key>,
  803. class = enable_if_t<!__is_allocator<_Compare>::value, void>,
  804. class = enable_if_t<__is_allocator<_Allocator>::value, void>>
  805. set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
  806. -> set<_Key, _Compare, _Allocator>;
  807. template<class _InputIterator, class _Allocator,
  808. class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
  809. class = enable_if_t<__is_allocator<_Allocator>::value, void>>
  810. set(_InputIterator, _InputIterator, _Allocator)
  811. -> set<__iter_value_type<_InputIterator>,
  812. less<__iter_value_type<_InputIterator>>, _Allocator>;
  813. template<class _Key, class _Allocator,
  814. class = enable_if_t<__is_allocator<_Allocator>::value, void>>
  815. set(initializer_list<_Key>, _Allocator)
  816. -> set<_Key, less<_Key>, _Allocator>;
  817. #endif
  818. #ifndef _LIBCPP_CXX03_LANG
  819. template <class _Key, class _Compare, class _Allocator>
  820. set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
  821. : __tree_(_VSTD::move(__s.__tree_), __a)
  822. {
  823. if (__a != __s.get_allocator())
  824. {
  825. const_iterator __e = cend();
  826. while (!__s.empty())
  827. insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
  828. }
  829. }
  830. #endif // _LIBCPP_CXX03_LANG
  831. template <class _Key, class _Compare, class _Allocator>
  832. inline _LIBCPP_INLINE_VISIBILITY
  833. bool
  834. operator==(const set<_Key, _Compare, _Allocator>& __x,
  835. const set<_Key, _Compare, _Allocator>& __y)
  836. {
  837. return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
  838. }
  839. template <class _Key, class _Compare, class _Allocator>
  840. inline _LIBCPP_INLINE_VISIBILITY
  841. bool
  842. operator< (const set<_Key, _Compare, _Allocator>& __x,
  843. const set<_Key, _Compare, _Allocator>& __y)
  844. {
  845. return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
  846. }
  847. template <class _Key, class _Compare, class _Allocator>
  848. inline _LIBCPP_INLINE_VISIBILITY
  849. bool
  850. operator!=(const set<_Key, _Compare, _Allocator>& __x,
  851. const set<_Key, _Compare, _Allocator>& __y)
  852. {
  853. return !(__x == __y);
  854. }
  855. template <class _Key, class _Compare, class _Allocator>
  856. inline _LIBCPP_INLINE_VISIBILITY
  857. bool
  858. operator> (const set<_Key, _Compare, _Allocator>& __x,
  859. const set<_Key, _Compare, _Allocator>& __y)
  860. {
  861. return __y < __x;
  862. }
  863. template <class _Key, class _Compare, class _Allocator>
  864. inline _LIBCPP_INLINE_VISIBILITY
  865. bool
  866. operator>=(const set<_Key, _Compare, _Allocator>& __x,
  867. const set<_Key, _Compare, _Allocator>& __y)
  868. {
  869. return !(__x < __y);
  870. }
  871. template <class _Key, class _Compare, class _Allocator>
  872. inline _LIBCPP_INLINE_VISIBILITY
  873. bool
  874. operator<=(const set<_Key, _Compare, _Allocator>& __x,
  875. const set<_Key, _Compare, _Allocator>& __y)
  876. {
  877. return !(__y < __x);
  878. }
  879. // specialized algorithms:
  880. template <class _Key, class _Compare, class _Allocator>
  881. inline _LIBCPP_INLINE_VISIBILITY
  882. void
  883. swap(set<_Key, _Compare, _Allocator>& __x,
  884. set<_Key, _Compare, _Allocator>& __y)
  885. _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
  886. {
  887. __x.swap(__y);
  888. }
  889. #if _LIBCPP_STD_VER > 17
  890. template <class _Key, class _Compare, class _Allocator, class _Predicate>
  891. inline _LIBCPP_INLINE_VISIBILITY
  892. typename set<_Key, _Compare, _Allocator>::size_type
  893. erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
  894. return _VSTD::__libcpp_erase_if_container(__c, __pred);
  895. }
  896. #endif
  897. template <class _Key, class _Compare = less<_Key>,
  898. class _Allocator = allocator<_Key> >
  899. class _LIBCPP_TEMPLATE_VIS multiset
  900. {
  901. public:
  902. // types:
  903. typedef _Key key_type;
  904. typedef key_type value_type;
  905. typedef __identity_t<_Compare> key_compare;
  906. typedef key_compare value_compare;
  907. typedef __identity_t<_Allocator> allocator_type;
  908. typedef value_type& reference;
  909. typedef const value_type& const_reference;
  910. static_assert((is_same<typename allocator_type::value_type, value_type>::value),
  911. "Allocator::value_type must be same type as value_type");
  912. private:
  913. typedef __tree<value_type, value_compare, allocator_type> __base;
  914. typedef allocator_traits<allocator_type> __alloc_traits;
  915. __base __tree_;
  916. public:
  917. typedef typename __base::pointer pointer;
  918. typedef typename __base::const_pointer const_pointer;
  919. typedef typename __base::size_type size_type;
  920. typedef typename __base::difference_type difference_type;
  921. typedef typename __base::const_iterator iterator;
  922. typedef typename __base::const_iterator const_iterator;
  923. typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
  924. typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
  925. #if _LIBCPP_STD_VER > 14
  926. typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
  927. #endif
  928. template <class _Key2, class _Compare2, class _Alloc2>
  929. friend class _LIBCPP_TEMPLATE_VIS set;
  930. template <class _Key2, class _Compare2, class _Alloc2>
  931. friend class _LIBCPP_TEMPLATE_VIS multiset;
  932. // construct/copy/destroy:
  933. _LIBCPP_INLINE_VISIBILITY
  934. multiset()
  935. _NOEXCEPT_(
  936. is_nothrow_default_constructible<allocator_type>::value &&
  937. is_nothrow_default_constructible<key_compare>::value &&
  938. is_nothrow_copy_constructible<key_compare>::value)
  939. : __tree_(value_compare()) {}
  940. _LIBCPP_INLINE_VISIBILITY
  941. explicit multiset(const value_compare& __comp)
  942. _NOEXCEPT_(
  943. is_nothrow_default_constructible<allocator_type>::value &&
  944. is_nothrow_copy_constructible<key_compare>::value)
  945. : __tree_(__comp) {}
  946. _LIBCPP_INLINE_VISIBILITY
  947. explicit multiset(const value_compare& __comp, const allocator_type& __a)
  948. : __tree_(__comp, __a) {}
  949. template <class _InputIterator>
  950. _LIBCPP_INLINE_VISIBILITY
  951. multiset(_InputIterator __f, _InputIterator __l,
  952. const value_compare& __comp = value_compare())
  953. : __tree_(__comp)
  954. {
  955. insert(__f, __l);
  956. }
  957. #if _LIBCPP_STD_VER > 11
  958. template <class _InputIterator>
  959. _LIBCPP_INLINE_VISIBILITY
  960. multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
  961. : multiset(__f, __l, key_compare(), __a) {}
  962. #endif
  963. template <class _InputIterator>
  964. _LIBCPP_INLINE_VISIBILITY
  965. multiset(_InputIterator __f, _InputIterator __l,
  966. const value_compare& __comp, const allocator_type& __a)
  967. : __tree_(__comp, __a)
  968. {
  969. insert(__f, __l);
  970. }
  971. _LIBCPP_INLINE_VISIBILITY
  972. multiset(const multiset& __s)
  973. : __tree_(__s.__tree_.value_comp(),
  974. __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc()))
  975. {
  976. insert(__s.begin(), __s.end());
  977. }
  978. _LIBCPP_INLINE_VISIBILITY
  979. multiset& operator=(const multiset& __s)
  980. {
  981. __tree_ = __s.__tree_;
  982. return *this;
  983. }
  984. #ifndef _LIBCPP_CXX03_LANG
  985. _LIBCPP_INLINE_VISIBILITY
  986. multiset(multiset&& __s)
  987. _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
  988. : __tree_(_VSTD::move(__s.__tree_)) {}
  989. multiset(multiset&& __s, const allocator_type& __a);
  990. #endif // _LIBCPP_CXX03_LANG
  991. _LIBCPP_INLINE_VISIBILITY
  992. explicit multiset(const allocator_type& __a)
  993. : __tree_(__a) {}
  994. _LIBCPP_INLINE_VISIBILITY
  995. multiset(const multiset& __s, const allocator_type& __a)
  996. : __tree_(__s.__tree_.value_comp(), __a)
  997. {
  998. insert(__s.begin(), __s.end());
  999. }
  1000. #ifndef _LIBCPP_CXX03_LANG
  1001. _LIBCPP_INLINE_VISIBILITY
  1002. multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
  1003. : __tree_(__comp)
  1004. {
  1005. insert(__il.begin(), __il.end());
  1006. }
  1007. _LIBCPP_INLINE_VISIBILITY
  1008. multiset(initializer_list<value_type> __il, const value_compare& __comp,
  1009. const allocator_type& __a)
  1010. : __tree_(__comp, __a)
  1011. {
  1012. insert(__il.begin(), __il.end());
  1013. }
  1014. #if _LIBCPP_STD_VER > 11
  1015. _LIBCPP_INLINE_VISIBILITY
  1016. multiset(initializer_list<value_type> __il, const allocator_type& __a)
  1017. : multiset(__il, key_compare(), __a) {}
  1018. #endif
  1019. _LIBCPP_INLINE_VISIBILITY
  1020. multiset& operator=(initializer_list<value_type> __il)
  1021. {
  1022. __tree_.__assign_multi(__il.begin(), __il.end());
  1023. return *this;
  1024. }
  1025. _LIBCPP_INLINE_VISIBILITY
  1026. multiset& operator=(multiset&& __s)
  1027. _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
  1028. {
  1029. __tree_ = _VSTD::move(__s.__tree_);
  1030. return *this;
  1031. }
  1032. #endif // _LIBCPP_CXX03_LANG
  1033. _LIBCPP_INLINE_VISIBILITY
  1034. ~multiset() {
  1035. static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
  1036. }
  1037. _LIBCPP_INLINE_VISIBILITY
  1038. iterator begin() _NOEXCEPT {return __tree_.begin();}
  1039. _LIBCPP_INLINE_VISIBILITY
  1040. const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
  1041. _LIBCPP_INLINE_VISIBILITY
  1042. iterator end() _NOEXCEPT {return __tree_.end();}
  1043. _LIBCPP_INLINE_VISIBILITY
  1044. const_iterator end() const _NOEXCEPT {return __tree_.end();}
  1045. _LIBCPP_INLINE_VISIBILITY
  1046. reverse_iterator rbegin() _NOEXCEPT
  1047. {return reverse_iterator(end());}
  1048. _LIBCPP_INLINE_VISIBILITY
  1049. const_reverse_iterator rbegin() const _NOEXCEPT
  1050. {return const_reverse_iterator(end());}
  1051. _LIBCPP_INLINE_VISIBILITY
  1052. reverse_iterator rend() _NOEXCEPT
  1053. {return reverse_iterator(begin());}
  1054. _LIBCPP_INLINE_VISIBILITY
  1055. const_reverse_iterator rend() const _NOEXCEPT
  1056. {return const_reverse_iterator(begin());}
  1057. _LIBCPP_INLINE_VISIBILITY
  1058. const_iterator cbegin() const _NOEXCEPT {return begin();}
  1059. _LIBCPP_INLINE_VISIBILITY
  1060. const_iterator cend() const _NOEXCEPT {return end();}
  1061. _LIBCPP_INLINE_VISIBILITY
  1062. const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
  1063. _LIBCPP_INLINE_VISIBILITY
  1064. const_reverse_iterator crend() const _NOEXCEPT {return rend();}
  1065. _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
  1066. bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
  1067. _LIBCPP_INLINE_VISIBILITY
  1068. size_type size() const _NOEXCEPT {return __tree_.size();}
  1069. _LIBCPP_INLINE_VISIBILITY
  1070. size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
  1071. // modifiers:
  1072. #ifndef _LIBCPP_CXX03_LANG
  1073. template <class... _Args>
  1074. _LIBCPP_INLINE_VISIBILITY
  1075. iterator emplace(_Args&&... __args)
  1076. {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
  1077. template <class... _Args>
  1078. _LIBCPP_INLINE_VISIBILITY
  1079. iterator emplace_hint(const_iterator __p, _Args&&... __args)
  1080. {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
  1081. #endif // _LIBCPP_CXX03_LANG
  1082. _LIBCPP_INLINE_VISIBILITY
  1083. iterator insert(const value_type& __v)
  1084. {return __tree_.__insert_multi(__v);}
  1085. _LIBCPP_INLINE_VISIBILITY
  1086. iterator insert(const_iterator __p, const value_type& __v)
  1087. {return __tree_.__insert_multi(__p, __v);}
  1088. template <class _InputIterator>
  1089. _LIBCPP_INLINE_VISIBILITY
  1090. void insert(_InputIterator __f, _InputIterator __l)
  1091. {
  1092. for (const_iterator __e = cend(); __f != __l; ++__f)
  1093. __tree_.__insert_multi(__e, *__f);
  1094. }
  1095. #ifndef _LIBCPP_CXX03_LANG
  1096. _LIBCPP_INLINE_VISIBILITY
  1097. iterator insert(value_type&& __v)
  1098. {return __tree_.__insert_multi(_VSTD::move(__v));}
  1099. _LIBCPP_INLINE_VISIBILITY
  1100. iterator insert(const_iterator __p, value_type&& __v)
  1101. {return __tree_.__insert_multi(__p, _VSTD::move(__v));}
  1102. _LIBCPP_INLINE_VISIBILITY
  1103. void insert(initializer_list<value_type> __il)
  1104. {insert(__il.begin(), __il.end());}
  1105. #endif // _LIBCPP_CXX03_LANG
  1106. _LIBCPP_INLINE_VISIBILITY
  1107. iterator erase(const_iterator __p) {return __tree_.erase(__p);}
  1108. _LIBCPP_INLINE_VISIBILITY
  1109. size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
  1110. _LIBCPP_INLINE_VISIBILITY
  1111. iterator erase(const_iterator __f, const_iterator __l)
  1112. {return __tree_.erase(__f, __l);}
  1113. _LIBCPP_REINITIALIZES_OBJECT _LIBCPP_INLINE_VISIBILITY
  1114. void clear() _NOEXCEPT {__tree_.clear();}
  1115. #if _LIBCPP_STD_VER > 14
  1116. _LIBCPP_INLINE_VISIBILITY
  1117. iterator insert(node_type&& __nh)
  1118. {
  1119. _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
  1120. "node_type with incompatible allocator passed to multiset::insert()");
  1121. return __tree_.template __node_handle_insert_multi<node_type>(
  1122. _VSTD::move(__nh));
  1123. }
  1124. _LIBCPP_INLINE_VISIBILITY
  1125. iterator insert(const_iterator __hint, node_type&& __nh)
  1126. {
  1127. _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
  1128. "node_type with incompatible allocator passed to multiset::insert()");
  1129. return __tree_.template __node_handle_insert_multi<node_type>(
  1130. __hint, _VSTD::move(__nh));
  1131. }
  1132. _LIBCPP_INLINE_VISIBILITY
  1133. node_type extract(key_type const& __key)
  1134. {
  1135. return __tree_.template __node_handle_extract<node_type>(__key);
  1136. }
  1137. _LIBCPP_INLINE_VISIBILITY
  1138. node_type extract(const_iterator __it)
  1139. {
  1140. return __tree_.template __node_handle_extract<node_type>(__it);
  1141. }
  1142. template <class _Compare2>
  1143. _LIBCPP_INLINE_VISIBILITY
  1144. void merge(multiset<key_type, _Compare2, allocator_type>& __source)
  1145. {
  1146. _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
  1147. "merging container with incompatible allocator");
  1148. __tree_.__node_handle_merge_multi(__source.__tree_);
  1149. }
  1150. template <class _Compare2>
  1151. _LIBCPP_INLINE_VISIBILITY
  1152. void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
  1153. {
  1154. _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
  1155. "merging container with incompatible allocator");
  1156. __tree_.__node_handle_merge_multi(__source.__tree_);
  1157. }
  1158. template <class _Compare2>
  1159. _LIBCPP_INLINE_VISIBILITY
  1160. void merge(set<key_type, _Compare2, allocator_type>& __source)
  1161. {
  1162. _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
  1163. "merging container with incompatible allocator");
  1164. __tree_.__node_handle_merge_multi(__source.__tree_);
  1165. }
  1166. template <class _Compare2>
  1167. _LIBCPP_INLINE_VISIBILITY
  1168. void merge(set<key_type, _Compare2, allocator_type>&& __source)
  1169. {
  1170. _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
  1171. "merging container with incompatible allocator");
  1172. __tree_.__node_handle_merge_multi(__source.__tree_);
  1173. }
  1174. #endif
  1175. _LIBCPP_INLINE_VISIBILITY
  1176. void swap(multiset& __s)
  1177. _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
  1178. {__tree_.swap(__s.__tree_);}
  1179. _LIBCPP_INLINE_VISIBILITY
  1180. allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
  1181. _LIBCPP_INLINE_VISIBILITY
  1182. key_compare key_comp() const {return __tree_.value_comp();}
  1183. _LIBCPP_INLINE_VISIBILITY
  1184. value_compare value_comp() const {return __tree_.value_comp();}
  1185. // set operations:
  1186. _LIBCPP_INLINE_VISIBILITY
  1187. iterator find(const key_type& __k) {return __tree_.find(__k);}
  1188. _LIBCPP_INLINE_VISIBILITY
  1189. const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
  1190. #if _LIBCPP_STD_VER > 11
  1191. template <typename _K2>
  1192. _LIBCPP_INLINE_VISIBILITY
  1193. typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
  1194. find(const _K2& __k) {return __tree_.find(__k);}
  1195. template <typename _K2>
  1196. _LIBCPP_INLINE_VISIBILITY
  1197. typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
  1198. find(const _K2& __k) const {return __tree_.find(__k);}
  1199. #endif
  1200. _LIBCPP_INLINE_VISIBILITY
  1201. size_type count(const key_type& __k) const
  1202. {return __tree_.__count_multi(__k);}
  1203. #if _LIBCPP_STD_VER > 11
  1204. template <typename _K2>
  1205. _LIBCPP_INLINE_VISIBILITY
  1206. typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
  1207. count(const _K2& __k) const {return __tree_.__count_multi(__k);}
  1208. #endif
  1209. #if _LIBCPP_STD_VER > 17
  1210. _LIBCPP_INLINE_VISIBILITY
  1211. bool contains(const key_type& __k) const {return find(__k) != end();}
  1212. template <typename _K2>
  1213. _LIBCPP_INLINE_VISIBILITY
  1214. typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
  1215. contains(const _K2& __k) const { return find(__k) != end(); }
  1216. #endif // _LIBCPP_STD_VER > 17
  1217. _LIBCPP_INLINE_VISIBILITY
  1218. iterator lower_bound(const key_type& __k)
  1219. {return __tree_.lower_bound(__k);}
  1220. _LIBCPP_INLINE_VISIBILITY
  1221. const_iterator lower_bound(const key_type& __k) const
  1222. {return __tree_.lower_bound(__k);}
  1223. #if _LIBCPP_STD_VER > 11
  1224. template <typename _K2>
  1225. _LIBCPP_INLINE_VISIBILITY
  1226. typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
  1227. lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
  1228. template <typename _K2>
  1229. _LIBCPP_INLINE_VISIBILITY
  1230. typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
  1231. lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
  1232. #endif
  1233. _LIBCPP_INLINE_VISIBILITY
  1234. iterator upper_bound(const key_type& __k)
  1235. {return __tree_.upper_bound(__k);}
  1236. _LIBCPP_INLINE_VISIBILITY
  1237. const_iterator upper_bound(const key_type& __k) const
  1238. {return __tree_.upper_bound(__k);}
  1239. #if _LIBCPP_STD_VER > 11
  1240. template <typename _K2>
  1241. _LIBCPP_INLINE_VISIBILITY
  1242. typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
  1243. upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
  1244. template <typename _K2>
  1245. _LIBCPP_INLINE_VISIBILITY
  1246. typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
  1247. upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
  1248. #endif
  1249. _LIBCPP_INLINE_VISIBILITY
  1250. pair<iterator,iterator> equal_range(const key_type& __k)
  1251. {return __tree_.__equal_range_multi(__k);}
  1252. _LIBCPP_INLINE_VISIBILITY
  1253. pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
  1254. {return __tree_.__equal_range_multi(__k);}
  1255. #if _LIBCPP_STD_VER > 11
  1256. template <typename _K2>
  1257. _LIBCPP_INLINE_VISIBILITY
  1258. typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
  1259. equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
  1260. template <typename _K2>
  1261. _LIBCPP_INLINE_VISIBILITY
  1262. typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
  1263. equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
  1264. #endif
  1265. };
  1266. #if _LIBCPP_STD_VER >= 17
  1267. template<class _InputIterator,
  1268. class _Compare = less<__iter_value_type<_InputIterator>>,
  1269. class _Allocator = allocator<__iter_value_type<_InputIterator>>,
  1270. class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
  1271. class = enable_if_t<__is_allocator<_Allocator>::value, void>,
  1272. class = enable_if_t<!__is_allocator<_Compare>::value, void>>
  1273. multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
  1274. -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
  1275. template<class _Key, class _Compare = less<_Key>,
  1276. class _Allocator = allocator<_Key>,
  1277. class = enable_if_t<__is_allocator<_Allocator>::value, void>,
  1278. class = enable_if_t<!__is_allocator<_Compare>::value, void>>
  1279. multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
  1280. -> multiset<_Key, _Compare, _Allocator>;
  1281. template<class _InputIterator, class _Allocator,
  1282. class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
  1283. class = enable_if_t<__is_allocator<_Allocator>::value, void>>
  1284. multiset(_InputIterator, _InputIterator, _Allocator)
  1285. -> multiset<__iter_value_type<_InputIterator>,
  1286. less<__iter_value_type<_InputIterator>>, _Allocator>;
  1287. template<class _Key, class _Allocator,
  1288. class = enable_if_t<__is_allocator<_Allocator>::value, void>>
  1289. multiset(initializer_list<_Key>, _Allocator)
  1290. -> multiset<_Key, less<_Key>, _Allocator>;
  1291. #endif
  1292. #ifndef _LIBCPP_CXX03_LANG
  1293. template <class _Key, class _Compare, class _Allocator>
  1294. multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
  1295. : __tree_(_VSTD::move(__s.__tree_), __a)
  1296. {
  1297. if (__a != __s.get_allocator())
  1298. {
  1299. const_iterator __e = cend();
  1300. while (!__s.empty())
  1301. insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
  1302. }
  1303. }
  1304. #endif // _LIBCPP_CXX03_LANG
  1305. template <class _Key, class _Compare, class _Allocator>
  1306. inline _LIBCPP_INLINE_VISIBILITY
  1307. bool
  1308. operator==(const multiset<_Key, _Compare, _Allocator>& __x,
  1309. const multiset<_Key, _Compare, _Allocator>& __y)
  1310. {
  1311. return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
  1312. }
  1313. template <class _Key, class _Compare, class _Allocator>
  1314. inline _LIBCPP_INLINE_VISIBILITY
  1315. bool
  1316. operator< (const multiset<_Key, _Compare, _Allocator>& __x,
  1317. const multiset<_Key, _Compare, _Allocator>& __y)
  1318. {
  1319. return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
  1320. }
  1321. template <class _Key, class _Compare, class _Allocator>
  1322. inline _LIBCPP_INLINE_VISIBILITY
  1323. bool
  1324. operator!=(const multiset<_Key, _Compare, _Allocator>& __x,
  1325. const multiset<_Key, _Compare, _Allocator>& __y)
  1326. {
  1327. return !(__x == __y);
  1328. }
  1329. template <class _Key, class _Compare, class _Allocator>
  1330. inline _LIBCPP_INLINE_VISIBILITY
  1331. bool
  1332. operator> (const multiset<_Key, _Compare, _Allocator>& __x,
  1333. const multiset<_Key, _Compare, _Allocator>& __y)
  1334. {
  1335. return __y < __x;
  1336. }
  1337. template <class _Key, class _Compare, class _Allocator>
  1338. inline _LIBCPP_INLINE_VISIBILITY
  1339. bool
  1340. operator>=(const multiset<_Key, _Compare, _Allocator>& __x,
  1341. const multiset<_Key, _Compare, _Allocator>& __y)
  1342. {
  1343. return !(__x < __y);
  1344. }
  1345. template <class _Key, class _Compare, class _Allocator>
  1346. inline _LIBCPP_INLINE_VISIBILITY
  1347. bool
  1348. operator<=(const multiset<_Key, _Compare, _Allocator>& __x,
  1349. const multiset<_Key, _Compare, _Allocator>& __y)
  1350. {
  1351. return !(__y < __x);
  1352. }
  1353. template <class _Key, class _Compare, class _Allocator>
  1354. inline _LIBCPP_INLINE_VISIBILITY
  1355. void
  1356. swap(multiset<_Key, _Compare, _Allocator>& __x,
  1357. multiset<_Key, _Compare, _Allocator>& __y)
  1358. _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
  1359. {
  1360. __x.swap(__y);
  1361. }
  1362. #if _LIBCPP_STD_VER > 17
  1363. template <class _Key, class _Compare, class _Allocator, class _Predicate>
  1364. inline _LIBCPP_INLINE_VISIBILITY
  1365. typename multiset<_Key, _Compare, _Allocator>::size_type
  1366. erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
  1367. return _VSTD::__libcpp_erase_if_container(__c, __pred);
  1368. }
  1369. #endif
  1370. _LIBCPP_END_NAMESPACE_STD
  1371. #endif // _LIBCPP_SET