10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_SET 110b57cec5SDimitry Andric#define _LIBCPP_SET 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric set synopsis 160b57cec5SDimitry Andric 170b57cec5SDimitry Andricnamespace std 180b57cec5SDimitry Andric{ 190b57cec5SDimitry Andric 200b57cec5SDimitry Andrictemplate <class Key, class Compare = less<Key>, 210b57cec5SDimitry Andric class Allocator = allocator<Key>> 220b57cec5SDimitry Andricclass set 230b57cec5SDimitry Andric{ 240b57cec5SDimitry Andricpublic: 250b57cec5SDimitry Andric // types: 260b57cec5SDimitry Andric typedef Key key_type; 270b57cec5SDimitry Andric typedef key_type value_type; 280b57cec5SDimitry Andric typedef Compare key_compare; 290b57cec5SDimitry Andric typedef key_compare value_compare; 300b57cec5SDimitry Andric typedef Allocator allocator_type; 310b57cec5SDimitry Andric typedef typename allocator_type::reference reference; 320b57cec5SDimitry Andric typedef typename allocator_type::const_reference const_reference; 330b57cec5SDimitry Andric typedef typename allocator_type::size_type size_type; 340b57cec5SDimitry Andric typedef typename allocator_type::difference_type difference_type; 350b57cec5SDimitry Andric typedef typename allocator_type::pointer pointer; 360b57cec5SDimitry Andric typedef typename allocator_type::const_pointer const_pointer; 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric typedef implementation-defined iterator; 390b57cec5SDimitry Andric typedef implementation-defined const_iterator; 400b57cec5SDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 410b57cec5SDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 420b57cec5SDimitry Andric typedef unspecified node_type; // C++17 430b57cec5SDimitry Andric typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric // construct/copy/destroy: 460b57cec5SDimitry Andric set() 470b57cec5SDimitry Andric noexcept( 480b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 490b57cec5SDimitry Andric is_nothrow_default_constructible<key_compare>::value && 500b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value); 510b57cec5SDimitry Andric explicit set(const value_compare& comp); 520b57cec5SDimitry Andric set(const value_compare& comp, const allocator_type& a); 530b57cec5SDimitry Andric template <class InputIterator> 540b57cec5SDimitry Andric set(InputIterator first, InputIterator last, 550b57cec5SDimitry Andric const value_compare& comp = value_compare()); 560b57cec5SDimitry Andric template <class InputIterator> 570b57cec5SDimitry Andric set(InputIterator first, InputIterator last, const value_compare& comp, 580b57cec5SDimitry Andric const allocator_type& a); 5906c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 6006c3fb27SDimitry Andric set(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23 610b57cec5SDimitry Andric set(const set& s); 620b57cec5SDimitry Andric set(set&& s) 630b57cec5SDimitry Andric noexcept( 640b57cec5SDimitry Andric is_nothrow_move_constructible<allocator_type>::value && 650b57cec5SDimitry Andric is_nothrow_move_constructible<key_compare>::value); 660b57cec5SDimitry Andric explicit set(const allocator_type& a); 670b57cec5SDimitry Andric set(const set& s, const allocator_type& a); 680b57cec5SDimitry Andric set(set&& s, const allocator_type& a); 690b57cec5SDimitry Andric set(initializer_list<value_type> il, const value_compare& comp = value_compare()); 700b57cec5SDimitry Andric set(initializer_list<value_type> il, const value_compare& comp, 710b57cec5SDimitry Andric const allocator_type& a); 720b57cec5SDimitry Andric template <class InputIterator> 730b57cec5SDimitry Andric set(InputIterator first, InputIterator last, const allocator_type& a) 740b57cec5SDimitry Andric : set(first, last, Compare(), a) {} // C++14 7506c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 7606c3fb27SDimitry Andric set(from_range_t, R&& rg, const Allocator& a)) 7706c3fb27SDimitry Andric : set(from_range, std::forward<R>(rg), Compare(), a) { } // C++23 780b57cec5SDimitry Andric set(initializer_list<value_type> il, const allocator_type& a) 790b57cec5SDimitry Andric : set(il, Compare(), a) {} // C++14 800b57cec5SDimitry Andric ~set(); 810b57cec5SDimitry Andric 820b57cec5SDimitry Andric set& operator=(const set& s); 830b57cec5SDimitry Andric set& operator=(set&& s) 840b57cec5SDimitry Andric noexcept( 850b57cec5SDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 860b57cec5SDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 870b57cec5SDimitry Andric is_nothrow_move_assignable<key_compare>::value); 880b57cec5SDimitry Andric set& operator=(initializer_list<value_type> il); 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric // iterators: 910b57cec5SDimitry Andric iterator begin() noexcept; 920b57cec5SDimitry Andric const_iterator begin() const noexcept; 930b57cec5SDimitry Andric iterator end() noexcept; 940b57cec5SDimitry Andric const_iterator end() const noexcept; 950b57cec5SDimitry Andric 960b57cec5SDimitry Andric reverse_iterator rbegin() noexcept; 970b57cec5SDimitry Andric const_reverse_iterator rbegin() const noexcept; 980b57cec5SDimitry Andric reverse_iterator rend() noexcept; 990b57cec5SDimitry Andric const_reverse_iterator rend() const noexcept; 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andric const_iterator cbegin() const noexcept; 1020b57cec5SDimitry Andric const_iterator cend() const noexcept; 1030b57cec5SDimitry Andric const_reverse_iterator crbegin() const noexcept; 1040b57cec5SDimitry Andric const_reverse_iterator crend() const noexcept; 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric // capacity: 1070b57cec5SDimitry Andric bool empty() const noexcept; 1080b57cec5SDimitry Andric size_type size() const noexcept; 1090b57cec5SDimitry Andric size_type max_size() const noexcept; 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric // modifiers: 1120b57cec5SDimitry Andric template <class... Args> 1130b57cec5SDimitry Andric pair<iterator, bool> emplace(Args&&... args); 1140b57cec5SDimitry Andric template <class... Args> 1150b57cec5SDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 1160b57cec5SDimitry Andric pair<iterator,bool> insert(const value_type& v); 1170b57cec5SDimitry Andric pair<iterator,bool> insert(value_type&& v); 1180b57cec5SDimitry Andric iterator insert(const_iterator position, const value_type& v); 1190b57cec5SDimitry Andric iterator insert(const_iterator position, value_type&& v); 1200b57cec5SDimitry Andric template <class InputIterator> 1210b57cec5SDimitry Andric void insert(InputIterator first, InputIterator last); 12206c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 12306c3fb27SDimitry Andric void insert_range(R&& rg); // C++23 1240b57cec5SDimitry Andric void insert(initializer_list<value_type> il); 1250b57cec5SDimitry Andric 1260b57cec5SDimitry Andric node_type extract(const_iterator position); // C++17 1270b57cec5SDimitry Andric node_type extract(const key_type& x); // C++17 1280b57cec5SDimitry Andric insert_return_type insert(node_type&& nh); // C++17 1290b57cec5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 1300b57cec5SDimitry Andric 1310b57cec5SDimitry Andric iterator erase(const_iterator position); 1320b57cec5SDimitry Andric iterator erase(iterator position); // C++14 1330b57cec5SDimitry Andric size_type erase(const key_type& k); 1340b57cec5SDimitry Andric iterator erase(const_iterator first, const_iterator last); 1350b57cec5SDimitry Andric void clear() noexcept; 1360b57cec5SDimitry Andric 1370b57cec5SDimitry Andric template<class C2> 1380b57cec5SDimitry Andric void merge(set<Key, C2, Allocator>& source); // C++17 1390b57cec5SDimitry Andric template<class C2> 1400b57cec5SDimitry Andric void merge(set<Key, C2, Allocator>&& source); // C++17 1410b57cec5SDimitry Andric template<class C2> 1420b57cec5SDimitry Andric void merge(multiset<Key, C2, Allocator>& source); // C++17 1430b57cec5SDimitry Andric template<class C2> 1440b57cec5SDimitry Andric void merge(multiset<Key, C2, Allocator>&& source); // C++17 1450b57cec5SDimitry Andric 1460b57cec5SDimitry Andric void swap(set& s) 1470b57cec5SDimitry Andric noexcept( 1480b57cec5SDimitry Andric __is_nothrow_swappable<key_compare>::value && 1490b57cec5SDimitry Andric (!allocator_type::propagate_on_container_swap::value || 1500b57cec5SDimitry Andric __is_nothrow_swappable<allocator_type>::value)); 1510b57cec5SDimitry Andric 1520b57cec5SDimitry Andric // observers: 1530b57cec5SDimitry Andric allocator_type get_allocator() const noexcept; 1540b57cec5SDimitry Andric key_compare key_comp() const; 1550b57cec5SDimitry Andric value_compare value_comp() const; 1560b57cec5SDimitry Andric 1570b57cec5SDimitry Andric // set operations: 1580b57cec5SDimitry Andric iterator find(const key_type& k); 1590b57cec5SDimitry Andric const_iterator find(const key_type& k) const; 1600b57cec5SDimitry Andric template<typename K> 1610b57cec5SDimitry Andric iterator find(const K& x); 1620b57cec5SDimitry Andric template<typename K> 1630b57cec5SDimitry Andric const_iterator find(const K& x) const; // C++14 164fe6060f1SDimitry Andric 1650b57cec5SDimitry Andric template<typename K> 1660b57cec5SDimitry Andric size_type count(const K& x) const; // C++14 1670b57cec5SDimitry Andric size_type count(const key_type& k) const; 168fe6060f1SDimitry Andric 1690b57cec5SDimitry Andric bool contains(const key_type& x) const; // C++20 170fe6060f1SDimitry Andric template<class K> bool contains(const K& x) const; // C++20 171fe6060f1SDimitry Andric 1720b57cec5SDimitry Andric iterator lower_bound(const key_type& k); 1730b57cec5SDimitry Andric const_iterator lower_bound(const key_type& k) const; 1740b57cec5SDimitry Andric template<typename K> 1750b57cec5SDimitry Andric iterator lower_bound(const K& x); // C++14 1760b57cec5SDimitry Andric template<typename K> 1770b57cec5SDimitry Andric const_iterator lower_bound(const K& x) const; // C++14 1780b57cec5SDimitry Andric 1790b57cec5SDimitry Andric iterator upper_bound(const key_type& k); 1800b57cec5SDimitry Andric const_iterator upper_bound(const key_type& k) const; 1810b57cec5SDimitry Andric template<typename K> 1820b57cec5SDimitry Andric iterator upper_bound(const K& x); // C++14 1830b57cec5SDimitry Andric template<typename K> 1840b57cec5SDimitry Andric const_iterator upper_bound(const K& x) const; // C++14 1850b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const key_type& k); 1860b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 1870b57cec5SDimitry Andric template<typename K> 1880b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const K& x); // C++14 1890b57cec5SDimitry Andric template<typename K> 1900b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 1910b57cec5SDimitry Andric}; 1920b57cec5SDimitry Andric 193349cc55cSDimitry Andrictemplate <class InputIterator, 194349cc55cSDimitry Andric class Compare = less<typename iterator_traits<InputIterator>::value_type>, 195349cc55cSDimitry Andric class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> 196349cc55cSDimitry Andricset(InputIterator, InputIterator, 197349cc55cSDimitry Andric Compare = Compare(), Allocator = Allocator()) 198349cc55cSDimitry Andric -> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17 199349cc55cSDimitry Andric 20006c3fb27SDimitry Andrictemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>, 20106c3fb27SDimitry Andric class Allocator = allocator<ranges::range_value_t<R>>> 20206c3fb27SDimitry Andric set(from_range_t, R&&, Compare = Compare(), Allocator = Allocator()) 20306c3fb27SDimitry Andric -> set<ranges::range_value_t<R>, Compare, Allocator>; // C++23 20406c3fb27SDimitry Andric 205349cc55cSDimitry Andrictemplate<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> 206349cc55cSDimitry Andricset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator()) 207349cc55cSDimitry Andric -> set<Key, Compare, Allocator>; // C++17 208349cc55cSDimitry Andric 209349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator> 210349cc55cSDimitry Andricset(InputIterator, InputIterator, Allocator) 211349cc55cSDimitry Andric -> set<typename iterator_traits<InputIterator>::value_type, 212349cc55cSDimitry Andric less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 213349cc55cSDimitry Andric 21406c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator> 21506c3fb27SDimitry Andric set(from_range_t, R&&, Allocator) 21606c3fb27SDimitry Andric -> set<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, Allocator>; // C++23 21706c3fb27SDimitry Andric 218349cc55cSDimitry Andrictemplate<class Key, class Allocator> 219349cc55cSDimitry Andricset(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>; // C++17 220349cc55cSDimitry Andric 2210b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2220b57cec5SDimitry Andricbool 2230b57cec5SDimitry Andricoperator==(const set<Key, Compare, Allocator>& x, 2240b57cec5SDimitry Andric const set<Key, Compare, Allocator>& y); 2250b57cec5SDimitry Andric 2260b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2270b57cec5SDimitry Andricbool 2280b57cec5SDimitry Andricoperator< (const set<Key, Compare, Allocator>& x, 22906c3fb27SDimitry Andric const set<Key, Compare, Allocator>& y); // removed in C++20 2300b57cec5SDimitry Andric 2310b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2320b57cec5SDimitry Andricbool 2330b57cec5SDimitry Andricoperator!=(const set<Key, Compare, Allocator>& x, 23406c3fb27SDimitry Andric const set<Key, Compare, Allocator>& y); // removed in C++20 2350b57cec5SDimitry Andric 2360b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2370b57cec5SDimitry Andricbool 2380b57cec5SDimitry Andricoperator> (const set<Key, Compare, Allocator>& x, 23906c3fb27SDimitry Andric const set<Key, Compare, Allocator>& y); // removed in C++20 2400b57cec5SDimitry Andric 2410b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2420b57cec5SDimitry Andricbool 2430b57cec5SDimitry Andricoperator>=(const set<Key, Compare, Allocator>& x, 24406c3fb27SDimitry Andric const set<Key, Compare, Allocator>& y); // removed in C++20 2450b57cec5SDimitry Andric 2460b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2470b57cec5SDimitry Andricbool 2480b57cec5SDimitry Andricoperator<=(const set<Key, Compare, Allocator>& x, 24906c3fb27SDimitry Andric const set<Key, Compare, Allocator>& y); // removed in C++20 25006c3fb27SDimitry Andric 25106c3fb27SDimitry Andrictemplate<class Key, class Compare, class Allocator> 25206c3fb27SDimitry Andric synth-three-way-result<Key> operator<=>(const set<Key, Compare, Allocator>& x, 25306c3fb27SDimitry Andric const set<Key, Compare, Allocator>& y); // since C++20 2540b57cec5SDimitry Andric 2550b57cec5SDimitry Andric// specialized algorithms: 2560b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2570b57cec5SDimitry Andricvoid 2580b57cec5SDimitry Andricswap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y) 2590b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator, class Predicate> 2625ffd83dbSDimitry Andrictypename set<Key, Compare, Allocator>::size_type 2635ffd83dbSDimitry Andricerase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20 2640b57cec5SDimitry Andric 2650b57cec5SDimitry Andrictemplate <class Key, class Compare = less<Key>, 2660b57cec5SDimitry Andric class Allocator = allocator<Key>> 2670b57cec5SDimitry Andricclass multiset 2680b57cec5SDimitry Andric{ 2690b57cec5SDimitry Andricpublic: 2700b57cec5SDimitry Andric // types: 2710b57cec5SDimitry Andric typedef Key key_type; 2720b57cec5SDimitry Andric typedef key_type value_type; 2730b57cec5SDimitry Andric typedef Compare key_compare; 2740b57cec5SDimitry Andric typedef key_compare value_compare; 2750b57cec5SDimitry Andric typedef Allocator allocator_type; 2760b57cec5SDimitry Andric typedef typename allocator_type::reference reference; 2770b57cec5SDimitry Andric typedef typename allocator_type::const_reference const_reference; 2780b57cec5SDimitry Andric typedef typename allocator_type::size_type size_type; 2790b57cec5SDimitry Andric typedef typename allocator_type::difference_type difference_type; 2800b57cec5SDimitry Andric typedef typename allocator_type::pointer pointer; 2810b57cec5SDimitry Andric typedef typename allocator_type::const_pointer const_pointer; 2820b57cec5SDimitry Andric 2830b57cec5SDimitry Andric typedef implementation-defined iterator; 2840b57cec5SDimitry Andric typedef implementation-defined const_iterator; 2850b57cec5SDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 2860b57cec5SDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 2870b57cec5SDimitry Andric typedef unspecified node_type; // C++17 2880b57cec5SDimitry Andric 2890b57cec5SDimitry Andric // construct/copy/destroy: 2900b57cec5SDimitry Andric multiset() 2910b57cec5SDimitry Andric noexcept( 2920b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 2930b57cec5SDimitry Andric is_nothrow_default_constructible<key_compare>::value && 2940b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value); 2950b57cec5SDimitry Andric explicit multiset(const value_compare& comp); 2960b57cec5SDimitry Andric multiset(const value_compare& comp, const allocator_type& a); 2970b57cec5SDimitry Andric template <class InputIterator> 2980b57cec5SDimitry Andric multiset(InputIterator first, InputIterator last, 2990b57cec5SDimitry Andric const value_compare& comp = value_compare()); 3000b57cec5SDimitry Andric template <class InputIterator> 3010b57cec5SDimitry Andric multiset(InputIterator first, InputIterator last, 3020b57cec5SDimitry Andric const value_compare& comp, const allocator_type& a); 30306c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 30406c3fb27SDimitry Andric multiset(from_range_t, R&& rg, 30506c3fb27SDimitry Andric const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23 3060b57cec5SDimitry Andric multiset(const multiset& s); 3070b57cec5SDimitry Andric multiset(multiset&& s) 3080b57cec5SDimitry Andric noexcept( 3090b57cec5SDimitry Andric is_nothrow_move_constructible<allocator_type>::value && 3100b57cec5SDimitry Andric is_nothrow_move_constructible<key_compare>::value); 3110b57cec5SDimitry Andric explicit multiset(const allocator_type& a); 3120b57cec5SDimitry Andric multiset(const multiset& s, const allocator_type& a); 3130b57cec5SDimitry Andric multiset(multiset&& s, const allocator_type& a); 3140b57cec5SDimitry Andric multiset(initializer_list<value_type> il, const value_compare& comp = value_compare()); 3150b57cec5SDimitry Andric multiset(initializer_list<value_type> il, const value_compare& comp, 3160b57cec5SDimitry Andric const allocator_type& a); 3170b57cec5SDimitry Andric template <class InputIterator> 3180b57cec5SDimitry Andric multiset(InputIterator first, InputIterator last, const allocator_type& a) 3190b57cec5SDimitry Andric : set(first, last, Compare(), a) {} // C++14 32006c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 32106c3fb27SDimitry Andric multiset(from_range_t, R&& rg, const Allocator& a)) 32206c3fb27SDimitry Andric : multiset(from_range, std::forward<R>(rg), Compare(), a) { } // C++23 3230b57cec5SDimitry Andric multiset(initializer_list<value_type> il, const allocator_type& a) 3240b57cec5SDimitry Andric : set(il, Compare(), a) {} // C++14 3250b57cec5SDimitry Andric ~multiset(); 3260b57cec5SDimitry Andric 3270b57cec5SDimitry Andric multiset& operator=(const multiset& s); 3280b57cec5SDimitry Andric multiset& operator=(multiset&& s) 3290b57cec5SDimitry Andric noexcept( 3300b57cec5SDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 3310b57cec5SDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 3320b57cec5SDimitry Andric is_nothrow_move_assignable<key_compare>::value); 3330b57cec5SDimitry Andric multiset& operator=(initializer_list<value_type> il); 3340b57cec5SDimitry Andric 3350b57cec5SDimitry Andric // iterators: 3360b57cec5SDimitry Andric iterator begin() noexcept; 3370b57cec5SDimitry Andric const_iterator begin() const noexcept; 3380b57cec5SDimitry Andric iterator end() noexcept; 3390b57cec5SDimitry Andric const_iterator end() const noexcept; 3400b57cec5SDimitry Andric 3410b57cec5SDimitry Andric reverse_iterator rbegin() noexcept; 3420b57cec5SDimitry Andric const_reverse_iterator rbegin() const noexcept; 3430b57cec5SDimitry Andric reverse_iterator rend() noexcept; 3440b57cec5SDimitry Andric const_reverse_iterator rend() const noexcept; 3450b57cec5SDimitry Andric 3460b57cec5SDimitry Andric const_iterator cbegin() const noexcept; 3470b57cec5SDimitry Andric const_iterator cend() const noexcept; 3480b57cec5SDimitry Andric const_reverse_iterator crbegin() const noexcept; 3490b57cec5SDimitry Andric const_reverse_iterator crend() const noexcept; 3500b57cec5SDimitry Andric 3510b57cec5SDimitry Andric // capacity: 3520b57cec5SDimitry Andric bool empty() const noexcept; 3530b57cec5SDimitry Andric size_type size() const noexcept; 3540b57cec5SDimitry Andric size_type max_size() const noexcept; 3550b57cec5SDimitry Andric 3560b57cec5SDimitry Andric // modifiers: 3570b57cec5SDimitry Andric template <class... Args> 3580b57cec5SDimitry Andric iterator emplace(Args&&... args); 3590b57cec5SDimitry Andric template <class... Args> 3600b57cec5SDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 3610b57cec5SDimitry Andric iterator insert(const value_type& v); 3620b57cec5SDimitry Andric iterator insert(value_type&& v); 3630b57cec5SDimitry Andric iterator insert(const_iterator position, const value_type& v); 3640b57cec5SDimitry Andric iterator insert(const_iterator position, value_type&& v); 3650b57cec5SDimitry Andric template <class InputIterator> 3660b57cec5SDimitry Andric void insert(InputIterator first, InputIterator last); 36706c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 36806c3fb27SDimitry Andric void insert_range(R&& rg); // C++23 3690b57cec5SDimitry Andric void insert(initializer_list<value_type> il); 3700b57cec5SDimitry Andric 3710b57cec5SDimitry Andric node_type extract(const_iterator position); // C++17 3720b57cec5SDimitry Andric node_type extract(const key_type& x); // C++17 3730b57cec5SDimitry Andric iterator insert(node_type&& nh); // C++17 3740b57cec5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 3750b57cec5SDimitry Andric 3760b57cec5SDimitry Andric iterator erase(const_iterator position); 3770b57cec5SDimitry Andric iterator erase(iterator position); // C++14 3780b57cec5SDimitry Andric size_type erase(const key_type& k); 3790b57cec5SDimitry Andric iterator erase(const_iterator first, const_iterator last); 3800b57cec5SDimitry Andric void clear() noexcept; 3810b57cec5SDimitry Andric 3820b57cec5SDimitry Andric template<class C2> 3830b57cec5SDimitry Andric void merge(multiset<Key, C2, Allocator>& source); // C++17 3840b57cec5SDimitry Andric template<class C2> 3850b57cec5SDimitry Andric void merge(multiset<Key, C2, Allocator>&& source); // C++17 3860b57cec5SDimitry Andric template<class C2> 3870b57cec5SDimitry Andric void merge(set<Key, C2, Allocator>& source); // C++17 3880b57cec5SDimitry Andric template<class C2> 3890b57cec5SDimitry Andric void merge(set<Key, C2, Allocator>&& source); // C++17 3900b57cec5SDimitry Andric 3910b57cec5SDimitry Andric void swap(multiset& s) 3920b57cec5SDimitry Andric noexcept( 3930b57cec5SDimitry Andric __is_nothrow_swappable<key_compare>::value && 3940b57cec5SDimitry Andric (!allocator_type::propagate_on_container_swap::value || 3950b57cec5SDimitry Andric __is_nothrow_swappable<allocator_type>::value)); 3960b57cec5SDimitry Andric 3970b57cec5SDimitry Andric // observers: 3980b57cec5SDimitry Andric allocator_type get_allocator() const noexcept; 3990b57cec5SDimitry Andric key_compare key_comp() const; 4000b57cec5SDimitry Andric value_compare value_comp() const; 4010b57cec5SDimitry Andric 4020b57cec5SDimitry Andric // set operations: 4030b57cec5SDimitry Andric iterator find(const key_type& k); 4040b57cec5SDimitry Andric const_iterator find(const key_type& k) const; 4050b57cec5SDimitry Andric template<typename K> 4060b57cec5SDimitry Andric iterator find(const K& x); 4070b57cec5SDimitry Andric template<typename K> 4080b57cec5SDimitry Andric const_iterator find(const K& x) const; // C++14 409fe6060f1SDimitry Andric 4100b57cec5SDimitry Andric template<typename K> 4110b57cec5SDimitry Andric size_type count(const K& x) const; // C++14 4120b57cec5SDimitry Andric size_type count(const key_type& k) const; 413fe6060f1SDimitry Andric 4140b57cec5SDimitry Andric bool contains(const key_type& x) const; // C++20 415fe6060f1SDimitry Andric template<class K> bool contains(const K& x) const; // C++20 416fe6060f1SDimitry Andric 4170b57cec5SDimitry Andric iterator lower_bound(const key_type& k); 4180b57cec5SDimitry Andric const_iterator lower_bound(const key_type& k) const; 4190b57cec5SDimitry Andric template<typename K> 4200b57cec5SDimitry Andric iterator lower_bound(const K& x); // C++14 4210b57cec5SDimitry Andric template<typename K> 4220b57cec5SDimitry Andric const_iterator lower_bound(const K& x) const; // C++14 4230b57cec5SDimitry Andric 4240b57cec5SDimitry Andric iterator upper_bound(const key_type& k); 4250b57cec5SDimitry Andric const_iterator upper_bound(const key_type& k) const; 4260b57cec5SDimitry Andric template<typename K> 4270b57cec5SDimitry Andric iterator upper_bound(const K& x); // C++14 4280b57cec5SDimitry Andric template<typename K> 4290b57cec5SDimitry Andric const_iterator upper_bound(const K& x) const; // C++14 4300b57cec5SDimitry Andric 4310b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const key_type& k); 4320b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 4330b57cec5SDimitry Andric template<typename K> 4340b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const K& x); // C++14 4350b57cec5SDimitry Andric template<typename K> 4360b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 4370b57cec5SDimitry Andric}; 4380b57cec5SDimitry Andric 439349cc55cSDimitry Andrictemplate <class InputIterator, 440349cc55cSDimitry Andric class Compare = less<typename iterator_traits<InputIterator>::value_type>, 441349cc55cSDimitry Andric class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> 442349cc55cSDimitry Andricmultiset(InputIterator, InputIterator, 443349cc55cSDimitry Andric Compare = Compare(), Allocator = Allocator()) 444349cc55cSDimitry Andric -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17 445349cc55cSDimitry Andric 44606c3fb27SDimitry Andrictemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>, 44706c3fb27SDimitry Andric class Allocator = allocator<ranges::range_value_t<R>>> 44806c3fb27SDimitry Andric multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator()) 44906c3fb27SDimitry Andric -> multiset<ranges::range_value_t<R>, Compare, Allocator>; 45006c3fb27SDimitry Andric 451349cc55cSDimitry Andrictemplate<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> 452349cc55cSDimitry Andricmultiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator()) 453349cc55cSDimitry Andric -> multiset<Key, Compare, Allocator>; // C++17 454349cc55cSDimitry Andric 455349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator> 456349cc55cSDimitry Andricmultiset(InputIterator, InputIterator, Allocator) 457349cc55cSDimitry Andric -> multiset<typename iterator_traits<InputIterator>::value_type, 458349cc55cSDimitry Andric less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 459349cc55cSDimitry Andric 46006c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator> 46106c3fb27SDimitry Andric multiset(from_range_t, R&&, Allocator) 46206c3fb27SDimitry Andric -> multiset<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, Allocator>; 46306c3fb27SDimitry Andric 464349cc55cSDimitry Andrictemplate<class Key, class Allocator> 465349cc55cSDimitry Andricmultiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>; // C++17 466349cc55cSDimitry Andric 4670b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4680b57cec5SDimitry Andricbool 4690b57cec5SDimitry Andricoperator==(const multiset<Key, Compare, Allocator>& x, 4700b57cec5SDimitry Andric const multiset<Key, Compare, Allocator>& y); 4710b57cec5SDimitry Andric 4720b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4730b57cec5SDimitry Andricbool 4740b57cec5SDimitry Andricoperator< (const multiset<Key, Compare, Allocator>& x, 47506c3fb27SDimitry Andric const multiset<Key, Compare, Allocator>& y); // removed in C++20 4760b57cec5SDimitry Andric 4770b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4780b57cec5SDimitry Andricbool 4790b57cec5SDimitry Andricoperator!=(const multiset<Key, Compare, Allocator>& x, 48006c3fb27SDimitry Andric const multiset<Key, Compare, Allocator>& y); // removed in C++20 4810b57cec5SDimitry Andric 4820b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4830b57cec5SDimitry Andricbool 4840b57cec5SDimitry Andricoperator> (const multiset<Key, Compare, Allocator>& x, 48506c3fb27SDimitry Andric const multiset<Key, Compare, Allocator>& y); // removed in C++20 4860b57cec5SDimitry Andric 4870b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4880b57cec5SDimitry Andricbool 4890b57cec5SDimitry Andricoperator>=(const multiset<Key, Compare, Allocator>& x, 49006c3fb27SDimitry Andric const multiset<Key, Compare, Allocator>& y); // removed in C++20 4910b57cec5SDimitry Andric 4920b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4930b57cec5SDimitry Andricbool 4940b57cec5SDimitry Andricoperator<=(const multiset<Key, Compare, Allocator>& x, 49506c3fb27SDimitry Andric const multiset<Key, Compare, Allocator>& y); // removed in C++20 49606c3fb27SDimitry Andric 49706c3fb27SDimitry Andrictemplate<class Key, class Compare, class Allocator> 49806c3fb27SDimitry Andric synth-three-way-result<Key> operator<=>(const multiset<Key, Compare, Allocator>& x, 49906c3fb27SDimitry Andric const multiset<Key, Compare, Allocator>& y); // since C++20 5000b57cec5SDimitry Andric 5010b57cec5SDimitry Andric// specialized algorithms: 5020b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 5030b57cec5SDimitry Andricvoid 5040b57cec5SDimitry Andricswap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y) 5050b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 5060b57cec5SDimitry Andric 5070b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator, class Predicate> 5085ffd83dbSDimitry Andrictypename multiset<Key, Compare, Allocator>::size_type 5095ffd83dbSDimitry Andricerase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 5100b57cec5SDimitry Andric 5110b57cec5SDimitry Andric} // std 5120b57cec5SDimitry Andric 5130b57cec5SDimitry Andric*/ 5140b57cec5SDimitry Andric 51581ad6265SDimitry Andric#include <__algorithm/equal.h> 51681ad6265SDimitry Andric#include <__algorithm/lexicographical_compare.h> 51706c3fb27SDimitry Andric#include <__algorithm/lexicographical_compare_three_way.h> 51881ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 51906c3fb27SDimitry Andric#include <__availability> 5200b57cec5SDimitry Andric#include <__config> 521fe6060f1SDimitry Andric#include <__functional/is_transparent.h> 52281ad6265SDimitry Andric#include <__functional/operations.h> 52381ad6265SDimitry Andric#include <__iterator/erase_if_container.h> 524349cc55cSDimitry Andric#include <__iterator/iterator_traits.h> 52506c3fb27SDimitry Andric#include <__iterator/ranges_iterator_traits.h> 52681ad6265SDimitry Andric#include <__iterator/reverse_iterator.h> 527bdd1243dSDimitry Andric#include <__memory/allocator.h> 528bdd1243dSDimitry Andric#include <__memory_resource/polymorphic_allocator.h> 5290b57cec5SDimitry Andric#include <__node_handle> 53006c3fb27SDimitry Andric#include <__ranges/concepts.h> 53106c3fb27SDimitry Andric#include <__ranges/container_compatible_range.h> 53206c3fb27SDimitry Andric#include <__ranges/from_range.h> 533fe6060f1SDimitry Andric#include <__tree> 534bdd1243dSDimitry Andric#include <__type_traits/is_allocator.h> 535fe6060f1SDimitry Andric#include <__utility/forward.h> 5360b57cec5SDimitry Andric#include <version> 5370b57cec5SDimitry Andric 53881ad6265SDimitry Andric// standard-mandated includes 53981ad6265SDimitry Andric 54081ad6265SDimitry Andric// [iterator.range] 54181ad6265SDimitry Andric#include <__iterator/access.h> 54281ad6265SDimitry Andric#include <__iterator/data.h> 54381ad6265SDimitry Andric#include <__iterator/empty.h> 54481ad6265SDimitry Andric#include <__iterator/reverse_access.h> 54581ad6265SDimitry Andric#include <__iterator/size.h> 54681ad6265SDimitry Andric 54781ad6265SDimitry Andric// [associative.set.syn] 54881ad6265SDimitry Andric#include <compare> 54981ad6265SDimitry Andric#include <initializer_list> 55081ad6265SDimitry Andric 5510b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 5520b57cec5SDimitry Andric# pragma GCC system_header 5530b57cec5SDimitry Andric#endif 5540b57cec5SDimitry Andric 5550b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 5560b57cec5SDimitry Andric 5570b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 5580b57cec5SDimitry Andricclass multiset; 5590b57cec5SDimitry Andric 5600b57cec5SDimitry Andrictemplate <class _Key, class _Compare = less<_Key>, 5610b57cec5SDimitry Andric class _Allocator = allocator<_Key> > 5620b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS set 5630b57cec5SDimitry Andric{ 5640b57cec5SDimitry Andricpublic: 5650b57cec5SDimitry Andric // types: 5660b57cec5SDimitry Andric typedef _Key key_type; 5670b57cec5SDimitry Andric typedef key_type value_type; 56881ad6265SDimitry Andric typedef __type_identity_t<_Compare> key_compare; 5690b57cec5SDimitry Andric typedef key_compare value_compare; 57081ad6265SDimitry Andric typedef __type_identity_t<_Allocator> allocator_type; 5710b57cec5SDimitry Andric typedef value_type& reference; 5720b57cec5SDimitry Andric typedef const value_type& const_reference; 5730b57cec5SDimitry Andric 5740b57cec5SDimitry Andric static_assert((is_same<typename allocator_type::value_type, value_type>::value), 5750b57cec5SDimitry Andric "Allocator::value_type must be same type as value_type"); 5760b57cec5SDimitry Andric 5770b57cec5SDimitry Andricprivate: 5780b57cec5SDimitry Andric typedef __tree<value_type, value_compare, allocator_type> __base; 5790b57cec5SDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 5800b57cec5SDimitry Andric 581bdd1243dSDimitry Andric static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, 582bdd1243dSDimitry Andric "[allocator.requirements] states that rebinding an allocator to the same type should result in the " 583bdd1243dSDimitry Andric "original allocator"); 584bdd1243dSDimitry Andric 5850b57cec5SDimitry Andric __base __tree_; 5860b57cec5SDimitry Andric 5870b57cec5SDimitry Andricpublic: 5880b57cec5SDimitry Andric typedef typename __base::pointer pointer; 5890b57cec5SDimitry Andric typedef typename __base::const_pointer const_pointer; 5900b57cec5SDimitry Andric typedef typename __base::size_type size_type; 5910b57cec5SDimitry Andric typedef typename __base::difference_type difference_type; 5920b57cec5SDimitry Andric typedef typename __base::const_iterator iterator; 5930b57cec5SDimitry Andric typedef typename __base::const_iterator const_iterator; 594*5f757f3fSDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 595*5f757f3fSDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 5960b57cec5SDimitry Andric 59706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 5980b57cec5SDimitry Andric typedef __set_node_handle<typename __base::__node, allocator_type> node_type; 5990b57cec5SDimitry Andric typedef __insert_return_type<iterator, node_type> insert_return_type; 6000b57cec5SDimitry Andric#endif 6010b57cec5SDimitry Andric 6020b57cec5SDimitry Andric template <class _Key2, class _Compare2, class _Alloc2> 6030b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS set; 6040b57cec5SDimitry Andric template <class _Key2, class _Compare2, class _Alloc2> 6050b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multiset; 6060b57cec5SDimitry Andric 607*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6080b57cec5SDimitry Andric set() 6090b57cec5SDimitry Andric _NOEXCEPT_( 6100b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 6110b57cec5SDimitry Andric is_nothrow_default_constructible<key_compare>::value && 6120b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 6130b57cec5SDimitry Andric : __tree_(value_compare()) {} 6140b57cec5SDimitry Andric 615*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6160b57cec5SDimitry Andric explicit set(const value_compare& __comp) 6170b57cec5SDimitry Andric _NOEXCEPT_( 6180b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 6190b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 6200b57cec5SDimitry Andric : __tree_(__comp) {} 6210b57cec5SDimitry Andric 622*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6230b57cec5SDimitry Andric explicit set(const value_compare& __comp, const allocator_type& __a) 6240b57cec5SDimitry Andric : __tree_(__comp, __a) {} 6250b57cec5SDimitry Andric template <class _InputIterator> 626*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6270b57cec5SDimitry Andric set(_InputIterator __f, _InputIterator __l, 6280b57cec5SDimitry Andric const value_compare& __comp = value_compare()) 6290b57cec5SDimitry Andric : __tree_(__comp) 6300b57cec5SDimitry Andric { 6310b57cec5SDimitry Andric insert(__f, __l); 6320b57cec5SDimitry Andric } 6330b57cec5SDimitry Andric 6340b57cec5SDimitry Andric template <class _InputIterator> 635*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6360b57cec5SDimitry Andric set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, 6370b57cec5SDimitry Andric const allocator_type& __a) 6380b57cec5SDimitry Andric : __tree_(__comp, __a) 6390b57cec5SDimitry Andric { 6400b57cec5SDimitry Andric insert(__f, __l); 6410b57cec5SDimitry Andric } 6420b57cec5SDimitry Andric 64306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 64406c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 64506c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 64606c3fb27SDimitry Andric set(from_range_t, _Range&& __range, const key_compare& __comp = key_compare(), 64706c3fb27SDimitry Andric const allocator_type& __a = allocator_type()) 64806c3fb27SDimitry Andric : __tree_(__comp, __a) { 64906c3fb27SDimitry Andric insert_range(std::forward<_Range>(__range)); 65006c3fb27SDimitry Andric } 65106c3fb27SDimitry Andric#endif 65206c3fb27SDimitry Andric 65306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 6540b57cec5SDimitry Andric template <class _InputIterator> 655*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6560b57cec5SDimitry Andric set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) 6570b57cec5SDimitry Andric : set(__f, __l, key_compare(), __a) {} 6580b57cec5SDimitry Andric#endif 6590b57cec5SDimitry Andric 66006c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 66106c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 66206c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 66306c3fb27SDimitry Andric set(from_range_t, _Range&& __range, const allocator_type& __a) 66406c3fb27SDimitry Andric : set(from_range, std::forward<_Range>(__range), key_compare(), __a) {} 66506c3fb27SDimitry Andric#endif 66606c3fb27SDimitry Andric 667*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6680b57cec5SDimitry Andric set(const set& __s) 6690b57cec5SDimitry Andric : __tree_(__s.__tree_) 6700b57cec5SDimitry Andric { 6710b57cec5SDimitry Andric insert(__s.begin(), __s.end()); 6720b57cec5SDimitry Andric } 6730b57cec5SDimitry Andric 674*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6750b57cec5SDimitry Andric set& operator=(const set& __s) 6760b57cec5SDimitry Andric { 6770b57cec5SDimitry Andric __tree_ = __s.__tree_; 6780b57cec5SDimitry Andric return *this; 6790b57cec5SDimitry Andric } 6800b57cec5SDimitry Andric 6810b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 682*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6830b57cec5SDimitry Andric set(set&& __s) 6840b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) 685*5f757f3fSDimitry Andric : __tree_(std::move(__s.__tree_)) {} 6860b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6870b57cec5SDimitry Andric 688*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6890b57cec5SDimitry Andric explicit set(const allocator_type& __a) 6900b57cec5SDimitry Andric : __tree_(__a) {} 6910b57cec5SDimitry Andric 692*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6930b57cec5SDimitry Andric set(const set& __s, const allocator_type& __a) 6940b57cec5SDimitry Andric : __tree_(__s.__tree_.value_comp(), __a) 6950b57cec5SDimitry Andric { 6960b57cec5SDimitry Andric insert(__s.begin(), __s.end()); 6970b57cec5SDimitry Andric } 6980b57cec5SDimitry Andric 6990b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 70006c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __a); 7010b57cec5SDimitry Andric 702*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7030b57cec5SDimitry Andric set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) 7040b57cec5SDimitry Andric : __tree_(__comp) 7050b57cec5SDimitry Andric { 7060b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 7070b57cec5SDimitry Andric } 7080b57cec5SDimitry Andric 709*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7100b57cec5SDimitry Andric set(initializer_list<value_type> __il, const value_compare& __comp, 7110b57cec5SDimitry Andric const allocator_type& __a) 7120b57cec5SDimitry Andric : __tree_(__comp, __a) 7130b57cec5SDimitry Andric { 7140b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 7150b57cec5SDimitry Andric } 7160b57cec5SDimitry Andric 71706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 718*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7190b57cec5SDimitry Andric set(initializer_list<value_type> __il, const allocator_type& __a) 7200b57cec5SDimitry Andric : set(__il, key_compare(), __a) {} 7210b57cec5SDimitry Andric#endif 7220b57cec5SDimitry Andric 723*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7240b57cec5SDimitry Andric set& operator=(initializer_list<value_type> __il) 7250b57cec5SDimitry Andric { 7260b57cec5SDimitry Andric __tree_.__assign_unique(__il.begin(), __il.end()); 7270b57cec5SDimitry Andric return *this; 7280b57cec5SDimitry Andric } 7290b57cec5SDimitry Andric 730*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7310b57cec5SDimitry Andric set& operator=(set&& __s) 7320b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) 7330b57cec5SDimitry Andric { 734*5f757f3fSDimitry Andric __tree_ = std::move(__s.__tree_); 7350b57cec5SDimitry Andric return *this; 7360b57cec5SDimitry Andric } 7370b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7380b57cec5SDimitry Andric 739*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7400b57cec5SDimitry Andric ~set() { 7410b57cec5SDimitry Andric static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); 7420b57cec5SDimitry Andric } 7430b57cec5SDimitry Andric 744*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7450b57cec5SDimitry Andric iterator begin() _NOEXCEPT {return __tree_.begin();} 746*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7470b57cec5SDimitry Andric const_iterator begin() const _NOEXCEPT {return __tree_.begin();} 748*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7490b57cec5SDimitry Andric iterator end() _NOEXCEPT {return __tree_.end();} 750*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7510b57cec5SDimitry Andric const_iterator end() const _NOEXCEPT {return __tree_.end();} 7520b57cec5SDimitry Andric 753*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7540b57cec5SDimitry Andric reverse_iterator rbegin() _NOEXCEPT 7550b57cec5SDimitry Andric {return reverse_iterator(end());} 756*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7570b57cec5SDimitry Andric const_reverse_iterator rbegin() const _NOEXCEPT 7580b57cec5SDimitry Andric {return const_reverse_iterator(end());} 759*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7600b57cec5SDimitry Andric reverse_iterator rend() _NOEXCEPT 7610b57cec5SDimitry Andric {return reverse_iterator(begin());} 762*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7630b57cec5SDimitry Andric const_reverse_iterator rend() const _NOEXCEPT 7640b57cec5SDimitry Andric {return const_reverse_iterator(begin());} 7650b57cec5SDimitry Andric 766*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7670b57cec5SDimitry Andric const_iterator cbegin() const _NOEXCEPT {return begin();} 768*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7690b57cec5SDimitry Andric const_iterator cend() const _NOEXCEPT {return end();} 770*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7710b57cec5SDimitry Andric const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 772*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7730b57cec5SDimitry Andric const_reverse_iterator crend() const _NOEXCEPT {return rend();} 7740b57cec5SDimitry Andric 775*5f757f3fSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI 7760b57cec5SDimitry Andric bool empty() const _NOEXCEPT {return __tree_.size() == 0;} 777*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7780b57cec5SDimitry Andric size_type size() const _NOEXCEPT {return __tree_.size();} 779*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7800b57cec5SDimitry Andric size_type max_size() const _NOEXCEPT {return __tree_.max_size();} 7810b57cec5SDimitry Andric 7820b57cec5SDimitry Andric // modifiers: 7830b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 7840b57cec5SDimitry Andric template <class... _Args> 785*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7860b57cec5SDimitry Andric pair<iterator, bool> emplace(_Args&&... __args) 787*5f757f3fSDimitry Andric {return __tree_.__emplace_unique(std::forward<_Args>(__args)...);} 7880b57cec5SDimitry Andric template <class... _Args> 789*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7900b57cec5SDimitry Andric iterator emplace_hint(const_iterator __p, _Args&&... __args) 791*5f757f3fSDimitry Andric {return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...);} 7920b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7930b57cec5SDimitry Andric 794*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7950b57cec5SDimitry Andric pair<iterator,bool> insert(const value_type& __v) 7960b57cec5SDimitry Andric {return __tree_.__insert_unique(__v);} 797*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7980b57cec5SDimitry Andric iterator insert(const_iterator __p, const value_type& __v) 7990b57cec5SDimitry Andric {return __tree_.__insert_unique(__p, __v);} 8000b57cec5SDimitry Andric 8010b57cec5SDimitry Andric template <class _InputIterator> 802*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8030b57cec5SDimitry Andric void insert(_InputIterator __f, _InputIterator __l) 8040b57cec5SDimitry Andric { 8050b57cec5SDimitry Andric for (const_iterator __e = cend(); __f != __l; ++__f) 8060b57cec5SDimitry Andric __tree_.__insert_unique(__e, *__f); 8070b57cec5SDimitry Andric } 8080b57cec5SDimitry Andric 80906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 81006c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 81106c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 81206c3fb27SDimitry Andric void insert_range(_Range&& __range) { 81306c3fb27SDimitry Andric const_iterator __end = cend(); 81406c3fb27SDimitry Andric for (auto&& __element : __range) { 81506c3fb27SDimitry Andric __tree_.__insert_unique(__end, std::forward<decltype(__element)>(__element)); 81606c3fb27SDimitry Andric } 81706c3fb27SDimitry Andric } 81806c3fb27SDimitry Andric#endif 81906c3fb27SDimitry Andric 8200b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 821*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8220b57cec5SDimitry Andric pair<iterator,bool> insert(value_type&& __v) 823*5f757f3fSDimitry Andric {return __tree_.__insert_unique(std::move(__v));} 8240b57cec5SDimitry Andric 825*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8260b57cec5SDimitry Andric iterator insert(const_iterator __p, value_type&& __v) 827*5f757f3fSDimitry Andric {return __tree_.__insert_unique(__p, std::move(__v));} 8280b57cec5SDimitry Andric 829*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8300b57cec5SDimitry Andric void insert(initializer_list<value_type> __il) 8310b57cec5SDimitry Andric {insert(__il.begin(), __il.end());} 8320b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 8330b57cec5SDimitry Andric 834*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8350b57cec5SDimitry Andric iterator erase(const_iterator __p) {return __tree_.erase(__p);} 836*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8370b57cec5SDimitry Andric size_type erase(const key_type& __k) 8380b57cec5SDimitry Andric {return __tree_.__erase_unique(__k);} 839*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8400b57cec5SDimitry Andric iterator erase(const_iterator __f, const_iterator __l) 8410b57cec5SDimitry Andric {return __tree_.erase(__f, __l);} 842*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8430b57cec5SDimitry Andric void clear() _NOEXCEPT {__tree_.clear();} 8440b57cec5SDimitry Andric 84506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 846*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8470b57cec5SDimitry Andric insert_return_type insert(node_type&& __nh) 8480b57cec5SDimitry Andric { 84906c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__nh.empty() || __nh.get_allocator() == get_allocator(), 8500b57cec5SDimitry Andric "node_type with incompatible allocator passed to set::insert()"); 8510b57cec5SDimitry Andric return __tree_.template __node_handle_insert_unique< 852*5f757f3fSDimitry Andric node_type, insert_return_type>(std::move(__nh)); 8530b57cec5SDimitry Andric } 854*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8550b57cec5SDimitry Andric iterator insert(const_iterator __hint, node_type&& __nh) 8560b57cec5SDimitry Andric { 85706c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__nh.empty() || __nh.get_allocator() == get_allocator(), 8580b57cec5SDimitry Andric "node_type with incompatible allocator passed to set::insert()"); 8590b57cec5SDimitry Andric return __tree_.template __node_handle_insert_unique<node_type>( 860*5f757f3fSDimitry Andric __hint, std::move(__nh)); 8610b57cec5SDimitry Andric } 862*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8630b57cec5SDimitry Andric node_type extract(key_type const& __key) 8640b57cec5SDimitry Andric { 8650b57cec5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__key); 8660b57cec5SDimitry Andric } 867*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8680b57cec5SDimitry Andric node_type extract(const_iterator __it) 8690b57cec5SDimitry Andric { 8700b57cec5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__it); 8710b57cec5SDimitry Andric } 8720b57cec5SDimitry Andric template <class _Compare2> 873*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8740b57cec5SDimitry Andric void merge(set<key_type, _Compare2, allocator_type>& __source) 8750b57cec5SDimitry Andric { 87606c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__source.get_allocator() == get_allocator(), 8770b57cec5SDimitry Andric "merging container with incompatible allocator"); 8780b57cec5SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 8790b57cec5SDimitry Andric } 8800b57cec5SDimitry Andric template <class _Compare2> 881*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8820b57cec5SDimitry Andric void merge(set<key_type, _Compare2, allocator_type>&& __source) 8830b57cec5SDimitry Andric { 88406c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__source.get_allocator() == get_allocator(), 8850b57cec5SDimitry Andric "merging container with incompatible allocator"); 8860b57cec5SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 8870b57cec5SDimitry Andric } 8880b57cec5SDimitry Andric template <class _Compare2> 889*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8900b57cec5SDimitry Andric void merge(multiset<key_type, _Compare2, allocator_type>& __source) 8910b57cec5SDimitry Andric { 89206c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__source.get_allocator() == get_allocator(), 8930b57cec5SDimitry Andric "merging container with incompatible allocator"); 8940b57cec5SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 8950b57cec5SDimitry Andric } 8960b57cec5SDimitry Andric template <class _Compare2> 897*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 8980b57cec5SDimitry Andric void merge(multiset<key_type, _Compare2, allocator_type>&& __source) 8990b57cec5SDimitry Andric { 90006c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__source.get_allocator() == get_allocator(), 9010b57cec5SDimitry Andric "merging container with incompatible allocator"); 9020b57cec5SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 9030b57cec5SDimitry Andric } 9040b57cec5SDimitry Andric#endif 9050b57cec5SDimitry Andric 906*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9070b57cec5SDimitry Andric void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) 9080b57cec5SDimitry Andric {__tree_.swap(__s.__tree_);} 9090b57cec5SDimitry Andric 910*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9110b57cec5SDimitry Andric allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} 912*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9130b57cec5SDimitry Andric key_compare key_comp() const {return __tree_.value_comp();} 914*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9150b57cec5SDimitry Andric value_compare value_comp() const {return __tree_.value_comp();} 9160b57cec5SDimitry Andric 9170b57cec5SDimitry Andric // set operations: 918*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9190b57cec5SDimitry Andric iterator find(const key_type& __k) {return __tree_.find(__k);} 920*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9210b57cec5SDimitry Andric const_iterator find(const key_type& __k) const {return __tree_.find(__k);} 92206c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 923*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 924*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 925*5f757f3fSDimitry Andric iterator 9260b57cec5SDimitry Andric find(const _K2& __k) {return __tree_.find(__k);} 927*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 928*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 929*5f757f3fSDimitry Andric const_iterator 9300b57cec5SDimitry Andric find(const _K2& __k) const {return __tree_.find(__k);} 9310b57cec5SDimitry Andric#endif 9320b57cec5SDimitry Andric 933*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9340b57cec5SDimitry Andric size_type count(const key_type& __k) const 9350b57cec5SDimitry Andric {return __tree_.__count_unique(__k);} 93606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 937*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 938*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 939*5f757f3fSDimitry Andric size_type 9400b57cec5SDimitry Andric count(const _K2& __k) const {return __tree_.__count_multi(__k);} 9410b57cec5SDimitry Andric#endif 9420b57cec5SDimitry Andric 94306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 944*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9450b57cec5SDimitry Andric bool contains(const key_type& __k) const {return find(__k) != end();} 946*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 947*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 948*5f757f3fSDimitry Andric bool 949fe6060f1SDimitry Andric contains(const _K2& __k) const { return find(__k) != end(); } 95006c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 9510b57cec5SDimitry Andric 952*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9530b57cec5SDimitry Andric iterator lower_bound(const key_type& __k) 9540b57cec5SDimitry Andric {return __tree_.lower_bound(__k);} 955*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9560b57cec5SDimitry Andric const_iterator lower_bound(const key_type& __k) const 9570b57cec5SDimitry Andric {return __tree_.lower_bound(__k);} 95806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 959*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 960*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 961*5f757f3fSDimitry Andric iterator 9620b57cec5SDimitry Andric lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} 9630b57cec5SDimitry Andric 964*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 965*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 966*5f757f3fSDimitry Andric const_iterator 9670b57cec5SDimitry Andric lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} 9680b57cec5SDimitry Andric#endif 9690b57cec5SDimitry Andric 970*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9710b57cec5SDimitry Andric iterator upper_bound(const key_type& __k) 9720b57cec5SDimitry Andric {return __tree_.upper_bound(__k);} 973*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9740b57cec5SDimitry Andric const_iterator upper_bound(const key_type& __k) const 9750b57cec5SDimitry Andric {return __tree_.upper_bound(__k);} 97606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 977*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 978*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 979*5f757f3fSDimitry Andric iterator 9800b57cec5SDimitry Andric upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} 981*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 982*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 983*5f757f3fSDimitry Andric const_iterator 9840b57cec5SDimitry Andric upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} 9850b57cec5SDimitry Andric#endif 9860b57cec5SDimitry Andric 987*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9880b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const key_type& __k) 9890b57cec5SDimitry Andric {return __tree_.__equal_range_unique(__k);} 990*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9910b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& __k) const 9920b57cec5SDimitry Andric {return __tree_.__equal_range_unique(__k);} 99306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 994*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 995*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 996*5f757f3fSDimitry Andric pair<iterator,iterator> 9970b57cec5SDimitry Andric equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} 998*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 999*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1000*5f757f3fSDimitry Andric pair<const_iterator,const_iterator> 10010b57cec5SDimitry Andric equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} 10020b57cec5SDimitry Andric#endif 10030b57cec5SDimitry Andric}; 10040b57cec5SDimitry Andric 1005349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17 10060b57cec5SDimitry Andrictemplate<class _InputIterator, 1007fe6060f1SDimitry Andric class _Compare = less<__iter_value_type<_InputIterator>>, 1008fe6060f1SDimitry Andric class _Allocator = allocator<__iter_value_type<_InputIterator>>, 100906c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, 1010349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>, 1011349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value, void>> 10120b57cec5SDimitry Andricset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) 1013fe6060f1SDimitry Andric -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>; 10140b57cec5SDimitry Andric 101506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 101606c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Compare = less<ranges::range_value_t<_Range>>, 101706c3fb27SDimitry Andric class _Allocator = allocator<ranges::range_value_t<_Range>>, 101806c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>, 101906c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value, void>> 102006c3fb27SDimitry Andricset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) 102106c3fb27SDimitry Andric -> set<ranges::range_value_t<_Range>, _Compare, _Allocator>; 102206c3fb27SDimitry Andric#endif 102306c3fb27SDimitry Andric 10240b57cec5SDimitry Andrictemplate<class _Key, class _Compare = less<_Key>, 10250b57cec5SDimitry Andric class _Allocator = allocator<_Key>, 1026349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value, void>, 1027349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>> 10280b57cec5SDimitry Andricset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) 10290b57cec5SDimitry Andric -> set<_Key, _Compare, _Allocator>; 10300b57cec5SDimitry Andric 10310b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator, 103206c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, 1033349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>> 10340b57cec5SDimitry Andricset(_InputIterator, _InputIterator, _Allocator) 1035fe6060f1SDimitry Andric -> set<__iter_value_type<_InputIterator>, 1036fe6060f1SDimitry Andric less<__iter_value_type<_InputIterator>>, _Allocator>; 10370b57cec5SDimitry Andric 103806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 103906c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, 104006c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>> 104106c3fb27SDimitry Andricset(from_range_t, _Range&&, _Allocator) 104206c3fb27SDimitry Andric -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; 104306c3fb27SDimitry Andric#endif 104406c3fb27SDimitry Andric 10450b57cec5SDimitry Andrictemplate<class _Key, class _Allocator, 1046349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>> 10470b57cec5SDimitry Andricset(initializer_list<_Key>, _Allocator) 10480b57cec5SDimitry Andric -> set<_Key, less<_Key>, _Allocator>; 10490b57cec5SDimitry Andric#endif 10500b57cec5SDimitry Andric 10510b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 10520b57cec5SDimitry Andric 10530b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 10540b57cec5SDimitry Andricset<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) 1055*5f757f3fSDimitry Andric : __tree_(std::move(__s.__tree_), __a) 10560b57cec5SDimitry Andric{ 10570b57cec5SDimitry Andric if (__a != __s.get_allocator()) 10580b57cec5SDimitry Andric { 10590b57cec5SDimitry Andric const_iterator __e = cend(); 10600b57cec5SDimitry Andric while (!__s.empty()) 1061*5f757f3fSDimitry Andric insert(__e, std::move(__s.__tree_.remove(__s.begin())->__value_)); 10620b57cec5SDimitry Andric } 10630b57cec5SDimitry Andric} 10640b57cec5SDimitry Andric 10650b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 10660b57cec5SDimitry Andric 10670b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1068*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 10690b57cec5SDimitry Andricbool 10700b57cec5SDimitry Andricoperator==(const set<_Key, _Compare, _Allocator>& __x, 10710b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 10720b57cec5SDimitry Andric{ 1073*5f757f3fSDimitry Andric return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); 10740b57cec5SDimitry Andric} 10750b57cec5SDimitry Andric 107606c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17 107706c3fb27SDimitry Andric 10780b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1079*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 10800b57cec5SDimitry Andricbool 10810b57cec5SDimitry Andricoperator< (const set<_Key, _Compare, _Allocator>& __x, 10820b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 10830b57cec5SDimitry Andric{ 1084*5f757f3fSDimitry Andric return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 10850b57cec5SDimitry Andric} 10860b57cec5SDimitry Andric 10870b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1088*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 10890b57cec5SDimitry Andricbool 10900b57cec5SDimitry Andricoperator!=(const set<_Key, _Compare, _Allocator>& __x, 10910b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 10920b57cec5SDimitry Andric{ 10930b57cec5SDimitry Andric return !(__x == __y); 10940b57cec5SDimitry Andric} 10950b57cec5SDimitry Andric 10960b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1097*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 10980b57cec5SDimitry Andricbool 10990b57cec5SDimitry Andricoperator> (const set<_Key, _Compare, _Allocator>& __x, 11000b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 11010b57cec5SDimitry Andric{ 11020b57cec5SDimitry Andric return __y < __x; 11030b57cec5SDimitry Andric} 11040b57cec5SDimitry Andric 11050b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1106*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 11070b57cec5SDimitry Andricbool 11080b57cec5SDimitry Andricoperator>=(const set<_Key, _Compare, _Allocator>& __x, 11090b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 11100b57cec5SDimitry Andric{ 11110b57cec5SDimitry Andric return !(__x < __y); 11120b57cec5SDimitry Andric} 11130b57cec5SDimitry Andric 11140b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1115*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 11160b57cec5SDimitry Andricbool 11170b57cec5SDimitry Andricoperator<=(const set<_Key, _Compare, _Allocator>& __x, 11180b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 11190b57cec5SDimitry Andric{ 11200b57cec5SDimitry Andric return !(__y < __x); 11210b57cec5SDimitry Andric} 11220b57cec5SDimitry Andric 112306c3fb27SDimitry Andric#else // _LIBCPP_STD_VER <= 17 112406c3fb27SDimitry Andric 112506c3fb27SDimitry Andrictemplate <class _Key, class _Allocator> 112606c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> 112706c3fb27SDimitry Andricoperator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) { 112806c3fb27SDimitry Andric return std::lexicographical_compare_three_way( 112906c3fb27SDimitry Andric __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>); 113006c3fb27SDimitry Andric} 113106c3fb27SDimitry Andric 113206c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER <= 17 113306c3fb27SDimitry Andric 11340b57cec5SDimitry Andric// specialized algorithms: 11350b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1136*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 11370b57cec5SDimitry Andricvoid 11380b57cec5SDimitry Andricswap(set<_Key, _Compare, _Allocator>& __x, 11390b57cec5SDimitry Andric set<_Key, _Compare, _Allocator>& __y) 11400b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 11410b57cec5SDimitry Andric{ 11420b57cec5SDimitry Andric __x.swap(__y); 11430b57cec5SDimitry Andric} 11440b57cec5SDimitry Andric 114506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 11460b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator, class _Predicate> 1147*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 11485ffd83dbSDimitry Andric typename set<_Key, _Compare, _Allocator>::size_type 11495ffd83dbSDimitry Andric erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { 1150*5f757f3fSDimitry Andric return std::__libcpp_erase_if_container(__c, __pred); 11515ffd83dbSDimitry Andric} 11520b57cec5SDimitry Andric#endif 11530b57cec5SDimitry Andric 11540b57cec5SDimitry Andrictemplate <class _Key, class _Compare = less<_Key>, 11550b57cec5SDimitry Andric class _Allocator = allocator<_Key> > 11560b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS multiset 11570b57cec5SDimitry Andric{ 11580b57cec5SDimitry Andricpublic: 11590b57cec5SDimitry Andric // types: 11600b57cec5SDimitry Andric typedef _Key key_type; 11610b57cec5SDimitry Andric typedef key_type value_type; 116281ad6265SDimitry Andric typedef __type_identity_t<_Compare> key_compare; 11630b57cec5SDimitry Andric typedef key_compare value_compare; 116481ad6265SDimitry Andric typedef __type_identity_t<_Allocator> allocator_type; 11650b57cec5SDimitry Andric typedef value_type& reference; 11660b57cec5SDimitry Andric typedef const value_type& const_reference; 11670b57cec5SDimitry Andric 11680b57cec5SDimitry Andric static_assert((is_same<typename allocator_type::value_type, value_type>::value), 11690b57cec5SDimitry Andric "Allocator::value_type must be same type as value_type"); 11700b57cec5SDimitry Andric 11710b57cec5SDimitry Andricprivate: 11720b57cec5SDimitry Andric typedef __tree<value_type, value_compare, allocator_type> __base; 11730b57cec5SDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 11740b57cec5SDimitry Andric 1175bdd1243dSDimitry Andric static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, 1176bdd1243dSDimitry Andric "[allocator.requirements] states that rebinding an allocator to the same type should result in the " 1177bdd1243dSDimitry Andric "original allocator"); 1178bdd1243dSDimitry Andric 11790b57cec5SDimitry Andric __base __tree_; 11800b57cec5SDimitry Andric 11810b57cec5SDimitry Andricpublic: 11820b57cec5SDimitry Andric typedef typename __base::pointer pointer; 11830b57cec5SDimitry Andric typedef typename __base::const_pointer const_pointer; 11840b57cec5SDimitry Andric typedef typename __base::size_type size_type; 11850b57cec5SDimitry Andric typedef typename __base::difference_type difference_type; 11860b57cec5SDimitry Andric typedef typename __base::const_iterator iterator; 11870b57cec5SDimitry Andric typedef typename __base::const_iterator const_iterator; 1188*5f757f3fSDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 1189*5f757f3fSDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 11900b57cec5SDimitry Andric 119106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 11920b57cec5SDimitry Andric typedef __set_node_handle<typename __base::__node, allocator_type> node_type; 11930b57cec5SDimitry Andric#endif 11940b57cec5SDimitry Andric 11950b57cec5SDimitry Andric template <class _Key2, class _Compare2, class _Alloc2> 11960b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS set; 11970b57cec5SDimitry Andric template <class _Key2, class _Compare2, class _Alloc2> 11980b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multiset; 11990b57cec5SDimitry Andric 12000b57cec5SDimitry Andric // construct/copy/destroy: 1201*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12020b57cec5SDimitry Andric multiset() 12030b57cec5SDimitry Andric _NOEXCEPT_( 12040b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 12050b57cec5SDimitry Andric is_nothrow_default_constructible<key_compare>::value && 12060b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 12070b57cec5SDimitry Andric : __tree_(value_compare()) {} 12080b57cec5SDimitry Andric 1209*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12100b57cec5SDimitry Andric explicit multiset(const value_compare& __comp) 12110b57cec5SDimitry Andric _NOEXCEPT_( 12120b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 12130b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 12140b57cec5SDimitry Andric : __tree_(__comp) {} 12150b57cec5SDimitry Andric 1216*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12170b57cec5SDimitry Andric explicit multiset(const value_compare& __comp, const allocator_type& __a) 12180b57cec5SDimitry Andric : __tree_(__comp, __a) {} 12190b57cec5SDimitry Andric template <class _InputIterator> 1220*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12210b57cec5SDimitry Andric multiset(_InputIterator __f, _InputIterator __l, 12220b57cec5SDimitry Andric const value_compare& __comp = value_compare()) 12230b57cec5SDimitry Andric : __tree_(__comp) 12240b57cec5SDimitry Andric { 12250b57cec5SDimitry Andric insert(__f, __l); 12260b57cec5SDimitry Andric } 12270b57cec5SDimitry Andric 122806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 12290b57cec5SDimitry Andric template <class _InputIterator> 1230*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12310b57cec5SDimitry Andric multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) 12320b57cec5SDimitry Andric : multiset(__f, __l, key_compare(), __a) {} 12330b57cec5SDimitry Andric#endif 12340b57cec5SDimitry Andric 12350b57cec5SDimitry Andric template <class _InputIterator> 1236*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12370b57cec5SDimitry Andric multiset(_InputIterator __f, _InputIterator __l, 12380b57cec5SDimitry Andric const value_compare& __comp, const allocator_type& __a) 12390b57cec5SDimitry Andric : __tree_(__comp, __a) 12400b57cec5SDimitry Andric { 12410b57cec5SDimitry Andric insert(__f, __l); 12420b57cec5SDimitry Andric } 12430b57cec5SDimitry Andric 124406c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 124506c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 124606c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 124706c3fb27SDimitry Andric multiset(from_range_t, _Range&& __range, const key_compare& __comp = key_compare(), 124806c3fb27SDimitry Andric const allocator_type& __a = allocator_type()) 124906c3fb27SDimitry Andric : __tree_(__comp, __a) { 125006c3fb27SDimitry Andric insert_range(std::forward<_Range>(__range)); 125106c3fb27SDimitry Andric } 125206c3fb27SDimitry Andric 125306c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 125406c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 125506c3fb27SDimitry Andric multiset(from_range_t, _Range&& __range, const allocator_type& __a) 125606c3fb27SDimitry Andric : multiset(from_range, std::forward<_Range>(__range), key_compare(), __a) {} 125706c3fb27SDimitry Andric#endif 125806c3fb27SDimitry Andric 1259*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12600b57cec5SDimitry Andric multiset(const multiset& __s) 12610b57cec5SDimitry Andric : __tree_(__s.__tree_.value_comp(), 12620b57cec5SDimitry Andric __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) 12630b57cec5SDimitry Andric { 12640b57cec5SDimitry Andric insert(__s.begin(), __s.end()); 12650b57cec5SDimitry Andric } 12660b57cec5SDimitry Andric 1267*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12680b57cec5SDimitry Andric multiset& operator=(const multiset& __s) 12690b57cec5SDimitry Andric { 12700b57cec5SDimitry Andric __tree_ = __s.__tree_; 12710b57cec5SDimitry Andric return *this; 12720b57cec5SDimitry Andric } 12730b57cec5SDimitry Andric 12740b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 1275*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12760b57cec5SDimitry Andric multiset(multiset&& __s) 12770b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) 1278*5f757f3fSDimitry Andric : __tree_(std::move(__s.__tree_)) {} 12790b57cec5SDimitry Andric 128006c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a); 12810b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 1282*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12830b57cec5SDimitry Andric explicit multiset(const allocator_type& __a) 12840b57cec5SDimitry Andric : __tree_(__a) {} 1285*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12860b57cec5SDimitry Andric multiset(const multiset& __s, const allocator_type& __a) 12870b57cec5SDimitry Andric : __tree_(__s.__tree_.value_comp(), __a) 12880b57cec5SDimitry Andric { 12890b57cec5SDimitry Andric insert(__s.begin(), __s.end()); 12900b57cec5SDimitry Andric } 12910b57cec5SDimitry Andric 12920b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 1293*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12940b57cec5SDimitry Andric multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) 12950b57cec5SDimitry Andric : __tree_(__comp) 12960b57cec5SDimitry Andric { 12970b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 12980b57cec5SDimitry Andric } 12990b57cec5SDimitry Andric 1300*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13010b57cec5SDimitry Andric multiset(initializer_list<value_type> __il, const value_compare& __comp, 13020b57cec5SDimitry Andric const allocator_type& __a) 13030b57cec5SDimitry Andric : __tree_(__comp, __a) 13040b57cec5SDimitry Andric { 13050b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 13060b57cec5SDimitry Andric } 13070b57cec5SDimitry Andric 130806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 1309*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13100b57cec5SDimitry Andric multiset(initializer_list<value_type> __il, const allocator_type& __a) 13110b57cec5SDimitry Andric : multiset(__il, key_compare(), __a) {} 13120b57cec5SDimitry Andric#endif 13130b57cec5SDimitry Andric 1314*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13150b57cec5SDimitry Andric multiset& operator=(initializer_list<value_type> __il) 13160b57cec5SDimitry Andric { 13170b57cec5SDimitry Andric __tree_.__assign_multi(__il.begin(), __il.end()); 13180b57cec5SDimitry Andric return *this; 13190b57cec5SDimitry Andric } 13200b57cec5SDimitry Andric 1321*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13220b57cec5SDimitry Andric multiset& operator=(multiset&& __s) 13230b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) 13240b57cec5SDimitry Andric { 1325*5f757f3fSDimitry Andric __tree_ = std::move(__s.__tree_); 13260b57cec5SDimitry Andric return *this; 13270b57cec5SDimitry Andric } 13280b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 13290b57cec5SDimitry Andric 1330*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13310b57cec5SDimitry Andric ~multiset() { 13320b57cec5SDimitry Andric static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); 13330b57cec5SDimitry Andric } 13340b57cec5SDimitry Andric 1335*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13360b57cec5SDimitry Andric iterator begin() _NOEXCEPT {return __tree_.begin();} 1337*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13380b57cec5SDimitry Andric const_iterator begin() const _NOEXCEPT {return __tree_.begin();} 1339*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13400b57cec5SDimitry Andric iterator end() _NOEXCEPT {return __tree_.end();} 1341*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13420b57cec5SDimitry Andric const_iterator end() const _NOEXCEPT {return __tree_.end();} 13430b57cec5SDimitry Andric 1344*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13450b57cec5SDimitry Andric reverse_iterator rbegin() _NOEXCEPT 13460b57cec5SDimitry Andric {return reverse_iterator(end());} 1347*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13480b57cec5SDimitry Andric const_reverse_iterator rbegin() const _NOEXCEPT 13490b57cec5SDimitry Andric {return const_reverse_iterator(end());} 1350*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13510b57cec5SDimitry Andric reverse_iterator rend() _NOEXCEPT 13520b57cec5SDimitry Andric {return reverse_iterator(begin());} 1353*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13540b57cec5SDimitry Andric const_reverse_iterator rend() const _NOEXCEPT 13550b57cec5SDimitry Andric {return const_reverse_iterator(begin());} 13560b57cec5SDimitry Andric 1357*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13580b57cec5SDimitry Andric const_iterator cbegin() const _NOEXCEPT {return begin();} 1359*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13600b57cec5SDimitry Andric const_iterator cend() const _NOEXCEPT {return end();} 1361*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13620b57cec5SDimitry Andric const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 1363*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13640b57cec5SDimitry Andric const_reverse_iterator crend() const _NOEXCEPT {return rend();} 13650b57cec5SDimitry Andric 1366*5f757f3fSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI 13670b57cec5SDimitry Andric bool empty() const _NOEXCEPT {return __tree_.size() == 0;} 1368*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13690b57cec5SDimitry Andric size_type size() const _NOEXCEPT {return __tree_.size();} 1370*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13710b57cec5SDimitry Andric size_type max_size() const _NOEXCEPT {return __tree_.max_size();} 13720b57cec5SDimitry Andric 13730b57cec5SDimitry Andric // modifiers: 13740b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 13750b57cec5SDimitry Andric template <class... _Args> 1376*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13770b57cec5SDimitry Andric iterator emplace(_Args&&... __args) 1378*5f757f3fSDimitry Andric {return __tree_.__emplace_multi(std::forward<_Args>(__args)...);} 13790b57cec5SDimitry Andric template <class... _Args> 1380*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13810b57cec5SDimitry Andric iterator emplace_hint(const_iterator __p, _Args&&... __args) 1382*5f757f3fSDimitry Andric {return __tree_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...);} 13830b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 13840b57cec5SDimitry Andric 1385*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13860b57cec5SDimitry Andric iterator insert(const value_type& __v) 13870b57cec5SDimitry Andric {return __tree_.__insert_multi(__v);} 1388*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13890b57cec5SDimitry Andric iterator insert(const_iterator __p, const value_type& __v) 13900b57cec5SDimitry Andric {return __tree_.__insert_multi(__p, __v);} 13910b57cec5SDimitry Andric 13920b57cec5SDimitry Andric template <class _InputIterator> 1393*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13940b57cec5SDimitry Andric void insert(_InputIterator __f, _InputIterator __l) 13950b57cec5SDimitry Andric { 13960b57cec5SDimitry Andric for (const_iterator __e = cend(); __f != __l; ++__f) 13970b57cec5SDimitry Andric __tree_.__insert_multi(__e, *__f); 13980b57cec5SDimitry Andric } 13990b57cec5SDimitry Andric 140006c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 140106c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 140206c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 140306c3fb27SDimitry Andric void insert_range(_Range&& __range) { 140406c3fb27SDimitry Andric const_iterator __end = cend(); 140506c3fb27SDimitry Andric for (auto&& __element : __range) { 140606c3fb27SDimitry Andric __tree_.__insert_multi(__end, std::forward<decltype(__element)>(__element)); 140706c3fb27SDimitry Andric } 140806c3fb27SDimitry Andric } 140906c3fb27SDimitry Andric#endif 141006c3fb27SDimitry Andric 14110b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 1412*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14130b57cec5SDimitry Andric iterator insert(value_type&& __v) 1414*5f757f3fSDimitry Andric {return __tree_.__insert_multi(std::move(__v));} 14150b57cec5SDimitry Andric 1416*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14170b57cec5SDimitry Andric iterator insert(const_iterator __p, value_type&& __v) 1418*5f757f3fSDimitry Andric {return __tree_.__insert_multi(__p, std::move(__v));} 14190b57cec5SDimitry Andric 1420*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14210b57cec5SDimitry Andric void insert(initializer_list<value_type> __il) 14220b57cec5SDimitry Andric {insert(__il.begin(), __il.end());} 14230b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 14240b57cec5SDimitry Andric 1425*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14260b57cec5SDimitry Andric iterator erase(const_iterator __p) {return __tree_.erase(__p);} 1427*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14280b57cec5SDimitry Andric size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} 1429*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14300b57cec5SDimitry Andric iterator erase(const_iterator __f, const_iterator __l) 14310b57cec5SDimitry Andric {return __tree_.erase(__f, __l);} 1432*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14330b57cec5SDimitry Andric void clear() _NOEXCEPT {__tree_.clear();} 14340b57cec5SDimitry Andric 143506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 1436*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14370b57cec5SDimitry Andric iterator insert(node_type&& __nh) 14380b57cec5SDimitry Andric { 143906c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__nh.empty() || __nh.get_allocator() == get_allocator(), 14400b57cec5SDimitry Andric "node_type with incompatible allocator passed to multiset::insert()"); 14410b57cec5SDimitry Andric return __tree_.template __node_handle_insert_multi<node_type>( 1442*5f757f3fSDimitry Andric std::move(__nh)); 14430b57cec5SDimitry Andric } 1444*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14450b57cec5SDimitry Andric iterator insert(const_iterator __hint, node_type&& __nh) 14460b57cec5SDimitry Andric { 144706c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__nh.empty() || __nh.get_allocator() == get_allocator(), 14480b57cec5SDimitry Andric "node_type with incompatible allocator passed to multiset::insert()"); 14490b57cec5SDimitry Andric return __tree_.template __node_handle_insert_multi<node_type>( 1450*5f757f3fSDimitry Andric __hint, std::move(__nh)); 14510b57cec5SDimitry Andric } 1452*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14530b57cec5SDimitry Andric node_type extract(key_type const& __key) 14540b57cec5SDimitry Andric { 14550b57cec5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__key); 14560b57cec5SDimitry Andric } 1457*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14580b57cec5SDimitry Andric node_type extract(const_iterator __it) 14590b57cec5SDimitry Andric { 14600b57cec5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__it); 14610b57cec5SDimitry Andric } 14620b57cec5SDimitry Andric template <class _Compare2> 1463*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14640b57cec5SDimitry Andric void merge(multiset<key_type, _Compare2, allocator_type>& __source) 14650b57cec5SDimitry Andric { 146606c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__source.get_allocator() == get_allocator(), 14670b57cec5SDimitry Andric "merging container with incompatible allocator"); 14680b57cec5SDimitry Andric __tree_.__node_handle_merge_multi(__source.__tree_); 14690b57cec5SDimitry Andric } 14700b57cec5SDimitry Andric template <class _Compare2> 1471*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14720b57cec5SDimitry Andric void merge(multiset<key_type, _Compare2, allocator_type>&& __source) 14730b57cec5SDimitry Andric { 147406c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__source.get_allocator() == get_allocator(), 14750b57cec5SDimitry Andric "merging container with incompatible allocator"); 14760b57cec5SDimitry Andric __tree_.__node_handle_merge_multi(__source.__tree_); 14770b57cec5SDimitry Andric } 14780b57cec5SDimitry Andric template <class _Compare2> 1479*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14800b57cec5SDimitry Andric void merge(set<key_type, _Compare2, allocator_type>& __source) 14810b57cec5SDimitry Andric { 148206c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__source.get_allocator() == get_allocator(), 14830b57cec5SDimitry Andric "merging container with incompatible allocator"); 14840b57cec5SDimitry Andric __tree_.__node_handle_merge_multi(__source.__tree_); 14850b57cec5SDimitry Andric } 14860b57cec5SDimitry Andric template <class _Compare2> 1487*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14880b57cec5SDimitry Andric void merge(set<key_type, _Compare2, allocator_type>&& __source) 14890b57cec5SDimitry Andric { 149006c3fb27SDimitry Andric _LIBCPP_ASSERT_UNCATEGORIZED(__source.get_allocator() == get_allocator(), 14910b57cec5SDimitry Andric "merging container with incompatible allocator"); 14920b57cec5SDimitry Andric __tree_.__node_handle_merge_multi(__source.__tree_); 14930b57cec5SDimitry Andric } 14940b57cec5SDimitry Andric#endif 14950b57cec5SDimitry Andric 1496*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14970b57cec5SDimitry Andric void swap(multiset& __s) 14980b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<__base>::value) 14990b57cec5SDimitry Andric {__tree_.swap(__s.__tree_);} 15000b57cec5SDimitry Andric 1501*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15020b57cec5SDimitry Andric allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} 1503*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15040b57cec5SDimitry Andric key_compare key_comp() const {return __tree_.value_comp();} 1505*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15060b57cec5SDimitry Andric value_compare value_comp() const {return __tree_.value_comp();} 15070b57cec5SDimitry Andric 15080b57cec5SDimitry Andric // set operations: 1509*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15100b57cec5SDimitry Andric iterator find(const key_type& __k) {return __tree_.find(__k);} 1511*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15120b57cec5SDimitry Andric const_iterator find(const key_type& __k) const {return __tree_.find(__k);} 151306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 1514*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1515*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1516*5f757f3fSDimitry Andric iterator 15170b57cec5SDimitry Andric find(const _K2& __k) {return __tree_.find(__k);} 1518*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1519*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1520*5f757f3fSDimitry Andric const_iterator 15210b57cec5SDimitry Andric find(const _K2& __k) const {return __tree_.find(__k);} 15220b57cec5SDimitry Andric#endif 15230b57cec5SDimitry Andric 1524*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15250b57cec5SDimitry Andric size_type count(const key_type& __k) const 15260b57cec5SDimitry Andric {return __tree_.__count_multi(__k);} 152706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 1528*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1529*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1530*5f757f3fSDimitry Andric size_type 15310b57cec5SDimitry Andric count(const _K2& __k) const {return __tree_.__count_multi(__k);} 15320b57cec5SDimitry Andric#endif 15330b57cec5SDimitry Andric 153406c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 1535*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15360b57cec5SDimitry Andric bool contains(const key_type& __k) const {return find(__k) != end();} 1537*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1538*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1539*5f757f3fSDimitry Andric bool 1540fe6060f1SDimitry Andric contains(const _K2& __k) const { return find(__k) != end(); } 154106c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 15420b57cec5SDimitry Andric 1543*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15440b57cec5SDimitry Andric iterator lower_bound(const key_type& __k) 15450b57cec5SDimitry Andric {return __tree_.lower_bound(__k);} 1546*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15470b57cec5SDimitry Andric const_iterator lower_bound(const key_type& __k) const 15480b57cec5SDimitry Andric {return __tree_.lower_bound(__k);} 154906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 1550*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1551*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1552*5f757f3fSDimitry Andric iterator 15530b57cec5SDimitry Andric lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} 15540b57cec5SDimitry Andric 1555*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1556*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1557*5f757f3fSDimitry Andric const_iterator 15580b57cec5SDimitry Andric lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} 15590b57cec5SDimitry Andric#endif 15600b57cec5SDimitry Andric 1561*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15620b57cec5SDimitry Andric iterator upper_bound(const key_type& __k) 15630b57cec5SDimitry Andric {return __tree_.upper_bound(__k);} 1564*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15650b57cec5SDimitry Andric const_iterator upper_bound(const key_type& __k) const 15660b57cec5SDimitry Andric {return __tree_.upper_bound(__k);} 156706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 1568*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1569*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1570*5f757f3fSDimitry Andric iterator 15710b57cec5SDimitry Andric upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} 1572*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1573*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1574*5f757f3fSDimitry Andric const_iterator 15750b57cec5SDimitry Andric upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} 15760b57cec5SDimitry Andric#endif 15770b57cec5SDimitry Andric 1578*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15790b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const key_type& __k) 15800b57cec5SDimitry Andric {return __tree_.__equal_range_multi(__k);} 1581*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15820b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& __k) const 15830b57cec5SDimitry Andric {return __tree_.__equal_range_multi(__k);} 158406c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 1585*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1586*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1587*5f757f3fSDimitry Andric pair<iterator,iterator> 15880b57cec5SDimitry Andric equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} 1589*5f757f3fSDimitry Andric template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> 1590*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1591*5f757f3fSDimitry Andric pair<const_iterator,const_iterator> 15920b57cec5SDimitry Andric equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} 15930b57cec5SDimitry Andric#endif 15940b57cec5SDimitry Andric}; 15950b57cec5SDimitry Andric 1596349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17 15970b57cec5SDimitry Andrictemplate<class _InputIterator, 1598fe6060f1SDimitry Andric class _Compare = less<__iter_value_type<_InputIterator>>, 1599fe6060f1SDimitry Andric class _Allocator = allocator<__iter_value_type<_InputIterator>>, 160006c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, 1601349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>, 1602349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value, void>> 16030b57cec5SDimitry Andricmultiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) 1604fe6060f1SDimitry Andric -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>; 16050b57cec5SDimitry Andric 160606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 160706c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Compare = less<ranges::range_value_t<_Range>>, 160806c3fb27SDimitry Andric class _Allocator = allocator<ranges::range_value_t<_Range>>, 160906c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>, 161006c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value, void>> 161106c3fb27SDimitry Andricmultiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) 161206c3fb27SDimitry Andric -> multiset<ranges::range_value_t<_Range>, _Compare, _Allocator>; 161306c3fb27SDimitry Andric#endif 161406c3fb27SDimitry Andric 16150b57cec5SDimitry Andrictemplate<class _Key, class _Compare = less<_Key>, 16160b57cec5SDimitry Andric class _Allocator = allocator<_Key>, 1617349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>, 1618349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value, void>> 16190b57cec5SDimitry Andricmultiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) 16200b57cec5SDimitry Andric -> multiset<_Key, _Compare, _Allocator>; 16210b57cec5SDimitry Andric 16220b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator, 162306c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, 1624349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>> 16250b57cec5SDimitry Andricmultiset(_InputIterator, _InputIterator, _Allocator) 1626fe6060f1SDimitry Andric -> multiset<__iter_value_type<_InputIterator>, 1627fe6060f1SDimitry Andric less<__iter_value_type<_InputIterator>>, _Allocator>; 16280b57cec5SDimitry Andric 162906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 163006c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, 163106c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>> 163206c3fb27SDimitry Andricmultiset(from_range_t, _Range&&, _Allocator) 163306c3fb27SDimitry Andric -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; 163406c3fb27SDimitry Andric#endif 163506c3fb27SDimitry Andric 16360b57cec5SDimitry Andrictemplate<class _Key, class _Allocator, 1637349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value, void>> 16380b57cec5SDimitry Andricmultiset(initializer_list<_Key>, _Allocator) 16390b57cec5SDimitry Andric -> multiset<_Key, less<_Key>, _Allocator>; 16400b57cec5SDimitry Andric#endif 16410b57cec5SDimitry Andric 16420b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 16430b57cec5SDimitry Andric 16440b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 16450b57cec5SDimitry Andricmultiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) 1646*5f757f3fSDimitry Andric : __tree_(std::move(__s.__tree_), __a) 16470b57cec5SDimitry Andric{ 16480b57cec5SDimitry Andric if (__a != __s.get_allocator()) 16490b57cec5SDimitry Andric { 16500b57cec5SDimitry Andric const_iterator __e = cend(); 16510b57cec5SDimitry Andric while (!__s.empty()) 1652*5f757f3fSDimitry Andric insert(__e, std::move(__s.__tree_.remove(__s.begin())->__value_)); 16530b57cec5SDimitry Andric } 16540b57cec5SDimitry Andric} 16550b57cec5SDimitry Andric 16560b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 16570b57cec5SDimitry Andric 16580b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1659*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 16600b57cec5SDimitry Andricbool 16610b57cec5SDimitry Andricoperator==(const multiset<_Key, _Compare, _Allocator>& __x, 16620b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 16630b57cec5SDimitry Andric{ 1664*5f757f3fSDimitry Andric return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); 16650b57cec5SDimitry Andric} 16660b57cec5SDimitry Andric 166706c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17 166806c3fb27SDimitry Andric 16690b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1670*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 16710b57cec5SDimitry Andricbool 16720b57cec5SDimitry Andricoperator< (const multiset<_Key, _Compare, _Allocator>& __x, 16730b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 16740b57cec5SDimitry Andric{ 1675*5f757f3fSDimitry Andric return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 16760b57cec5SDimitry Andric} 16770b57cec5SDimitry Andric 16780b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1679*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 16800b57cec5SDimitry Andricbool 16810b57cec5SDimitry Andricoperator!=(const multiset<_Key, _Compare, _Allocator>& __x, 16820b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 16830b57cec5SDimitry Andric{ 16840b57cec5SDimitry Andric return !(__x == __y); 16850b57cec5SDimitry Andric} 16860b57cec5SDimitry Andric 16870b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1688*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 16890b57cec5SDimitry Andricbool 16900b57cec5SDimitry Andricoperator> (const multiset<_Key, _Compare, _Allocator>& __x, 16910b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 16920b57cec5SDimitry Andric{ 16930b57cec5SDimitry Andric return __y < __x; 16940b57cec5SDimitry Andric} 16950b57cec5SDimitry Andric 16960b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1697*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 16980b57cec5SDimitry Andricbool 16990b57cec5SDimitry Andricoperator>=(const multiset<_Key, _Compare, _Allocator>& __x, 17000b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 17010b57cec5SDimitry Andric{ 17020b57cec5SDimitry Andric return !(__x < __y); 17030b57cec5SDimitry Andric} 17040b57cec5SDimitry Andric 17050b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1706*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 17070b57cec5SDimitry Andricbool 17080b57cec5SDimitry Andricoperator<=(const multiset<_Key, _Compare, _Allocator>& __x, 17090b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 17100b57cec5SDimitry Andric{ 17110b57cec5SDimitry Andric return !(__y < __x); 17120b57cec5SDimitry Andric} 17130b57cec5SDimitry Andric 171406c3fb27SDimitry Andric#else // _LIBCPP_STD_VER <= 17 171506c3fb27SDimitry Andric 171606c3fb27SDimitry Andrictemplate <class _Key, class _Allocator> 171706c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> 171806c3fb27SDimitry Andricoperator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) { 171906c3fb27SDimitry Andric return std::lexicographical_compare_three_way( 172006c3fb27SDimitry Andric __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>); 172106c3fb27SDimitry Andric} 172206c3fb27SDimitry Andric 172306c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER <= 17 172406c3fb27SDimitry Andric 17250b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 1726*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 17270b57cec5SDimitry Andricvoid 17280b57cec5SDimitry Andricswap(multiset<_Key, _Compare, _Allocator>& __x, 17290b57cec5SDimitry Andric multiset<_Key, _Compare, _Allocator>& __y) 17300b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 17310b57cec5SDimitry Andric{ 17320b57cec5SDimitry Andric __x.swap(__y); 17330b57cec5SDimitry Andric} 17340b57cec5SDimitry Andric 173506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 17360b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator, class _Predicate> 1737*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 17385ffd83dbSDimitry Andric typename multiset<_Key, _Compare, _Allocator>::size_type 17395ffd83dbSDimitry Andric erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { 1740*5f757f3fSDimitry Andric return std::__libcpp_erase_if_container(__c, __pred); 17415ffd83dbSDimitry Andric} 17420b57cec5SDimitry Andric#endif 17430b57cec5SDimitry Andric 17440b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 17450b57cec5SDimitry Andric 174606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 1747bdd1243dSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 1748bdd1243dSDimitry Andricnamespace pmr { 1749bdd1243dSDimitry Andrictemplate <class _KeyT, class _CompareT = std::less<_KeyT>> 175006c3fb27SDimitry Andricusing set _LIBCPP_AVAILABILITY_PMR = std::set<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>; 1751bdd1243dSDimitry Andric 1752bdd1243dSDimitry Andrictemplate <class _KeyT, class _CompareT = std::less<_KeyT>> 175306c3fb27SDimitry Andricusing multiset _LIBCPP_AVAILABILITY_PMR = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>; 1754bdd1243dSDimitry Andric} // namespace pmr 1755bdd1243dSDimitry Andric_LIBCPP_END_NAMESPACE_STD 1756bdd1243dSDimitry Andric#endif 1757bdd1243dSDimitry Andric 1758bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 1759bdd1243dSDimitry Andric# include <concepts> 176006c3fb27SDimitry Andric# include <cstdlib> 1761bdd1243dSDimitry Andric# include <functional> 1762bdd1243dSDimitry Andric# include <iterator> 1763*5f757f3fSDimitry Andric# include <stdexcept> 176406c3fb27SDimitry Andric# include <type_traits> 1765bdd1243dSDimitry Andric#endif 1766bdd1243dSDimitry Andric 17670b57cec5SDimitry Andric#endif // _LIBCPP_SET 1768