xref: /freebsd/contrib/llvm-project/libcxx/include/__cxx03/set (revision 700637cbb5e582861067a11aaca4d053546871d2)
1*700637cbSDimitry Andric// -*- C++ -*-
2*700637cbSDimitry Andric//===----------------------------------------------------------------------===//
3*700637cbSDimitry Andric//
4*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
6*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*700637cbSDimitry Andric//
8*700637cbSDimitry Andric//===----------------------------------------------------------------------===//
9*700637cbSDimitry Andric
10*700637cbSDimitry Andric#ifndef _LIBCPP___CXX03_SET
11*700637cbSDimitry Andric#define _LIBCPP___CXX03_SET
12*700637cbSDimitry Andric
13*700637cbSDimitry Andric/*
14*700637cbSDimitry Andric
15*700637cbSDimitry Andric    set synopsis
16*700637cbSDimitry Andric
17*700637cbSDimitry Andricnamespace std
18*700637cbSDimitry Andric{
19*700637cbSDimitry Andric
20*700637cbSDimitry Andrictemplate <class Key, class Compare = less<Key>,
21*700637cbSDimitry Andric          class Allocator = allocator<Key>>
22*700637cbSDimitry Andricclass set
23*700637cbSDimitry Andric{
24*700637cbSDimitry Andricpublic:
25*700637cbSDimitry Andric    // types:
26*700637cbSDimitry Andric    typedef Key                                      key_type;
27*700637cbSDimitry Andric    typedef key_type                                 value_type;
28*700637cbSDimitry Andric    typedef Compare                                  key_compare;
29*700637cbSDimitry Andric    typedef key_compare                              value_compare;
30*700637cbSDimitry Andric    typedef Allocator                                allocator_type;
31*700637cbSDimitry Andric    typedef typename allocator_type::reference       reference;
32*700637cbSDimitry Andric    typedef typename allocator_type::const_reference const_reference;
33*700637cbSDimitry Andric    typedef typename allocator_type::size_type       size_type;
34*700637cbSDimitry Andric    typedef typename allocator_type::difference_type difference_type;
35*700637cbSDimitry Andric    typedef typename allocator_type::pointer         pointer;
36*700637cbSDimitry Andric    typedef typename allocator_type::const_pointer   const_pointer;
37*700637cbSDimitry Andric
38*700637cbSDimitry Andric    typedef implementation-defined                   iterator;
39*700637cbSDimitry Andric    typedef implementation-defined                   const_iterator;
40*700637cbSDimitry Andric    typedef std::reverse_iterator<iterator>          reverse_iterator;
41*700637cbSDimitry Andric    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
42*700637cbSDimitry Andric    typedef unspecified                              node_type;               // C++17
43*700637cbSDimitry Andric    typedef INSERT_RETURN_TYPE<iterator, node_type>  insert_return_type;      // C++17
44*700637cbSDimitry Andric
45*700637cbSDimitry Andric    // construct/copy/destroy:
46*700637cbSDimitry Andric    set()
47*700637cbSDimitry Andric        noexcept(
48*700637cbSDimitry Andric            is_nothrow_default_constructible<allocator_type>::value &&
49*700637cbSDimitry Andric            is_nothrow_default_constructible<key_compare>::value &&
50*700637cbSDimitry Andric            is_nothrow_copy_constructible<key_compare>::value);
51*700637cbSDimitry Andric    explicit set(const value_compare& comp);
52*700637cbSDimitry Andric    set(const value_compare& comp, const allocator_type& a);
53*700637cbSDimitry Andric    template <class InputIterator>
54*700637cbSDimitry Andric        set(InputIterator first, InputIterator last,
55*700637cbSDimitry Andric            const value_compare& comp = value_compare());
56*700637cbSDimitry Andric    template <class InputIterator>
57*700637cbSDimitry Andric        set(InputIterator first, InputIterator last, const value_compare& comp,
58*700637cbSDimitry Andric            const allocator_type& a);
59*700637cbSDimitry Andric    template<container-compatible-range<value_type> R>
60*700637cbSDimitry Andric      set(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23
61*700637cbSDimitry Andric    set(const set& s);
62*700637cbSDimitry Andric    set(set&& s)
63*700637cbSDimitry Andric        noexcept(
64*700637cbSDimitry Andric            is_nothrow_move_constructible<allocator_type>::value &&
65*700637cbSDimitry Andric            is_nothrow_move_constructible<key_compare>::value);
66*700637cbSDimitry Andric    explicit set(const allocator_type& a);
67*700637cbSDimitry Andric    set(const set& s, const allocator_type& a);
68*700637cbSDimitry Andric    set(set&& s, const allocator_type& a);
69*700637cbSDimitry Andric    set(initializer_list<value_type> il, const value_compare& comp = value_compare());
70*700637cbSDimitry Andric    set(initializer_list<value_type> il, const value_compare& comp,
71*700637cbSDimitry Andric        const allocator_type& a);
72*700637cbSDimitry Andric    template <class InputIterator>
73*700637cbSDimitry Andric        set(InputIterator first, InputIterator last, const allocator_type& a)
74*700637cbSDimitry Andric            : set(first, last, Compare(), a) {}  // C++14
75*700637cbSDimitry Andric    template<container-compatible-range<value_type> R>
76*700637cbSDimitry Andric      set(from_range_t, R&& rg, const Allocator& a))
77*700637cbSDimitry Andric        : set(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
78*700637cbSDimitry Andric    set(initializer_list<value_type> il, const allocator_type& a)
79*700637cbSDimitry Andric        : set(il, Compare(), a) {}  // C++14
80*700637cbSDimitry Andric    ~set();
81*700637cbSDimitry Andric
82*700637cbSDimitry Andric    set& operator=(const set& s);
83*700637cbSDimitry Andric    set& operator=(set&& s)
84*700637cbSDimitry Andric        noexcept(
85*700637cbSDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
86*700637cbSDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
87*700637cbSDimitry Andric            is_nothrow_move_assignable<key_compare>::value);
88*700637cbSDimitry Andric    set& operator=(initializer_list<value_type> il);
89*700637cbSDimitry Andric
90*700637cbSDimitry Andric    // iterators:
91*700637cbSDimitry Andric          iterator begin() noexcept;
92*700637cbSDimitry Andric    const_iterator begin() const noexcept;
93*700637cbSDimitry Andric          iterator end() noexcept;
94*700637cbSDimitry Andric    const_iterator end()   const noexcept;
95*700637cbSDimitry Andric
96*700637cbSDimitry Andric          reverse_iterator rbegin() noexcept;
97*700637cbSDimitry Andric    const_reverse_iterator rbegin() const noexcept;
98*700637cbSDimitry Andric          reverse_iterator rend() noexcept;
99*700637cbSDimitry Andric    const_reverse_iterator rend()   const noexcept;
100*700637cbSDimitry Andric
101*700637cbSDimitry Andric    const_iterator         cbegin()  const noexcept;
102*700637cbSDimitry Andric    const_iterator         cend()    const noexcept;
103*700637cbSDimitry Andric    const_reverse_iterator crbegin() const noexcept;
104*700637cbSDimitry Andric    const_reverse_iterator crend()   const noexcept;
105*700637cbSDimitry Andric
106*700637cbSDimitry Andric    // capacity:
107*700637cbSDimitry Andric    bool      empty()    const noexcept;
108*700637cbSDimitry Andric    size_type size()     const noexcept;
109*700637cbSDimitry Andric    size_type max_size() const noexcept;
110*700637cbSDimitry Andric
111*700637cbSDimitry Andric    // modifiers:
112*700637cbSDimitry Andric    template <class... Args>
113*700637cbSDimitry Andric        pair<iterator, bool> emplace(Args&&... args);
114*700637cbSDimitry Andric    template <class... Args>
115*700637cbSDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
116*700637cbSDimitry Andric    pair<iterator,bool> insert(const value_type& v);
117*700637cbSDimitry Andric    pair<iterator,bool> insert(value_type&& v);
118*700637cbSDimitry Andric    iterator insert(const_iterator position, const value_type& v);
119*700637cbSDimitry Andric    iterator insert(const_iterator position, value_type&& v);
120*700637cbSDimitry Andric    template <class InputIterator>
121*700637cbSDimitry Andric        void insert(InputIterator first, InputIterator last);
122*700637cbSDimitry Andric    template<container-compatible-range<value_type> R>
123*700637cbSDimitry Andric      void insert_range(R&& rg);                                                      // C++23
124*700637cbSDimitry Andric    void insert(initializer_list<value_type> il);
125*700637cbSDimitry Andric
126*700637cbSDimitry Andric    node_type extract(const_iterator position);                                       // C++17
127*700637cbSDimitry Andric    node_type extract(const key_type& x);                                             // C++17
128*700637cbSDimitry Andric    insert_return_type insert(node_type&& nh);                                        // C++17
129*700637cbSDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);                             // C++17
130*700637cbSDimitry Andric
131*700637cbSDimitry Andric    iterator  erase(const_iterator position);
132*700637cbSDimitry Andric    iterator  erase(iterator position);  // C++14
133*700637cbSDimitry Andric    size_type erase(const key_type& k);
134*700637cbSDimitry Andric    iterator  erase(const_iterator first, const_iterator last);
135*700637cbSDimitry Andric    void clear() noexcept;
136*700637cbSDimitry Andric
137*700637cbSDimitry Andric    template<class C2>
138*700637cbSDimitry Andric      void merge(set<Key, C2, Allocator>& source);         // C++17
139*700637cbSDimitry Andric    template<class C2>
140*700637cbSDimitry Andric      void merge(set<Key, C2, Allocator>&& source);        // C++17
141*700637cbSDimitry Andric    template<class C2>
142*700637cbSDimitry Andric      void merge(multiset<Key, C2, Allocator>& source);    // C++17
143*700637cbSDimitry Andric    template<class C2>
144*700637cbSDimitry Andric      void merge(multiset<Key, C2, Allocator>&& source);   // C++17
145*700637cbSDimitry Andric
146*700637cbSDimitry Andric    void swap(set& s)
147*700637cbSDimitry Andric        noexcept(
148*700637cbSDimitry Andric            __is_nothrow_swappable<key_compare>::value &&
149*700637cbSDimitry Andric            (!allocator_type::propagate_on_container_swap::value ||
150*700637cbSDimitry Andric             __is_nothrow_swappable<allocator_type>::value));
151*700637cbSDimitry Andric
152*700637cbSDimitry Andric    // observers:
153*700637cbSDimitry Andric    allocator_type get_allocator() const noexcept;
154*700637cbSDimitry Andric    key_compare    key_comp()      const;
155*700637cbSDimitry Andric    value_compare  value_comp()    const;
156*700637cbSDimitry Andric
157*700637cbSDimitry Andric    // set operations:
158*700637cbSDimitry Andric          iterator find(const key_type& k);
159*700637cbSDimitry Andric    const_iterator find(const key_type& k) const;
160*700637cbSDimitry Andric    template<typename K>
161*700637cbSDimitry Andric        iterator find(const K& x);
162*700637cbSDimitry Andric    template<typename K>
163*700637cbSDimitry Andric        const_iterator find(const K& x) const;  // C++14
164*700637cbSDimitry Andric
165*700637cbSDimitry Andric    template<typename K>
166*700637cbSDimitry Andric        size_type count(const K& x) const;        // C++14
167*700637cbSDimitry Andric    size_type      count(const key_type& k) const;
168*700637cbSDimitry Andric
169*700637cbSDimitry Andric    bool           contains(const key_type& x) const;  // C++20
170*700637cbSDimitry Andric    template<class K> bool contains(const K& x) const; // C++20
171*700637cbSDimitry Andric
172*700637cbSDimitry Andric          iterator lower_bound(const key_type& k);
173*700637cbSDimitry Andric    const_iterator lower_bound(const key_type& k) const;
174*700637cbSDimitry Andric    template<typename K>
175*700637cbSDimitry Andric        iterator lower_bound(const K& x);              // C++14
176*700637cbSDimitry Andric    template<typename K>
177*700637cbSDimitry Andric        const_iterator lower_bound(const K& x) const;  // C++14
178*700637cbSDimitry Andric
179*700637cbSDimitry Andric          iterator upper_bound(const key_type& k);
180*700637cbSDimitry Andric    const_iterator upper_bound(const key_type& k) const;
181*700637cbSDimitry Andric    template<typename K>
182*700637cbSDimitry Andric        iterator upper_bound(const K& x);              // C++14
183*700637cbSDimitry Andric    template<typename K>
184*700637cbSDimitry Andric        const_iterator upper_bound(const K& x) const;  // C++14
185*700637cbSDimitry Andric    pair<iterator,iterator>             equal_range(const key_type& k);
186*700637cbSDimitry Andric    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
187*700637cbSDimitry Andric    template<typename K>
188*700637cbSDimitry Andric        pair<iterator,iterator>             equal_range(const K& x);        // C++14
189*700637cbSDimitry Andric    template<typename K>
190*700637cbSDimitry Andric        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
191*700637cbSDimitry Andric};
192*700637cbSDimitry Andric
193*700637cbSDimitry Andrictemplate <class InputIterator,
194*700637cbSDimitry Andric      class Compare = less<typename iterator_traits<InputIterator>::value_type>,
195*700637cbSDimitry Andric      class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
196*700637cbSDimitry Andricset(InputIterator, InputIterator,
197*700637cbSDimitry Andric    Compare = Compare(), Allocator = Allocator())
198*700637cbSDimitry Andric  -> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17
199*700637cbSDimitry Andric
200*700637cbSDimitry Andrictemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
201*700637cbSDimitry Andric         class Allocator = allocator<ranges::range_value_t<R>>>
202*700637cbSDimitry Andric  set(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
203*700637cbSDimitry Andric    -> set<ranges::range_value_t<R>, Compare, Allocator>; // C++23
204*700637cbSDimitry Andric
205*700637cbSDimitry Andrictemplate<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
206*700637cbSDimitry Andricset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
207*700637cbSDimitry Andric  -> set<Key, Compare, Allocator>; // C++17
208*700637cbSDimitry Andric
209*700637cbSDimitry Andrictemplate<class InputIterator, class Allocator>
210*700637cbSDimitry Andricset(InputIterator, InputIterator, Allocator)
211*700637cbSDimitry Andric  -> set<typename iterator_traits<InputIterator>::value_type,
212*700637cbSDimitry Andric          less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
213*700637cbSDimitry Andric
214*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator>
215*700637cbSDimitry Andric  set(from_range_t, R&&, Allocator)
216*700637cbSDimitry Andric    -> set<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, Allocator>; // C++23
217*700637cbSDimitry Andric
218*700637cbSDimitry Andrictemplate<class Key, class Allocator>
219*700637cbSDimitry Andricset(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>; // C++17
220*700637cbSDimitry Andric
221*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
222*700637cbSDimitry Andricbool
223*700637cbSDimitry Andricoperator==(const set<Key, Compare, Allocator>& x,
224*700637cbSDimitry Andric           const set<Key, Compare, Allocator>& y);
225*700637cbSDimitry Andric
226*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
227*700637cbSDimitry Andricbool
228*700637cbSDimitry Andricoperator< (const set<Key, Compare, Allocator>& x,
229*700637cbSDimitry Andric           const set<Key, Compare, Allocator>& y);                                // removed in C++20
230*700637cbSDimitry Andric
231*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
232*700637cbSDimitry Andricbool
233*700637cbSDimitry Andricoperator!=(const set<Key, Compare, Allocator>& x,
234*700637cbSDimitry Andric           const set<Key, Compare, Allocator>& y);                                // removed in C++20
235*700637cbSDimitry Andric
236*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
237*700637cbSDimitry Andricbool
238*700637cbSDimitry Andricoperator> (const set<Key, Compare, Allocator>& x,
239*700637cbSDimitry Andric           const set<Key, Compare, Allocator>& y);                                // removed in C++20
240*700637cbSDimitry Andric
241*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
242*700637cbSDimitry Andricbool
243*700637cbSDimitry Andricoperator>=(const set<Key, Compare, Allocator>& x,
244*700637cbSDimitry Andric           const set<Key, Compare, Allocator>& y);                                // removed in C++20
245*700637cbSDimitry Andric
246*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
247*700637cbSDimitry Andricbool
248*700637cbSDimitry Andricoperator<=(const set<Key, Compare, Allocator>& x,
249*700637cbSDimitry Andric           const set<Key, Compare, Allocator>& y);                                // removed in C++20
250*700637cbSDimitry Andric
251*700637cbSDimitry Andrictemplate<class Key, class Compare, class Allocator>
252*700637cbSDimitry Andric  synth-three-way-result<Key> operator<=>(const set<Key, Compare, Allocator>& x,
253*700637cbSDimitry Andric                                          const set<Key, Compare, Allocator>& y); // since C++20
254*700637cbSDimitry Andric
255*700637cbSDimitry Andric// specialized algorithms:
256*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
257*700637cbSDimitry Andricvoid
258*700637cbSDimitry Andricswap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
259*700637cbSDimitry Andric    noexcept(noexcept(x.swap(y)));
260*700637cbSDimitry Andric
261*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator, class Predicate>
262*700637cbSDimitry Andrictypename set<Key, Compare, Allocator>::size_type
263*700637cbSDimitry Andricerase_if(set<Key, Compare, Allocator>& c, Predicate pred);  // C++20
264*700637cbSDimitry Andric
265*700637cbSDimitry Andrictemplate <class Key, class Compare = less<Key>,
266*700637cbSDimitry Andric          class Allocator = allocator<Key>>
267*700637cbSDimitry Andricclass multiset
268*700637cbSDimitry Andric{
269*700637cbSDimitry Andricpublic:
270*700637cbSDimitry Andric    // types:
271*700637cbSDimitry Andric    typedef Key                                      key_type;
272*700637cbSDimitry Andric    typedef key_type                                 value_type;
273*700637cbSDimitry Andric    typedef Compare                                  key_compare;
274*700637cbSDimitry Andric    typedef key_compare                              value_compare;
275*700637cbSDimitry Andric    typedef Allocator                                allocator_type;
276*700637cbSDimitry Andric    typedef typename allocator_type::reference       reference;
277*700637cbSDimitry Andric    typedef typename allocator_type::const_reference const_reference;
278*700637cbSDimitry Andric    typedef typename allocator_type::size_type       size_type;
279*700637cbSDimitry Andric    typedef typename allocator_type::difference_type difference_type;
280*700637cbSDimitry Andric    typedef typename allocator_type::pointer         pointer;
281*700637cbSDimitry Andric    typedef typename allocator_type::const_pointer   const_pointer;
282*700637cbSDimitry Andric
283*700637cbSDimitry Andric    typedef implementation-defined                   iterator;
284*700637cbSDimitry Andric    typedef implementation-defined                   const_iterator;
285*700637cbSDimitry Andric    typedef std::reverse_iterator<iterator>          reverse_iterator;
286*700637cbSDimitry Andric    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
287*700637cbSDimitry Andric    typedef unspecified                              node_type;               // C++17
288*700637cbSDimitry Andric
289*700637cbSDimitry Andric    // construct/copy/destroy:
290*700637cbSDimitry Andric    multiset()
291*700637cbSDimitry Andric        noexcept(
292*700637cbSDimitry Andric            is_nothrow_default_constructible<allocator_type>::value &&
293*700637cbSDimitry Andric            is_nothrow_default_constructible<key_compare>::value &&
294*700637cbSDimitry Andric            is_nothrow_copy_constructible<key_compare>::value);
295*700637cbSDimitry Andric    explicit multiset(const value_compare& comp);
296*700637cbSDimitry Andric    multiset(const value_compare& comp, const allocator_type& a);
297*700637cbSDimitry Andric    template <class InputIterator>
298*700637cbSDimitry Andric        multiset(InputIterator first, InputIterator last,
299*700637cbSDimitry Andric                 const value_compare& comp = value_compare());
300*700637cbSDimitry Andric    template <class InputIterator>
301*700637cbSDimitry Andric        multiset(InputIterator first, InputIterator last,
302*700637cbSDimitry Andric                 const value_compare& comp, const allocator_type& a);
303*700637cbSDimitry Andric    template<container-compatible-range<value_type> R>
304*700637cbSDimitry Andric      multiset(from_range_t, R&& rg,
305*700637cbSDimitry Andric               const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23
306*700637cbSDimitry Andric    multiset(const multiset& s);
307*700637cbSDimitry Andric    multiset(multiset&& s)
308*700637cbSDimitry Andric        noexcept(
309*700637cbSDimitry Andric            is_nothrow_move_constructible<allocator_type>::value &&
310*700637cbSDimitry Andric            is_nothrow_move_constructible<key_compare>::value);
311*700637cbSDimitry Andric    explicit multiset(const allocator_type& a);
312*700637cbSDimitry Andric    multiset(const multiset& s, const allocator_type& a);
313*700637cbSDimitry Andric    multiset(multiset&& s, const allocator_type& a);
314*700637cbSDimitry Andric    multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
315*700637cbSDimitry Andric    multiset(initializer_list<value_type> il, const value_compare& comp,
316*700637cbSDimitry Andric             const allocator_type& a);
317*700637cbSDimitry Andric    template <class InputIterator>
318*700637cbSDimitry Andric        multiset(InputIterator first, InputIterator last, const allocator_type& a)
319*700637cbSDimitry Andric            : set(first, last, Compare(), a) {}  // C++14
320*700637cbSDimitry Andric    template<container-compatible-range<value_type> R>
321*700637cbSDimitry Andric      multiset(from_range_t, R&& rg, const Allocator& a))
322*700637cbSDimitry Andric        : multiset(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
323*700637cbSDimitry Andric    multiset(initializer_list<value_type> il, const allocator_type& a)
324*700637cbSDimitry Andric        : set(il, Compare(), a) {}  // C++14
325*700637cbSDimitry Andric    ~multiset();
326*700637cbSDimitry Andric
327*700637cbSDimitry Andric    multiset& operator=(const multiset& s);
328*700637cbSDimitry Andric    multiset& operator=(multiset&& s)
329*700637cbSDimitry Andric        noexcept(
330*700637cbSDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
331*700637cbSDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
332*700637cbSDimitry Andric            is_nothrow_move_assignable<key_compare>::value);
333*700637cbSDimitry Andric    multiset& operator=(initializer_list<value_type> il);
334*700637cbSDimitry Andric
335*700637cbSDimitry Andric    // iterators:
336*700637cbSDimitry Andric          iterator begin() noexcept;
337*700637cbSDimitry Andric    const_iterator begin() const noexcept;
338*700637cbSDimitry Andric          iterator end() noexcept;
339*700637cbSDimitry Andric    const_iterator end()   const noexcept;
340*700637cbSDimitry Andric
341*700637cbSDimitry Andric          reverse_iterator rbegin() noexcept;
342*700637cbSDimitry Andric    const_reverse_iterator rbegin() const noexcept;
343*700637cbSDimitry Andric          reverse_iterator rend() noexcept;
344*700637cbSDimitry Andric    const_reverse_iterator rend()   const noexcept;
345*700637cbSDimitry Andric
346*700637cbSDimitry Andric    const_iterator         cbegin()  const noexcept;
347*700637cbSDimitry Andric    const_iterator         cend()    const noexcept;
348*700637cbSDimitry Andric    const_reverse_iterator crbegin() const noexcept;
349*700637cbSDimitry Andric    const_reverse_iterator crend()   const noexcept;
350*700637cbSDimitry Andric
351*700637cbSDimitry Andric    // capacity:
352*700637cbSDimitry Andric    bool      empty()    const noexcept;
353*700637cbSDimitry Andric    size_type size()     const noexcept;
354*700637cbSDimitry Andric    size_type max_size() const noexcept;
355*700637cbSDimitry Andric
356*700637cbSDimitry Andric    // modifiers:
357*700637cbSDimitry Andric    template <class... Args>
358*700637cbSDimitry Andric        iterator emplace(Args&&... args);
359*700637cbSDimitry Andric    template <class... Args>
360*700637cbSDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
361*700637cbSDimitry Andric    iterator insert(const value_type& v);
362*700637cbSDimitry Andric    iterator insert(value_type&& v);
363*700637cbSDimitry Andric    iterator insert(const_iterator position, const value_type& v);
364*700637cbSDimitry Andric    iterator insert(const_iterator position, value_type&& v);
365*700637cbSDimitry Andric    template <class InputIterator>
366*700637cbSDimitry Andric        void insert(InputIterator first, InputIterator last);
367*700637cbSDimitry Andric    template<container-compatible-range<value_type> R>
368*700637cbSDimitry Andric      void insert_range(R&& rg);                                                      // C++23
369*700637cbSDimitry Andric    void insert(initializer_list<value_type> il);
370*700637cbSDimitry Andric
371*700637cbSDimitry Andric    node_type extract(const_iterator position);                                       // C++17
372*700637cbSDimitry Andric    node_type extract(const key_type& x);                                             // C++17
373*700637cbSDimitry Andric    iterator insert(node_type&& nh);                                                  // C++17
374*700637cbSDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);                             // C++17
375*700637cbSDimitry Andric
376*700637cbSDimitry Andric    iterator  erase(const_iterator position);
377*700637cbSDimitry Andric    iterator  erase(iterator position);  // C++14
378*700637cbSDimitry Andric    size_type erase(const key_type& k);
379*700637cbSDimitry Andric    iterator  erase(const_iterator first, const_iterator last);
380*700637cbSDimitry Andric    void clear() noexcept;
381*700637cbSDimitry Andric
382*700637cbSDimitry Andric    template<class C2>
383*700637cbSDimitry Andric      void merge(multiset<Key, C2, Allocator>& source);    // C++17
384*700637cbSDimitry Andric    template<class C2>
385*700637cbSDimitry Andric      void merge(multiset<Key, C2, Allocator>&& source);   // C++17
386*700637cbSDimitry Andric    template<class C2>
387*700637cbSDimitry Andric      void merge(set<Key, C2, Allocator>& source);         // C++17
388*700637cbSDimitry Andric    template<class C2>
389*700637cbSDimitry Andric      void merge(set<Key, C2, Allocator>&& source);        // C++17
390*700637cbSDimitry Andric
391*700637cbSDimitry Andric    void swap(multiset& s)
392*700637cbSDimitry Andric        noexcept(
393*700637cbSDimitry Andric            __is_nothrow_swappable<key_compare>::value &&
394*700637cbSDimitry Andric            (!allocator_type::propagate_on_container_swap::value ||
395*700637cbSDimitry Andric             __is_nothrow_swappable<allocator_type>::value));
396*700637cbSDimitry Andric
397*700637cbSDimitry Andric    // observers:
398*700637cbSDimitry Andric    allocator_type get_allocator() const noexcept;
399*700637cbSDimitry Andric    key_compare    key_comp()      const;
400*700637cbSDimitry Andric    value_compare  value_comp()    const;
401*700637cbSDimitry Andric
402*700637cbSDimitry Andric    // set operations:
403*700637cbSDimitry Andric          iterator find(const key_type& k);
404*700637cbSDimitry Andric    const_iterator find(const key_type& k) const;
405*700637cbSDimitry Andric    template<typename K>
406*700637cbSDimitry Andric        iterator find(const K& x);
407*700637cbSDimitry Andric    template<typename K>
408*700637cbSDimitry Andric        const_iterator find(const K& x) const;  // C++14
409*700637cbSDimitry Andric
410*700637cbSDimitry Andric    template<typename K>
411*700637cbSDimitry Andric        size_type count(const K& x) const;      // C++14
412*700637cbSDimitry Andric    size_type      count(const key_type& k) const;
413*700637cbSDimitry Andric
414*700637cbSDimitry Andric    bool           contains(const key_type& x) const;  // C++20
415*700637cbSDimitry Andric    template<class K> bool contains(const K& x) const; // C++20
416*700637cbSDimitry Andric
417*700637cbSDimitry Andric          iterator lower_bound(const key_type& k);
418*700637cbSDimitry Andric    const_iterator lower_bound(const key_type& k) const;
419*700637cbSDimitry Andric    template<typename K>
420*700637cbSDimitry Andric        iterator lower_bound(const K& x);              // C++14
421*700637cbSDimitry Andric    template<typename K>
422*700637cbSDimitry Andric        const_iterator lower_bound(const K& x) const;  // C++14
423*700637cbSDimitry Andric
424*700637cbSDimitry Andric          iterator upper_bound(const key_type& k);
425*700637cbSDimitry Andric    const_iterator upper_bound(const key_type& k) const;
426*700637cbSDimitry Andric    template<typename K>
427*700637cbSDimitry Andric        iterator upper_bound(const K& x);              // C++14
428*700637cbSDimitry Andric    template<typename K>
429*700637cbSDimitry Andric        const_iterator upper_bound(const K& x) const;  // C++14
430*700637cbSDimitry Andric
431*700637cbSDimitry Andric    pair<iterator,iterator>             equal_range(const key_type& k);
432*700637cbSDimitry Andric    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
433*700637cbSDimitry Andric    template<typename K>
434*700637cbSDimitry Andric        pair<iterator,iterator>             equal_range(const K& x);        // C++14
435*700637cbSDimitry Andric    template<typename K>
436*700637cbSDimitry Andric        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
437*700637cbSDimitry Andric};
438*700637cbSDimitry Andric
439*700637cbSDimitry Andrictemplate <class InputIterator,
440*700637cbSDimitry Andric      class Compare = less<typename iterator_traits<InputIterator>::value_type>,
441*700637cbSDimitry Andric      class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
442*700637cbSDimitry Andricmultiset(InputIterator, InputIterator,
443*700637cbSDimitry Andric    Compare = Compare(), Allocator = Allocator())
444*700637cbSDimitry Andric  -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17
445*700637cbSDimitry Andric
446*700637cbSDimitry Andrictemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
447*700637cbSDimitry Andric          class Allocator = allocator<ranges::range_value_t<R>>>
448*700637cbSDimitry Andric  multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
449*700637cbSDimitry Andric    -> multiset<ranges::range_value_t<R>, Compare, Allocator>;
450*700637cbSDimitry Andric
451*700637cbSDimitry Andrictemplate<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
452*700637cbSDimitry Andricmultiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
453*700637cbSDimitry Andric  -> multiset<Key, Compare, Allocator>; // C++17
454*700637cbSDimitry Andric
455*700637cbSDimitry Andrictemplate<class InputIterator, class Allocator>
456*700637cbSDimitry Andricmultiset(InputIterator, InputIterator, Allocator)
457*700637cbSDimitry Andric  -> multiset<typename iterator_traits<InputIterator>::value_type,
458*700637cbSDimitry Andric          less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
459*700637cbSDimitry Andric
460*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator>
461*700637cbSDimitry Andric  multiset(from_range_t, R&&, Allocator)
462*700637cbSDimitry Andric    -> multiset<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, Allocator>;
463*700637cbSDimitry Andric
464*700637cbSDimitry Andrictemplate<class Key, class Allocator>
465*700637cbSDimitry Andricmultiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>; // C++17
466*700637cbSDimitry Andric
467*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
468*700637cbSDimitry Andricbool
469*700637cbSDimitry Andricoperator==(const multiset<Key, Compare, Allocator>& x,
470*700637cbSDimitry Andric           const multiset<Key, Compare, Allocator>& y);
471*700637cbSDimitry Andric
472*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
473*700637cbSDimitry Andricbool
474*700637cbSDimitry Andricoperator< (const multiset<Key, Compare, Allocator>& x,
475*700637cbSDimitry Andric           const multiset<Key, Compare, Allocator>& y);                                // removed in C++20
476*700637cbSDimitry Andric
477*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
478*700637cbSDimitry Andricbool
479*700637cbSDimitry Andricoperator!=(const multiset<Key, Compare, Allocator>& x,
480*700637cbSDimitry Andric           const multiset<Key, Compare, Allocator>& y);                                // removed in C++20
481*700637cbSDimitry Andric
482*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
483*700637cbSDimitry Andricbool
484*700637cbSDimitry Andricoperator> (const multiset<Key, Compare, Allocator>& x,
485*700637cbSDimitry Andric           const multiset<Key, Compare, Allocator>& y);                                // removed in C++20
486*700637cbSDimitry Andric
487*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
488*700637cbSDimitry Andricbool
489*700637cbSDimitry Andricoperator>=(const multiset<Key, Compare, Allocator>& x,
490*700637cbSDimitry Andric           const multiset<Key, Compare, Allocator>& y);                                // removed in C++20
491*700637cbSDimitry Andric
492*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
493*700637cbSDimitry Andricbool
494*700637cbSDimitry Andricoperator<=(const multiset<Key, Compare, Allocator>& x,
495*700637cbSDimitry Andric           const multiset<Key, Compare, Allocator>& y);                                // removed in C++20
496*700637cbSDimitry Andric
497*700637cbSDimitry Andrictemplate<class Key, class Compare, class Allocator>
498*700637cbSDimitry Andric  synth-three-way-result<Key> operator<=>(const multiset<Key, Compare, Allocator>& x,
499*700637cbSDimitry Andric                                          const multiset<Key, Compare, Allocator>& y); // since C++20
500*700637cbSDimitry Andric
501*700637cbSDimitry Andric// specialized algorithms:
502*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator>
503*700637cbSDimitry Andricvoid
504*700637cbSDimitry Andricswap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
505*700637cbSDimitry Andric    noexcept(noexcept(x.swap(y)));
506*700637cbSDimitry Andric
507*700637cbSDimitry Andrictemplate <class Key, class Compare, class Allocator, class Predicate>
508*700637cbSDimitry Andrictypename multiset<Key, Compare, Allocator>::size_type
509*700637cbSDimitry Andricerase_if(multiset<Key, Compare, Allocator>& c, Predicate pred);  // C++20
510*700637cbSDimitry Andric
511*700637cbSDimitry Andric}  // std
512*700637cbSDimitry Andric
513*700637cbSDimitry Andric*/
514*700637cbSDimitry Andric
515*700637cbSDimitry Andric#include <__cxx03/__algorithm/equal.h>
516*700637cbSDimitry Andric#include <__cxx03/__algorithm/lexicographical_compare.h>
517*700637cbSDimitry Andric#include <__cxx03/__assert>
518*700637cbSDimitry Andric#include <__cxx03/__config>
519*700637cbSDimitry Andric#include <__cxx03/__functional/operations.h>
520*700637cbSDimitry Andric#include <__cxx03/__iterator/erase_if_container.h>
521*700637cbSDimitry Andric#include <__cxx03/__iterator/iterator_traits.h>
522*700637cbSDimitry Andric#include <__cxx03/__iterator/reverse_iterator.h>
523*700637cbSDimitry Andric#include <__cxx03/__memory/allocator.h>
524*700637cbSDimitry Andric#include <__cxx03/__tree>
525*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_allocator.h>
526*700637cbSDimitry Andric#include <__cxx03/__utility/forward.h>
527*700637cbSDimitry Andric#include <__cxx03/version>
528*700637cbSDimitry Andric
529*700637cbSDimitry Andric// standard-mandated includes
530*700637cbSDimitry Andric
531*700637cbSDimitry Andric// [iterator.range]
532*700637cbSDimitry Andric#include <__cxx03/__iterator/access.h>
533*700637cbSDimitry Andric
534*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
535*700637cbSDimitry Andric#  pragma GCC system_header
536*700637cbSDimitry Andric#endif
537*700637cbSDimitry Andric
538*700637cbSDimitry Andric_LIBCPP_PUSH_MACROS
539*700637cbSDimitry Andric#include <__cxx03/__undef_macros>
540*700637cbSDimitry Andric
541*700637cbSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
542*700637cbSDimitry Andric
543*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
544*700637cbSDimitry Andricclass multiset;
545*700637cbSDimitry Andric
546*700637cbSDimitry Andrictemplate <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >
547*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS set {
548*700637cbSDimitry Andricpublic:
549*700637cbSDimitry Andric  // types:
550*700637cbSDimitry Andric  typedef _Key key_type;
551*700637cbSDimitry Andric  typedef key_type value_type;
552*700637cbSDimitry Andric  typedef __type_identity_t<_Compare> key_compare;
553*700637cbSDimitry Andric  typedef key_compare value_compare;
554*700637cbSDimitry Andric  typedef __type_identity_t<_Allocator> allocator_type;
555*700637cbSDimitry Andric  typedef value_type& reference;
556*700637cbSDimitry Andric  typedef const value_type& const_reference;
557*700637cbSDimitry Andric
558*700637cbSDimitry Andric  static_assert(is_same<typename allocator_type::value_type, value_type>::value,
559*700637cbSDimitry Andric                "Allocator::value_type must be same type as value_type");
560*700637cbSDimitry Andric
561*700637cbSDimitry Andricprivate:
562*700637cbSDimitry Andric  typedef __tree<value_type, value_compare, allocator_type> __base;
563*700637cbSDimitry Andric  typedef allocator_traits<allocator_type> __alloc_traits;
564*700637cbSDimitry Andric
565*700637cbSDimitry Andric  static_assert(__check_valid_allocator<allocator_type>::value, "");
566*700637cbSDimitry Andric
567*700637cbSDimitry Andric  __base __tree_;
568*700637cbSDimitry Andric
569*700637cbSDimitry Andricpublic:
570*700637cbSDimitry Andric  typedef typename __base::pointer pointer;
571*700637cbSDimitry Andric  typedef typename __base::const_pointer const_pointer;
572*700637cbSDimitry Andric  typedef typename __base::size_type size_type;
573*700637cbSDimitry Andric  typedef typename __base::difference_type difference_type;
574*700637cbSDimitry Andric  typedef typename __base::const_iterator iterator;
575*700637cbSDimitry Andric  typedef typename __base::const_iterator const_iterator;
576*700637cbSDimitry Andric  typedef std::reverse_iterator<iterator> reverse_iterator;
577*700637cbSDimitry Andric  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
578*700637cbSDimitry Andric
579*700637cbSDimitry Andric  template <class _Key2, class _Compare2, class _Alloc2>
580*700637cbSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS set;
581*700637cbSDimitry Andric  template <class _Key2, class _Compare2, class _Alloc2>
582*700637cbSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS multiset;
583*700637cbSDimitry Andric
584*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI set() : __tree_(value_compare()) {}
585*700637cbSDimitry Andric
586*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit set(const value_compare& __comp) : __tree_(__comp) {}
587*700637cbSDimitry Andric
588*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit set(const value_compare& __comp, const allocator_type& __a) : __tree_(__comp, __a) {}
589*700637cbSDimitry Andric  template <class _InputIterator>
590*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())
591*700637cbSDimitry Andric      : __tree_(__comp) {
592*700637cbSDimitry Andric    insert(__f, __l);
593*700637cbSDimitry Andric  }
594*700637cbSDimitry Andric
595*700637cbSDimitry Andric  template <class _InputIterator>
596*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
597*700637cbSDimitry Andric  set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, const allocator_type& __a)
598*700637cbSDimitry Andric      : __tree_(__comp, __a) {
599*700637cbSDimitry Andric    insert(__f, __l);
600*700637cbSDimitry Andric  }
601*700637cbSDimitry Andric
602*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); }
603*700637cbSDimitry Andric
604*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) {
605*700637cbSDimitry Andric    __tree_ = __s.__tree_;
606*700637cbSDimitry Andric    return *this;
607*700637cbSDimitry Andric  }
608*700637cbSDimitry Andric
609*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {}
610*700637cbSDimitry Andric
611*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI set(const set& __s, const allocator_type& __a) : __tree_(__s.__tree_.value_comp(), __a) {
612*700637cbSDimitry Andric    insert(__s.begin(), __s.end());
613*700637cbSDimitry Andric  }
614*700637cbSDimitry Andric
615*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }
616*700637cbSDimitry Andric
617*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
618*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
619*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }
620*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }
621*700637cbSDimitry Andric
622*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }
623*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }
624*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }
625*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); }
626*700637cbSDimitry Andric
627*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }
628*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }
629*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
630*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
631*700637cbSDimitry Andric
632*700637cbSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
633*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
634*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
635*700637cbSDimitry Andric
636*700637cbSDimitry Andric  // modifiers:
637*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); }
638*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
639*700637cbSDimitry Andric    return __tree_.__insert_unique(__p, __v);
640*700637cbSDimitry Andric  }
641*700637cbSDimitry Andric
642*700637cbSDimitry Andric  template <class _InputIterator>
643*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {
644*700637cbSDimitry Andric    for (const_iterator __e = cend(); __f != __l; ++__f)
645*700637cbSDimitry Andric      __tree_.__insert_unique(__e, *__f);
646*700637cbSDimitry Andric  }
647*700637cbSDimitry Andric
648*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }
649*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); }
650*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }
651*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
652*700637cbSDimitry Andric
653*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(set& __s) { __tree_.swap(__s.__tree_); }
654*700637cbSDimitry Andric
655*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); }
656*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); }
657*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); }
658*700637cbSDimitry Andric
659*700637cbSDimitry Andric  // set operations:
660*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
661*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
662*700637cbSDimitry Andric
663*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }
664*700637cbSDimitry Andric
665*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
666*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
667*700637cbSDimitry Andric
668*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
669*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
670*700637cbSDimitry Andric
671*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
672*700637cbSDimitry Andric    return __tree_.__equal_range_unique(__k);
673*700637cbSDimitry Andric  }
674*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
675*700637cbSDimitry Andric    return __tree_.__equal_range_unique(__k);
676*700637cbSDimitry Andric  }
677*700637cbSDimitry Andric};
678*700637cbSDimitry Andric
679*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
680*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
681*700637cbSDimitry Andricoperator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
682*700637cbSDimitry Andric  return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
683*700637cbSDimitry Andric}
684*700637cbSDimitry Andric
685*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
686*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
687*700637cbSDimitry Andricoperator<(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
688*700637cbSDimitry Andric  return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
689*700637cbSDimitry Andric}
690*700637cbSDimitry Andric
691*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
692*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
693*700637cbSDimitry Andricoperator!=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
694*700637cbSDimitry Andric  return !(__x == __y);
695*700637cbSDimitry Andric}
696*700637cbSDimitry Andric
697*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
698*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
699*700637cbSDimitry Andricoperator>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
700*700637cbSDimitry Andric  return __y < __x;
701*700637cbSDimitry Andric}
702*700637cbSDimitry Andric
703*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
704*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
705*700637cbSDimitry Andricoperator>=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
706*700637cbSDimitry Andric  return !(__x < __y);
707*700637cbSDimitry Andric}
708*700637cbSDimitry Andric
709*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
710*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
711*700637cbSDimitry Andricoperator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
712*700637cbSDimitry Andric  return !(__y < __x);
713*700637cbSDimitry Andric}
714*700637cbSDimitry Andric
715*700637cbSDimitry Andric// specialized algorithms:
716*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
717*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y) {
718*700637cbSDimitry Andric  __x.swap(__y);
719*700637cbSDimitry Andric}
720*700637cbSDimitry Andric
721*700637cbSDimitry Andrictemplate <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >
722*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS multiset {
723*700637cbSDimitry Andricpublic:
724*700637cbSDimitry Andric  // types:
725*700637cbSDimitry Andric  typedef _Key key_type;
726*700637cbSDimitry Andric  typedef key_type value_type;
727*700637cbSDimitry Andric  typedef __type_identity_t<_Compare> key_compare;
728*700637cbSDimitry Andric  typedef key_compare value_compare;
729*700637cbSDimitry Andric  typedef __type_identity_t<_Allocator> allocator_type;
730*700637cbSDimitry Andric  typedef value_type& reference;
731*700637cbSDimitry Andric  typedef const value_type& const_reference;
732*700637cbSDimitry Andric
733*700637cbSDimitry Andric  static_assert(is_same<typename allocator_type::value_type, value_type>::value,
734*700637cbSDimitry Andric                "Allocator::value_type must be same type as value_type");
735*700637cbSDimitry Andric
736*700637cbSDimitry Andricprivate:
737*700637cbSDimitry Andric  typedef __tree<value_type, value_compare, allocator_type> __base;
738*700637cbSDimitry Andric  typedef allocator_traits<allocator_type> __alloc_traits;
739*700637cbSDimitry Andric
740*700637cbSDimitry Andric  static_assert(__check_valid_allocator<allocator_type>::value, "");
741*700637cbSDimitry Andric
742*700637cbSDimitry Andric  __base __tree_;
743*700637cbSDimitry Andric
744*700637cbSDimitry Andricpublic:
745*700637cbSDimitry Andric  typedef typename __base::pointer pointer;
746*700637cbSDimitry Andric  typedef typename __base::const_pointer const_pointer;
747*700637cbSDimitry Andric  typedef typename __base::size_type size_type;
748*700637cbSDimitry Andric  typedef typename __base::difference_type difference_type;
749*700637cbSDimitry Andric  typedef typename __base::const_iterator iterator;
750*700637cbSDimitry Andric  typedef typename __base::const_iterator const_iterator;
751*700637cbSDimitry Andric  typedef std::reverse_iterator<iterator> reverse_iterator;
752*700637cbSDimitry Andric  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
753*700637cbSDimitry Andric
754*700637cbSDimitry Andric  template <class _Key2, class _Compare2, class _Alloc2>
755*700637cbSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS set;
756*700637cbSDimitry Andric  template <class _Key2, class _Compare2, class _Alloc2>
757*700637cbSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS multiset;
758*700637cbSDimitry Andric
759*700637cbSDimitry Andric  // construct/copy/destroy:
760*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI multiset() : __tree_(value_compare()) {}
761*700637cbSDimitry Andric
762*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit multiset(const value_compare& __comp) : __tree_(__comp) {}
763*700637cbSDimitry Andric
764*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit multiset(const value_compare& __comp, const allocator_type& __a)
765*700637cbSDimitry Andric      : __tree_(__comp, __a) {}
766*700637cbSDimitry Andric  template <class _InputIterator>
767*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI multiset(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())
768*700637cbSDimitry Andric      : __tree_(__comp) {
769*700637cbSDimitry Andric    insert(__f, __l);
770*700637cbSDimitry Andric  }
771*700637cbSDimitry Andric
772*700637cbSDimitry Andric  template <class _InputIterator>
773*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
774*700637cbSDimitry Andric  multiset(_InputIterator __f, _InputIterator __l, const value_compare& __comp, const allocator_type& __a)
775*700637cbSDimitry Andric      : __tree_(__comp, __a) {
776*700637cbSDimitry Andric    insert(__f, __l);
777*700637cbSDimitry Andric  }
778*700637cbSDimitry Andric
779*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s)
780*700637cbSDimitry Andric      : __tree_(__s.__tree_.value_comp(),
781*700637cbSDimitry Andric                __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) {
782*700637cbSDimitry Andric    insert(__s.begin(), __s.end());
783*700637cbSDimitry Andric  }
784*700637cbSDimitry Andric
785*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI multiset& operator=(const multiset& __s) {
786*700637cbSDimitry Andric    __tree_ = __s.__tree_;
787*700637cbSDimitry Andric    return *this;
788*700637cbSDimitry Andric  }
789*700637cbSDimitry Andric
790*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit multiset(const allocator_type& __a) : __tree_(__a) {}
791*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s, const allocator_type& __a)
792*700637cbSDimitry Andric      : __tree_(__s.__tree_.value_comp(), __a) {
793*700637cbSDimitry Andric    insert(__s.begin(), __s.end());
794*700637cbSDimitry Andric  }
795*700637cbSDimitry Andric
796*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ~multiset() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }
797*700637cbSDimitry Andric
798*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
799*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
800*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }
801*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }
802*700637cbSDimitry Andric
803*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }
804*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }
805*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }
806*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); }
807*700637cbSDimitry Andric
808*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }
809*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }
810*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
811*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
812*700637cbSDimitry Andric
813*700637cbSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
814*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
815*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
816*700637cbSDimitry Andric
817*700637cbSDimitry Andric  // modifiers:
818*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); }
819*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
820*700637cbSDimitry Andric    return __tree_.__insert_multi(__p, __v);
821*700637cbSDimitry Andric  }
822*700637cbSDimitry Andric
823*700637cbSDimitry Andric  template <class _InputIterator>
824*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {
825*700637cbSDimitry Andric    for (const_iterator __e = cend(); __f != __l; ++__f)
826*700637cbSDimitry Andric      __tree_.__insert_multi(__e, *__f);
827*700637cbSDimitry Andric  }
828*700637cbSDimitry Andric
829*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }
830*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); }
831*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }
832*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
833*700637cbSDimitry Andric
834*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) { __tree_.swap(__s.__tree_); }
835*700637cbSDimitry Andric
836*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); }
837*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); }
838*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); }
839*700637cbSDimitry Andric
840*700637cbSDimitry Andric  // set operations:
841*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
842*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
843*700637cbSDimitry Andric
844*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }
845*700637cbSDimitry Andric
846*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
847*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
848*700637cbSDimitry Andric
849*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
850*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
851*700637cbSDimitry Andric
852*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
853*700637cbSDimitry Andric    return __tree_.__equal_range_multi(__k);
854*700637cbSDimitry Andric  }
855*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
856*700637cbSDimitry Andric    return __tree_.__equal_range_multi(__k);
857*700637cbSDimitry Andric  }
858*700637cbSDimitry Andric};
859*700637cbSDimitry Andric
860*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
861*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
862*700637cbSDimitry Andricoperator==(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
863*700637cbSDimitry Andric  return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
864*700637cbSDimitry Andric}
865*700637cbSDimitry Andric
866*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
867*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
868*700637cbSDimitry Andricoperator<(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
869*700637cbSDimitry Andric  return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
870*700637cbSDimitry Andric}
871*700637cbSDimitry Andric
872*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
873*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
874*700637cbSDimitry Andricoperator!=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
875*700637cbSDimitry Andric  return !(__x == __y);
876*700637cbSDimitry Andric}
877*700637cbSDimitry Andric
878*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
879*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
880*700637cbSDimitry Andricoperator>(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
881*700637cbSDimitry Andric  return __y < __x;
882*700637cbSDimitry Andric}
883*700637cbSDimitry Andric
884*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
885*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
886*700637cbSDimitry Andricoperator>=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
887*700637cbSDimitry Andric  return !(__x < __y);
888*700637cbSDimitry Andric}
889*700637cbSDimitry Andric
890*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
891*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool
892*700637cbSDimitry Andricoperator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
893*700637cbSDimitry Andric  return !(__y < __x);
894*700637cbSDimitry Andric}
895*700637cbSDimitry Andric
896*700637cbSDimitry Andrictemplate <class _Key, class _Compare, class _Allocator>
897*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
898*700637cbSDimitry Andricswap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Allocator>& __y) {
899*700637cbSDimitry Andric  __x.swap(__y);
900*700637cbSDimitry Andric}
901*700637cbSDimitry Andric
902*700637cbSDimitry Andric_LIBCPP_END_NAMESPACE_STD
903*700637cbSDimitry Andric
904*700637cbSDimitry Andric_LIBCPP_POP_MACROS
905*700637cbSDimitry Andric
906*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
907*700637cbSDimitry Andric#  include <__cxx03/cstdlib>
908*700637cbSDimitry Andric#  include <__cxx03/functional>
909*700637cbSDimitry Andric#  include <__cxx03/iterator>
910*700637cbSDimitry Andric#  include <__cxx03/stdexcept>
911*700637cbSDimitry Andric#  include <__cxx03/type_traits>
912*700637cbSDimitry Andric#endif
913*700637cbSDimitry Andric
914*700637cbSDimitry Andric#endif // _LIBCPP___CXX03_SET
915