xref: /openbsd-src/gnu/llvm/libcxx/include/set (revision 4bdff4bed0e3d54e55670334c7d0077db4170f86)
146035553Spatrick// -*- C++ -*-
2*4bdff4beSrobert//===----------------------------------------------------------------------===//
346035553Spatrick//
446035553Spatrick// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
546035553Spatrick// See https://llvm.org/LICENSE.txt for license information.
646035553Spatrick// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
746035553Spatrick//
846035553Spatrick//===----------------------------------------------------------------------===//
946035553Spatrick
1046035553Spatrick#ifndef _LIBCPP_SET
1146035553Spatrick#define _LIBCPP_SET
1246035553Spatrick
1346035553Spatrick/*
1446035553Spatrick
1546035553Spatrick    set synopsis
1646035553Spatrick
1746035553Spatricknamespace std
1846035553Spatrick{
1946035553Spatrick
2046035553Spatricktemplate <class Key, class Compare = less<Key>,
2146035553Spatrick          class Allocator = allocator<Key>>
2246035553Spatrickclass set
2346035553Spatrick{
2446035553Spatrickpublic:
2546035553Spatrick    // types:
2646035553Spatrick    typedef Key                                      key_type;
2746035553Spatrick    typedef key_type                                 value_type;
2846035553Spatrick    typedef Compare                                  key_compare;
2946035553Spatrick    typedef key_compare                              value_compare;
3046035553Spatrick    typedef Allocator                                allocator_type;
3146035553Spatrick    typedef typename allocator_type::reference       reference;
3246035553Spatrick    typedef typename allocator_type::const_reference const_reference;
3346035553Spatrick    typedef typename allocator_type::size_type       size_type;
3446035553Spatrick    typedef typename allocator_type::difference_type difference_type;
3546035553Spatrick    typedef typename allocator_type::pointer         pointer;
3646035553Spatrick    typedef typename allocator_type::const_pointer   const_pointer;
3746035553Spatrick
3846035553Spatrick    typedef implementation-defined                   iterator;
3946035553Spatrick    typedef implementation-defined                   const_iterator;
4046035553Spatrick    typedef std::reverse_iterator<iterator>          reverse_iterator;
4146035553Spatrick    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
4246035553Spatrick    typedef unspecified                              node_type;               // C++17
4346035553Spatrick    typedef INSERT_RETURN_TYPE<iterator, node_type>  insert_return_type;      // C++17
4446035553Spatrick
4546035553Spatrick    // construct/copy/destroy:
4646035553Spatrick    set()
4746035553Spatrick        noexcept(
4846035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
4946035553Spatrick            is_nothrow_default_constructible<key_compare>::value &&
5046035553Spatrick            is_nothrow_copy_constructible<key_compare>::value);
5146035553Spatrick    explicit set(const value_compare& comp);
5246035553Spatrick    set(const value_compare& comp, const allocator_type& a);
5346035553Spatrick    template <class InputIterator>
5446035553Spatrick        set(InputIterator first, InputIterator last,
5546035553Spatrick            const value_compare& comp = value_compare());
5646035553Spatrick    template <class InputIterator>
5746035553Spatrick        set(InputIterator first, InputIterator last, const value_compare& comp,
5846035553Spatrick            const allocator_type& a);
5946035553Spatrick    set(const set& s);
6046035553Spatrick    set(set&& s)
6146035553Spatrick        noexcept(
6246035553Spatrick            is_nothrow_move_constructible<allocator_type>::value &&
6346035553Spatrick            is_nothrow_move_constructible<key_compare>::value);
6446035553Spatrick    explicit set(const allocator_type& a);
6546035553Spatrick    set(const set& s, const allocator_type& a);
6646035553Spatrick    set(set&& s, const allocator_type& a);
6746035553Spatrick    set(initializer_list<value_type> il, const value_compare& comp = value_compare());
6846035553Spatrick    set(initializer_list<value_type> il, const value_compare& comp,
6946035553Spatrick        const allocator_type& a);
7046035553Spatrick    template <class InputIterator>
7146035553Spatrick        set(InputIterator first, InputIterator last, const allocator_type& a)
7246035553Spatrick            : set(first, last, Compare(), a) {}  // C++14
7346035553Spatrick    set(initializer_list<value_type> il, const allocator_type& a)
7446035553Spatrick        : set(il, Compare(), a) {}  // C++14
7546035553Spatrick    ~set();
7646035553Spatrick
7746035553Spatrick    set& operator=(const set& s);
7846035553Spatrick    set& operator=(set&& s)
7946035553Spatrick        noexcept(
8046035553Spatrick            allocator_type::propagate_on_container_move_assignment::value &&
8146035553Spatrick            is_nothrow_move_assignable<allocator_type>::value &&
8246035553Spatrick            is_nothrow_move_assignable<key_compare>::value);
8346035553Spatrick    set& operator=(initializer_list<value_type> il);
8446035553Spatrick
8546035553Spatrick    // iterators:
8646035553Spatrick          iterator begin() noexcept;
8746035553Spatrick    const_iterator begin() const noexcept;
8846035553Spatrick          iterator end() noexcept;
8946035553Spatrick    const_iterator end()   const noexcept;
9046035553Spatrick
9146035553Spatrick          reverse_iterator rbegin() noexcept;
9246035553Spatrick    const_reverse_iterator rbegin() const noexcept;
9346035553Spatrick          reverse_iterator rend() noexcept;
9446035553Spatrick    const_reverse_iterator rend()   const noexcept;
9546035553Spatrick
9646035553Spatrick    const_iterator         cbegin()  const noexcept;
9746035553Spatrick    const_iterator         cend()    const noexcept;
9846035553Spatrick    const_reverse_iterator crbegin() const noexcept;
9946035553Spatrick    const_reverse_iterator crend()   const noexcept;
10046035553Spatrick
10146035553Spatrick    // capacity:
10246035553Spatrick    bool      empty()    const noexcept;
10346035553Spatrick    size_type size()     const noexcept;
10446035553Spatrick    size_type max_size() const noexcept;
10546035553Spatrick
10646035553Spatrick    // modifiers:
10746035553Spatrick    template <class... Args>
10846035553Spatrick        pair<iterator, bool> emplace(Args&&... args);
10946035553Spatrick    template <class... Args>
11046035553Spatrick        iterator emplace_hint(const_iterator position, Args&&... args);
11146035553Spatrick    pair<iterator,bool> insert(const value_type& v);
11246035553Spatrick    pair<iterator,bool> insert(value_type&& v);
11346035553Spatrick    iterator insert(const_iterator position, const value_type& v);
11446035553Spatrick    iterator insert(const_iterator position, value_type&& v);
11546035553Spatrick    template <class InputIterator>
11646035553Spatrick        void insert(InputIterator first, InputIterator last);
11746035553Spatrick    void insert(initializer_list<value_type> il);
11846035553Spatrick
11946035553Spatrick    node_type extract(const_iterator position);                                       // C++17
12046035553Spatrick    node_type extract(const key_type& x);                                             // C++17
12146035553Spatrick    insert_return_type insert(node_type&& nh);                                        // C++17
12246035553Spatrick    iterator insert(const_iterator hint, node_type&& nh);                             // C++17
12346035553Spatrick
12446035553Spatrick    iterator  erase(const_iterator position);
12546035553Spatrick    iterator  erase(iterator position);  // C++14
12646035553Spatrick    size_type erase(const key_type& k);
12746035553Spatrick    iterator  erase(const_iterator first, const_iterator last);
12846035553Spatrick    void clear() noexcept;
12946035553Spatrick
13046035553Spatrick    template<class C2>
13146035553Spatrick      void merge(set<Key, C2, Allocator>& source);         // C++17
13246035553Spatrick    template<class C2>
13346035553Spatrick      void merge(set<Key, C2, Allocator>&& source);        // C++17
13446035553Spatrick    template<class C2>
13546035553Spatrick      void merge(multiset<Key, C2, Allocator>& source);    // C++17
13646035553Spatrick    template<class C2>
13746035553Spatrick      void merge(multiset<Key, C2, Allocator>&& source);   // C++17
13846035553Spatrick
13946035553Spatrick    void swap(set& s)
14046035553Spatrick        noexcept(
14146035553Spatrick            __is_nothrow_swappable<key_compare>::value &&
14246035553Spatrick            (!allocator_type::propagate_on_container_swap::value ||
14346035553Spatrick             __is_nothrow_swappable<allocator_type>::value));
14446035553Spatrick
14546035553Spatrick    // observers:
14646035553Spatrick    allocator_type get_allocator() const noexcept;
14746035553Spatrick    key_compare    key_comp()      const;
14846035553Spatrick    value_compare  value_comp()    const;
14946035553Spatrick
15046035553Spatrick    // set operations:
15146035553Spatrick          iterator find(const key_type& k);
15246035553Spatrick    const_iterator find(const key_type& k) const;
15346035553Spatrick    template<typename K>
15446035553Spatrick        iterator find(const K& x);
15546035553Spatrick    template<typename K>
15646035553Spatrick        const_iterator find(const K& x) const;  // C++14
15776d0caaeSpatrick
15846035553Spatrick    template<typename K>
15946035553Spatrick        size_type count(const K& x) const;        // C++14
16046035553Spatrick    size_type      count(const key_type& k) const;
16176d0caaeSpatrick
16246035553Spatrick    bool           contains(const key_type& x) const;  // C++20
16376d0caaeSpatrick    template<class K> bool contains(const K& x) const; // C++20
16476d0caaeSpatrick
16546035553Spatrick          iterator lower_bound(const key_type& k);
16646035553Spatrick    const_iterator lower_bound(const key_type& k) const;
16746035553Spatrick    template<typename K>
16846035553Spatrick        iterator lower_bound(const K& x);              // C++14
16946035553Spatrick    template<typename K>
17046035553Spatrick        const_iterator lower_bound(const K& x) const;  // C++14
17146035553Spatrick
17246035553Spatrick          iterator upper_bound(const key_type& k);
17346035553Spatrick    const_iterator upper_bound(const key_type& k) const;
17446035553Spatrick    template<typename K>
17546035553Spatrick        iterator upper_bound(const K& x);              // C++14
17646035553Spatrick    template<typename K>
17746035553Spatrick        const_iterator upper_bound(const K& x) const;  // C++14
17846035553Spatrick    pair<iterator,iterator>             equal_range(const key_type& k);
17946035553Spatrick    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
18046035553Spatrick    template<typename K>
18146035553Spatrick        pair<iterator,iterator>             equal_range(const K& x);        // C++14
18246035553Spatrick    template<typename K>
18346035553Spatrick        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
18446035553Spatrick};
18546035553Spatrick
186*4bdff4beSroberttemplate <class InputIterator,
187*4bdff4beSrobert      class Compare = less<typename iterator_traits<InputIterator>::value_type>,
188*4bdff4beSrobert      class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
189*4bdff4beSrobertset(InputIterator, InputIterator,
190*4bdff4beSrobert    Compare = Compare(), Allocator = Allocator())
191*4bdff4beSrobert  -> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17
192*4bdff4beSrobert
193*4bdff4beSroberttemplate<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
194*4bdff4beSrobertset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
195*4bdff4beSrobert  -> set<Key, Compare, Allocator>; // C++17
196*4bdff4beSrobert
197*4bdff4beSroberttemplate<class InputIterator, class Allocator>
198*4bdff4beSrobertset(InputIterator, InputIterator, Allocator)
199*4bdff4beSrobert  -> set<typename iterator_traits<InputIterator>::value_type,
200*4bdff4beSrobert          less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
201*4bdff4beSrobert
202*4bdff4beSroberttemplate<class Key, class Allocator>
203*4bdff4beSrobertset(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>; // C++17
204*4bdff4beSrobert
20546035553Spatricktemplate <class Key, class Compare, class Allocator>
20646035553Spatrickbool
20746035553Spatrickoperator==(const set<Key, Compare, Allocator>& x,
20846035553Spatrick           const set<Key, Compare, Allocator>& y);
20946035553Spatrick
21046035553Spatricktemplate <class Key, class Compare, class Allocator>
21146035553Spatrickbool
21246035553Spatrickoperator< (const set<Key, Compare, Allocator>& x,
21346035553Spatrick           const set<Key, Compare, Allocator>& y);
21446035553Spatrick
21546035553Spatricktemplate <class Key, class Compare, class Allocator>
21646035553Spatrickbool
21746035553Spatrickoperator!=(const set<Key, Compare, Allocator>& x,
21846035553Spatrick           const set<Key, Compare, Allocator>& y);
21946035553Spatrick
22046035553Spatricktemplate <class Key, class Compare, class Allocator>
22146035553Spatrickbool
22246035553Spatrickoperator> (const set<Key, Compare, Allocator>& x,
22346035553Spatrick           const set<Key, Compare, Allocator>& y);
22446035553Spatrick
22546035553Spatricktemplate <class Key, class Compare, class Allocator>
22646035553Spatrickbool
22746035553Spatrickoperator>=(const set<Key, Compare, Allocator>& x,
22846035553Spatrick           const set<Key, Compare, Allocator>& y);
22946035553Spatrick
23046035553Spatricktemplate <class Key, class Compare, class Allocator>
23146035553Spatrickbool
23246035553Spatrickoperator<=(const set<Key, Compare, Allocator>& x,
23346035553Spatrick           const set<Key, Compare, Allocator>& y);
23446035553Spatrick
23546035553Spatrick// specialized algorithms:
23646035553Spatricktemplate <class Key, class Compare, class Allocator>
23746035553Spatrickvoid
23846035553Spatrickswap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
23946035553Spatrick    noexcept(noexcept(x.swap(y)));
24046035553Spatrick
24146035553Spatricktemplate <class Key, class Compare, class Allocator, class Predicate>
242037e7968Spatricktypename set<Key, Compare, Allocator>::size_type
243037e7968Spatrickerase_if(set<Key, Compare, Allocator>& c, Predicate pred);  // C++20
24446035553Spatrick
24546035553Spatricktemplate <class Key, class Compare = less<Key>,
24646035553Spatrick          class Allocator = allocator<Key>>
24746035553Spatrickclass multiset
24846035553Spatrick{
24946035553Spatrickpublic:
25046035553Spatrick    // types:
25146035553Spatrick    typedef Key                                      key_type;
25246035553Spatrick    typedef key_type                                 value_type;
25346035553Spatrick    typedef Compare                                  key_compare;
25446035553Spatrick    typedef key_compare                              value_compare;
25546035553Spatrick    typedef Allocator                                allocator_type;
25646035553Spatrick    typedef typename allocator_type::reference       reference;
25746035553Spatrick    typedef typename allocator_type::const_reference const_reference;
25846035553Spatrick    typedef typename allocator_type::size_type       size_type;
25946035553Spatrick    typedef typename allocator_type::difference_type difference_type;
26046035553Spatrick    typedef typename allocator_type::pointer         pointer;
26146035553Spatrick    typedef typename allocator_type::const_pointer   const_pointer;
26246035553Spatrick
26346035553Spatrick    typedef implementation-defined                   iterator;
26446035553Spatrick    typedef implementation-defined                   const_iterator;
26546035553Spatrick    typedef std::reverse_iterator<iterator>          reverse_iterator;
26646035553Spatrick    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
26746035553Spatrick    typedef unspecified                              node_type;               // C++17
26846035553Spatrick
26946035553Spatrick    // construct/copy/destroy:
27046035553Spatrick    multiset()
27146035553Spatrick        noexcept(
27246035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
27346035553Spatrick            is_nothrow_default_constructible<key_compare>::value &&
27446035553Spatrick            is_nothrow_copy_constructible<key_compare>::value);
27546035553Spatrick    explicit multiset(const value_compare& comp);
27646035553Spatrick    multiset(const value_compare& comp, const allocator_type& a);
27746035553Spatrick    template <class InputIterator>
27846035553Spatrick        multiset(InputIterator first, InputIterator last,
27946035553Spatrick                 const value_compare& comp = value_compare());
28046035553Spatrick    template <class InputIterator>
28146035553Spatrick        multiset(InputIterator first, InputIterator last,
28246035553Spatrick                 const value_compare& comp, const allocator_type& a);
28346035553Spatrick    multiset(const multiset& s);
28446035553Spatrick    multiset(multiset&& s)
28546035553Spatrick        noexcept(
28646035553Spatrick            is_nothrow_move_constructible<allocator_type>::value &&
28746035553Spatrick            is_nothrow_move_constructible<key_compare>::value);
28846035553Spatrick    explicit multiset(const allocator_type& a);
28946035553Spatrick    multiset(const multiset& s, const allocator_type& a);
29046035553Spatrick    multiset(multiset&& s, const allocator_type& a);
29146035553Spatrick    multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
29246035553Spatrick    multiset(initializer_list<value_type> il, const value_compare& comp,
29346035553Spatrick             const allocator_type& a);
29446035553Spatrick    template <class InputIterator>
29546035553Spatrick        multiset(InputIterator first, InputIterator last, const allocator_type& a)
29646035553Spatrick            : set(first, last, Compare(), a) {}  // C++14
29746035553Spatrick    multiset(initializer_list<value_type> il, const allocator_type& a)
29846035553Spatrick        : set(il, Compare(), a) {}  // C++14
29946035553Spatrick    ~multiset();
30046035553Spatrick
30146035553Spatrick    multiset& operator=(const multiset& s);
30246035553Spatrick    multiset& operator=(multiset&& s)
30346035553Spatrick        noexcept(
30446035553Spatrick            allocator_type::propagate_on_container_move_assignment::value &&
30546035553Spatrick            is_nothrow_move_assignable<allocator_type>::value &&
30646035553Spatrick            is_nothrow_move_assignable<key_compare>::value);
30746035553Spatrick    multiset& operator=(initializer_list<value_type> il);
30846035553Spatrick
30946035553Spatrick    // iterators:
31046035553Spatrick          iterator begin() noexcept;
31146035553Spatrick    const_iterator begin() const noexcept;
31246035553Spatrick          iterator end() noexcept;
31346035553Spatrick    const_iterator end()   const noexcept;
31446035553Spatrick
31546035553Spatrick          reverse_iterator rbegin() noexcept;
31646035553Spatrick    const_reverse_iterator rbegin() const noexcept;
31746035553Spatrick          reverse_iterator rend() noexcept;
31846035553Spatrick    const_reverse_iterator rend()   const noexcept;
31946035553Spatrick
32046035553Spatrick    const_iterator         cbegin()  const noexcept;
32146035553Spatrick    const_iterator         cend()    const noexcept;
32246035553Spatrick    const_reverse_iterator crbegin() const noexcept;
32346035553Spatrick    const_reverse_iterator crend()   const noexcept;
32446035553Spatrick
32546035553Spatrick    // capacity:
32646035553Spatrick    bool      empty()    const noexcept;
32746035553Spatrick    size_type size()     const noexcept;
32846035553Spatrick    size_type max_size() const noexcept;
32946035553Spatrick
33046035553Spatrick    // modifiers:
33146035553Spatrick    template <class... Args>
33246035553Spatrick        iterator emplace(Args&&... args);
33346035553Spatrick    template <class... Args>
33446035553Spatrick        iterator emplace_hint(const_iterator position, Args&&... args);
33546035553Spatrick    iterator insert(const value_type& v);
33646035553Spatrick    iterator insert(value_type&& v);
33746035553Spatrick    iterator insert(const_iterator position, const value_type& v);
33846035553Spatrick    iterator insert(const_iterator position, value_type&& v);
33946035553Spatrick    template <class InputIterator>
34046035553Spatrick        void insert(InputIterator first, InputIterator last);
34146035553Spatrick    void insert(initializer_list<value_type> il);
34246035553Spatrick
34346035553Spatrick    node_type extract(const_iterator position);                                       // C++17
34446035553Spatrick    node_type extract(const key_type& x);                                             // C++17
34546035553Spatrick    iterator insert(node_type&& nh);                                                  // C++17
34646035553Spatrick    iterator insert(const_iterator hint, node_type&& nh);                             // C++17
34746035553Spatrick
34846035553Spatrick    iterator  erase(const_iterator position);
34946035553Spatrick    iterator  erase(iterator position);  // C++14
35046035553Spatrick    size_type erase(const key_type& k);
35146035553Spatrick    iterator  erase(const_iterator first, const_iterator last);
35246035553Spatrick    void clear() noexcept;
35346035553Spatrick
35446035553Spatrick    template<class C2>
35546035553Spatrick      void merge(multiset<Key, C2, Allocator>& source);    // C++17
35646035553Spatrick    template<class C2>
35746035553Spatrick      void merge(multiset<Key, C2, Allocator>&& source);   // C++17
35846035553Spatrick    template<class C2>
35946035553Spatrick      void merge(set<Key, C2, Allocator>& source);         // C++17
36046035553Spatrick    template<class C2>
36146035553Spatrick      void merge(set<Key, C2, Allocator>&& source);        // C++17
36246035553Spatrick
36346035553Spatrick    void swap(multiset& s)
36446035553Spatrick        noexcept(
36546035553Spatrick            __is_nothrow_swappable<key_compare>::value &&
36646035553Spatrick            (!allocator_type::propagate_on_container_swap::value ||
36746035553Spatrick             __is_nothrow_swappable<allocator_type>::value));
36846035553Spatrick
36946035553Spatrick    // observers:
37046035553Spatrick    allocator_type get_allocator() const noexcept;
37146035553Spatrick    key_compare    key_comp()      const;
37246035553Spatrick    value_compare  value_comp()    const;
37346035553Spatrick
37446035553Spatrick    // set operations:
37546035553Spatrick          iterator find(const key_type& k);
37646035553Spatrick    const_iterator find(const key_type& k) const;
37746035553Spatrick    template<typename K>
37846035553Spatrick        iterator find(const K& x);
37946035553Spatrick    template<typename K>
38046035553Spatrick        const_iterator find(const K& x) const;  // C++14
38176d0caaeSpatrick
38246035553Spatrick    template<typename K>
38346035553Spatrick        size_type count(const K& x) const;      // C++14
38446035553Spatrick    size_type      count(const key_type& k) const;
38576d0caaeSpatrick
38646035553Spatrick    bool           contains(const key_type& x) const;  // C++20
38776d0caaeSpatrick    template<class K> bool contains(const K& x) const; // C++20
38876d0caaeSpatrick
38946035553Spatrick          iterator lower_bound(const key_type& k);
39046035553Spatrick    const_iterator lower_bound(const key_type& k) const;
39146035553Spatrick    template<typename K>
39246035553Spatrick        iterator lower_bound(const K& x);              // C++14
39346035553Spatrick    template<typename K>
39446035553Spatrick        const_iterator lower_bound(const K& x) const;  // C++14
39546035553Spatrick
39646035553Spatrick          iterator upper_bound(const key_type& k);
39746035553Spatrick    const_iterator upper_bound(const key_type& k) const;
39846035553Spatrick    template<typename K>
39946035553Spatrick        iterator upper_bound(const K& x);              // C++14
40046035553Spatrick    template<typename K>
40146035553Spatrick        const_iterator upper_bound(const K& x) const;  // C++14
40246035553Spatrick
40346035553Spatrick    pair<iterator,iterator>             equal_range(const key_type& k);
40446035553Spatrick    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
40546035553Spatrick    template<typename K>
40646035553Spatrick        pair<iterator,iterator>             equal_range(const K& x);        // C++14
40746035553Spatrick    template<typename K>
40846035553Spatrick        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
40946035553Spatrick};
41046035553Spatrick
411*4bdff4beSroberttemplate <class InputIterator,
412*4bdff4beSrobert      class Compare = less<typename iterator_traits<InputIterator>::value_type>,
413*4bdff4beSrobert      class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
414*4bdff4beSrobertmultiset(InputIterator, InputIterator,
415*4bdff4beSrobert    Compare = Compare(), Allocator = Allocator())
416*4bdff4beSrobert  -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17
417*4bdff4beSrobert
418*4bdff4beSroberttemplate<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
419*4bdff4beSrobertmultiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
420*4bdff4beSrobert  -> multiset<Key, Compare, Allocator>; // C++17
421*4bdff4beSrobert
422*4bdff4beSroberttemplate<class InputIterator, class Allocator>
423*4bdff4beSrobertmultiset(InputIterator, InputIterator, Allocator)
424*4bdff4beSrobert  -> multiset<typename iterator_traits<InputIterator>::value_type,
425*4bdff4beSrobert          less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
426*4bdff4beSrobert
427*4bdff4beSroberttemplate<class Key, class Allocator>
428*4bdff4beSrobertmultiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>; // C++17
429*4bdff4beSrobert
43046035553Spatricktemplate <class Key, class Compare, class Allocator>
43146035553Spatrickbool
43246035553Spatrickoperator==(const multiset<Key, Compare, Allocator>& x,
43346035553Spatrick           const multiset<Key, Compare, Allocator>& y);
43446035553Spatrick
43546035553Spatricktemplate <class Key, class Compare, class Allocator>
43646035553Spatrickbool
43746035553Spatrickoperator< (const multiset<Key, Compare, Allocator>& x,
43846035553Spatrick           const multiset<Key, Compare, Allocator>& y);
43946035553Spatrick
44046035553Spatricktemplate <class Key, class Compare, class Allocator>
44146035553Spatrickbool
44246035553Spatrickoperator!=(const multiset<Key, Compare, Allocator>& x,
44346035553Spatrick           const multiset<Key, Compare, Allocator>& y);
44446035553Spatrick
44546035553Spatricktemplate <class Key, class Compare, class Allocator>
44646035553Spatrickbool
44746035553Spatrickoperator> (const multiset<Key, Compare, Allocator>& x,
44846035553Spatrick           const multiset<Key, Compare, Allocator>& y);
44946035553Spatrick
45046035553Spatricktemplate <class Key, class Compare, class Allocator>
45146035553Spatrickbool
45246035553Spatrickoperator>=(const multiset<Key, Compare, Allocator>& x,
45346035553Spatrick           const multiset<Key, Compare, Allocator>& y);
45446035553Spatrick
45546035553Spatricktemplate <class Key, class Compare, class Allocator>
45646035553Spatrickbool
45746035553Spatrickoperator<=(const multiset<Key, Compare, Allocator>& x,
45846035553Spatrick           const multiset<Key, Compare, Allocator>& y);
45946035553Spatrick
46046035553Spatrick// specialized algorithms:
46146035553Spatricktemplate <class Key, class Compare, class Allocator>
46246035553Spatrickvoid
46346035553Spatrickswap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
46446035553Spatrick    noexcept(noexcept(x.swap(y)));
46546035553Spatrick
46646035553Spatricktemplate <class Key, class Compare, class Allocator, class Predicate>
467037e7968Spatricktypename multiset<Key, Compare, Allocator>::size_type
468037e7968Spatrickerase_if(multiset<Key, Compare, Allocator>& c, Predicate pred);  // C++20
46946035553Spatrick
47046035553Spatrick}  // std
47146035553Spatrick
47246035553Spatrick*/
47346035553Spatrick
474*4bdff4beSrobert#include <__algorithm/equal.h>
475*4bdff4beSrobert#include <__algorithm/lexicographical_compare.h>
476*4bdff4beSrobert#include <__assert> // all public C++ headers provide the assertion handler
47746035553Spatrick#include <__config>
47876d0caaeSpatrick#include <__functional/is_transparent.h>
479*4bdff4beSrobert#include <__functional/operations.h>
480*4bdff4beSrobert#include <__iterator/erase_if_container.h>
481*4bdff4beSrobert#include <__iterator/iterator_traits.h>
482*4bdff4beSrobert#include <__iterator/reverse_iterator.h>
483*4bdff4beSrobert#include <__memory/allocator.h>
484*4bdff4beSrobert#include <__memory_resource/polymorphic_allocator.h>
48546035553Spatrick#include <__node_handle>
48676d0caaeSpatrick#include <__tree>
487*4bdff4beSrobert#include <__type_traits/is_allocator.h>
48876d0caaeSpatrick#include <__utility/forward.h>
48946035553Spatrick#include <version>
49046035553Spatrick
491*4bdff4beSrobert// standard-mandated includes
492*4bdff4beSrobert
493*4bdff4beSrobert// [iterator.range]
494*4bdff4beSrobert#include <__iterator/access.h>
495*4bdff4beSrobert#include <__iterator/data.h>
496*4bdff4beSrobert#include <__iterator/empty.h>
497*4bdff4beSrobert#include <__iterator/reverse_access.h>
498*4bdff4beSrobert#include <__iterator/size.h>
499*4bdff4beSrobert
500*4bdff4beSrobert// [associative.set.syn]
501*4bdff4beSrobert#include <compare>
502*4bdff4beSrobert#include <initializer_list>
503*4bdff4beSrobert
50446035553Spatrick#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50546035553Spatrick#  pragma GCC system_header
50646035553Spatrick#endif
50746035553Spatrick
50846035553Spatrick_LIBCPP_BEGIN_NAMESPACE_STD
50946035553Spatrick
51046035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
51146035553Spatrickclass multiset;
51246035553Spatrick
51346035553Spatricktemplate <class _Key, class _Compare = less<_Key>,
51446035553Spatrick          class _Allocator = allocator<_Key> >
51546035553Spatrickclass _LIBCPP_TEMPLATE_VIS set
51646035553Spatrick{
51746035553Spatrickpublic:
51846035553Spatrick    // types:
51946035553Spatrick    typedef _Key                                     key_type;
52046035553Spatrick    typedef key_type                                 value_type;
521*4bdff4beSrobert    typedef __type_identity_t<_Compare>              key_compare;
52246035553Spatrick    typedef key_compare                              value_compare;
523*4bdff4beSrobert    typedef __type_identity_t<_Allocator>            allocator_type;
52446035553Spatrick    typedef value_type&                              reference;
52546035553Spatrick    typedef const value_type&                        const_reference;
52646035553Spatrick
52746035553Spatrick    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
52846035553Spatrick                  "Allocator::value_type must be same type as value_type");
52946035553Spatrick
53046035553Spatrickprivate:
53146035553Spatrick    typedef __tree<value_type, value_compare, allocator_type> __base;
53246035553Spatrick    typedef allocator_traits<allocator_type>                  __alloc_traits;
533*4bdff4beSrobert
534*4bdff4beSrobert    static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
535*4bdff4beSrobert                  "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
536*4bdff4beSrobert                  "original allocator");
53746035553Spatrick
53846035553Spatrick    __base __tree_;
53946035553Spatrick
54046035553Spatrickpublic:
54146035553Spatrick    typedef typename __base::pointer               pointer;
54246035553Spatrick    typedef typename __base::const_pointer         const_pointer;
54346035553Spatrick    typedef typename __base::size_type             size_type;
54446035553Spatrick    typedef typename __base::difference_type       difference_type;
54546035553Spatrick    typedef typename __base::const_iterator        iterator;
54646035553Spatrick    typedef typename __base::const_iterator        const_iterator;
54746035553Spatrick    typedef _VSTD::reverse_iterator<iterator>       reverse_iterator;
54846035553Spatrick    typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
54946035553Spatrick
55046035553Spatrick#if _LIBCPP_STD_VER > 14
55146035553Spatrick    typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
55246035553Spatrick    typedef __insert_return_type<iterator, node_type> insert_return_type;
55346035553Spatrick#endif
55446035553Spatrick
55546035553Spatrick    template <class _Key2, class _Compare2, class _Alloc2>
55646035553Spatrick        friend class _LIBCPP_TEMPLATE_VIS set;
55746035553Spatrick    template <class _Key2, class _Compare2, class _Alloc2>
55846035553Spatrick        friend class _LIBCPP_TEMPLATE_VIS multiset;
55946035553Spatrick
56046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
56146035553Spatrick    set()
56246035553Spatrick        _NOEXCEPT_(
56346035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
56446035553Spatrick            is_nothrow_default_constructible<key_compare>::value &&
56546035553Spatrick            is_nothrow_copy_constructible<key_compare>::value)
56646035553Spatrick        : __tree_(value_compare()) {}
56746035553Spatrick
56846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
56946035553Spatrick    explicit set(const value_compare& __comp)
57046035553Spatrick        _NOEXCEPT_(
57146035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
57246035553Spatrick            is_nothrow_copy_constructible<key_compare>::value)
57346035553Spatrick        : __tree_(__comp) {}
57446035553Spatrick
57546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
57646035553Spatrick    explicit set(const value_compare& __comp, const allocator_type& __a)
57746035553Spatrick        : __tree_(__comp, __a) {}
57846035553Spatrick    template <class _InputIterator>
57946035553Spatrick        _LIBCPP_INLINE_VISIBILITY
58046035553Spatrick        set(_InputIterator __f, _InputIterator __l,
58146035553Spatrick            const value_compare& __comp = value_compare())
58246035553Spatrick        : __tree_(__comp)
58346035553Spatrick        {
58446035553Spatrick            insert(__f, __l);
58546035553Spatrick        }
58646035553Spatrick
58746035553Spatrick    template <class _InputIterator>
58846035553Spatrick        _LIBCPP_INLINE_VISIBILITY
58946035553Spatrick        set(_InputIterator __f, _InputIterator __l, const value_compare& __comp,
59046035553Spatrick            const allocator_type& __a)
59146035553Spatrick        : __tree_(__comp, __a)
59246035553Spatrick        {
59346035553Spatrick            insert(__f, __l);
59446035553Spatrick        }
59546035553Spatrick
59646035553Spatrick#if _LIBCPP_STD_VER > 11
59746035553Spatrick        template <class _InputIterator>
59846035553Spatrick        _LIBCPP_INLINE_VISIBILITY
59946035553Spatrick        set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
60046035553Spatrick            : set(__f, __l, key_compare(), __a) {}
60146035553Spatrick#endif
60246035553Spatrick
60346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
60446035553Spatrick    set(const set& __s)
60546035553Spatrick        : __tree_(__s.__tree_)
60646035553Spatrick        {
60746035553Spatrick            insert(__s.begin(), __s.end());
60846035553Spatrick        }
60946035553Spatrick
61046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
61146035553Spatrick    set& operator=(const set& __s)
61246035553Spatrick        {
61346035553Spatrick            __tree_ = __s.__tree_;
61446035553Spatrick            return *this;
61546035553Spatrick        }
61646035553Spatrick
61746035553Spatrick#ifndef _LIBCPP_CXX03_LANG
61846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
61946035553Spatrick    set(set&& __s)
62046035553Spatrick        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
62146035553Spatrick        : __tree_(_VSTD::move(__s.__tree_)) {}
62246035553Spatrick#endif // _LIBCPP_CXX03_LANG
62346035553Spatrick
62446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
62546035553Spatrick    explicit set(const allocator_type& __a)
62646035553Spatrick        : __tree_(__a) {}
62746035553Spatrick
62846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
62946035553Spatrick    set(const set& __s, const allocator_type& __a)
63046035553Spatrick        : __tree_(__s.__tree_.value_comp(), __a)
63146035553Spatrick        {
63246035553Spatrick            insert(__s.begin(), __s.end());
63346035553Spatrick        }
63446035553Spatrick
63546035553Spatrick#ifndef _LIBCPP_CXX03_LANG
63646035553Spatrick    set(set&& __s, const allocator_type& __a);
63746035553Spatrick
63846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
63946035553Spatrick    set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
64046035553Spatrick        : __tree_(__comp)
64146035553Spatrick        {
64246035553Spatrick            insert(__il.begin(), __il.end());
64346035553Spatrick        }
64446035553Spatrick
64546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
64646035553Spatrick    set(initializer_list<value_type> __il, const value_compare& __comp,
64746035553Spatrick        const allocator_type& __a)
64846035553Spatrick        : __tree_(__comp, __a)
64946035553Spatrick        {
65046035553Spatrick            insert(__il.begin(), __il.end());
65146035553Spatrick        }
65246035553Spatrick
65346035553Spatrick#if _LIBCPP_STD_VER > 11
65446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
65546035553Spatrick    set(initializer_list<value_type> __il, const allocator_type& __a)
65646035553Spatrick        : set(__il, key_compare(), __a) {}
65746035553Spatrick#endif
65846035553Spatrick
65946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
66046035553Spatrick    set& operator=(initializer_list<value_type> __il)
66146035553Spatrick        {
66246035553Spatrick            __tree_.__assign_unique(__il.begin(), __il.end());
66346035553Spatrick            return *this;
66446035553Spatrick        }
66546035553Spatrick
66646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
66746035553Spatrick    set& operator=(set&& __s)
66846035553Spatrick        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
66946035553Spatrick        {
67046035553Spatrick            __tree_ = _VSTD::move(__s.__tree_);
67146035553Spatrick            return *this;
67246035553Spatrick        }
67346035553Spatrick#endif // _LIBCPP_CXX03_LANG
67446035553Spatrick
67546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
67646035553Spatrick    ~set() {
67746035553Spatrick        static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
67846035553Spatrick    }
67946035553Spatrick
68046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
68146035553Spatrick          iterator begin() _NOEXCEPT       {return __tree_.begin();}
68246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
68346035553Spatrick    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
68446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
68546035553Spatrick          iterator end() _NOEXCEPT         {return __tree_.end();}
68646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
68746035553Spatrick    const_iterator end()   const _NOEXCEPT {return __tree_.end();}
68846035553Spatrick
68946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
69046035553Spatrick          reverse_iterator rbegin() _NOEXCEPT
69146035553Spatrick            {return reverse_iterator(end());}
69246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
69346035553Spatrick    const_reverse_iterator rbegin() const _NOEXCEPT
69446035553Spatrick        {return const_reverse_iterator(end());}
69546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
69646035553Spatrick          reverse_iterator rend() _NOEXCEPT
69746035553Spatrick            {return reverse_iterator(begin());}
69846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
69946035553Spatrick    const_reverse_iterator rend() const _NOEXCEPT
70046035553Spatrick        {return const_reverse_iterator(begin());}
70146035553Spatrick
70246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
70346035553Spatrick    const_iterator cbegin()  const _NOEXCEPT {return begin();}
70446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
70546035553Spatrick    const_iterator cend() const _NOEXCEPT {return end();}
70646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
70746035553Spatrick    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
70846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
70946035553Spatrick    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
71046035553Spatrick
71146035553Spatrick    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
71246035553Spatrick    bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
71346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
71446035553Spatrick    size_type size() const _NOEXCEPT {return __tree_.size();}
71546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
71646035553Spatrick    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
71746035553Spatrick
71846035553Spatrick    // modifiers:
71946035553Spatrick#ifndef _LIBCPP_CXX03_LANG
72046035553Spatrick    template <class... _Args>
72146035553Spatrick        _LIBCPP_INLINE_VISIBILITY
72246035553Spatrick        pair<iterator, bool> emplace(_Args&&... __args)
72346035553Spatrick            {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
72446035553Spatrick    template <class... _Args>
72546035553Spatrick        _LIBCPP_INLINE_VISIBILITY
72646035553Spatrick        iterator emplace_hint(const_iterator __p, _Args&&... __args)
72746035553Spatrick            {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);}
72846035553Spatrick#endif // _LIBCPP_CXX03_LANG
72946035553Spatrick
73046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
73146035553Spatrick    pair<iterator,bool> insert(const value_type& __v)
73246035553Spatrick        {return __tree_.__insert_unique(__v);}
73346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
73446035553Spatrick    iterator insert(const_iterator __p, const value_type& __v)
73546035553Spatrick        {return __tree_.__insert_unique(__p, __v);}
73646035553Spatrick
73746035553Spatrick    template <class _InputIterator>
73846035553Spatrick        _LIBCPP_INLINE_VISIBILITY
73946035553Spatrick        void insert(_InputIterator __f, _InputIterator __l)
74046035553Spatrick        {
74146035553Spatrick            for (const_iterator __e = cend(); __f != __l; ++__f)
74246035553Spatrick                __tree_.__insert_unique(__e, *__f);
74346035553Spatrick        }
74446035553Spatrick
74546035553Spatrick#ifndef _LIBCPP_CXX03_LANG
74646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
74746035553Spatrick    pair<iterator,bool> insert(value_type&& __v)
74846035553Spatrick        {return __tree_.__insert_unique(_VSTD::move(__v));}
74946035553Spatrick
75046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
75146035553Spatrick    iterator insert(const_iterator __p, value_type&& __v)
75246035553Spatrick        {return __tree_.__insert_unique(__p, _VSTD::move(__v));}
75346035553Spatrick
75446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
75546035553Spatrick    void insert(initializer_list<value_type> __il)
75646035553Spatrick        {insert(__il.begin(), __il.end());}
75746035553Spatrick#endif // _LIBCPP_CXX03_LANG
75846035553Spatrick
75946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
76046035553Spatrick    iterator  erase(const_iterator __p) {return __tree_.erase(__p);}
76146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
76246035553Spatrick    size_type erase(const key_type& __k)
76346035553Spatrick        {return __tree_.__erase_unique(__k);}
76446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
76546035553Spatrick    iterator  erase(const_iterator __f, const_iterator __l)
76646035553Spatrick        {return __tree_.erase(__f, __l);}
76746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
76846035553Spatrick    void clear() _NOEXCEPT {__tree_.clear();}
76946035553Spatrick
77046035553Spatrick#if _LIBCPP_STD_VER > 14
77146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
77246035553Spatrick    insert_return_type insert(node_type&& __nh)
77346035553Spatrick    {
77446035553Spatrick        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
77546035553Spatrick            "node_type with incompatible allocator passed to set::insert()");
77646035553Spatrick        return __tree_.template __node_handle_insert_unique<
77746035553Spatrick            node_type, insert_return_type>(_VSTD::move(__nh));
77846035553Spatrick    }
77946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
78046035553Spatrick    iterator insert(const_iterator __hint, node_type&& __nh)
78146035553Spatrick    {
78246035553Spatrick        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
78346035553Spatrick            "node_type with incompatible allocator passed to set::insert()");
78446035553Spatrick        return __tree_.template __node_handle_insert_unique<node_type>(
78546035553Spatrick            __hint, _VSTD::move(__nh));
78646035553Spatrick    }
78746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
78846035553Spatrick    node_type extract(key_type const& __key)
78946035553Spatrick    {
79046035553Spatrick        return __tree_.template __node_handle_extract<node_type>(__key);
79146035553Spatrick    }
79246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
79346035553Spatrick    node_type extract(const_iterator __it)
79446035553Spatrick    {
79546035553Spatrick        return __tree_.template __node_handle_extract<node_type>(__it);
79646035553Spatrick    }
79746035553Spatrick    template <class _Compare2>
79846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
79946035553Spatrick    void merge(set<key_type, _Compare2, allocator_type>& __source)
80046035553Spatrick    {
80146035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
80246035553Spatrick                       "merging container with incompatible allocator");
80346035553Spatrick        __tree_.__node_handle_merge_unique(__source.__tree_);
80446035553Spatrick    }
80546035553Spatrick    template <class _Compare2>
80646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
80746035553Spatrick    void merge(set<key_type, _Compare2, allocator_type>&& __source)
80846035553Spatrick    {
80946035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
81046035553Spatrick                       "merging container with incompatible allocator");
81146035553Spatrick        __tree_.__node_handle_merge_unique(__source.__tree_);
81246035553Spatrick    }
81346035553Spatrick    template <class _Compare2>
81446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
81546035553Spatrick    void merge(multiset<key_type, _Compare2, allocator_type>& __source)
81646035553Spatrick    {
81746035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
81846035553Spatrick                       "merging container with incompatible allocator");
81946035553Spatrick        __tree_.__node_handle_merge_unique(__source.__tree_);
82046035553Spatrick    }
82146035553Spatrick    template <class _Compare2>
82246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
82346035553Spatrick    void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
82446035553Spatrick    {
82546035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
82646035553Spatrick                       "merging container with incompatible allocator");
82746035553Spatrick        __tree_.__node_handle_merge_unique(__source.__tree_);
82846035553Spatrick    }
82946035553Spatrick#endif
83046035553Spatrick
83146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
83246035553Spatrick    void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
83346035553Spatrick        {__tree_.swap(__s.__tree_);}
83446035553Spatrick
83546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
83646035553Spatrick    allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
83746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
83846035553Spatrick    key_compare    key_comp()      const {return __tree_.value_comp();}
83946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
84046035553Spatrick    value_compare  value_comp()    const {return __tree_.value_comp();}
84146035553Spatrick
84246035553Spatrick    // set operations:
84346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
84446035553Spatrick    iterator find(const key_type& __k)             {return __tree_.find(__k);}
84546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
84646035553Spatrick    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
84746035553Spatrick#if _LIBCPP_STD_VER > 11
84846035553Spatrick    template <typename _K2>
84946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
85046035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
85146035553Spatrick    find(const _K2& __k)                           {return __tree_.find(__k);}
85246035553Spatrick    template <typename _K2>
85346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
85446035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
85546035553Spatrick    find(const _K2& __k) const                     {return __tree_.find(__k);}
85646035553Spatrick#endif
85746035553Spatrick
85846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
85946035553Spatrick    size_type      count(const key_type& __k) const
86046035553Spatrick        {return __tree_.__count_unique(__k);}
86146035553Spatrick#if _LIBCPP_STD_VER > 11
86246035553Spatrick    template <typename _K2>
86346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
86446035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
86546035553Spatrick    count(const _K2& __k) const                    {return __tree_.__count_multi(__k);}
86646035553Spatrick#endif
86746035553Spatrick
86846035553Spatrick#if _LIBCPP_STD_VER > 17
86946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
87046035553Spatrick    bool contains(const key_type& __k) const {return find(__k) != end();}
87176d0caaeSpatrick    template <typename _K2>
87276d0caaeSpatrick    _LIBCPP_INLINE_VISIBILITY
87376d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
87476d0caaeSpatrick    contains(const _K2& __k) const { return find(__k) != end(); }
87546035553Spatrick#endif // _LIBCPP_STD_VER > 17
87646035553Spatrick
87746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
87846035553Spatrick    iterator lower_bound(const key_type& __k)
87946035553Spatrick        {return __tree_.lower_bound(__k);}
88046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
88146035553Spatrick    const_iterator lower_bound(const key_type& __k) const
88246035553Spatrick        {return __tree_.lower_bound(__k);}
88346035553Spatrick#if _LIBCPP_STD_VER > 11
88446035553Spatrick    template <typename _K2>
88546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
88646035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
88746035553Spatrick    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
88846035553Spatrick
88946035553Spatrick    template <typename _K2>
89046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
89146035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
89246035553Spatrick    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
89346035553Spatrick#endif
89446035553Spatrick
89546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
89646035553Spatrick    iterator upper_bound(const key_type& __k)
89746035553Spatrick        {return __tree_.upper_bound(__k);}
89846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
89946035553Spatrick    const_iterator upper_bound(const key_type& __k) const
90046035553Spatrick        {return __tree_.upper_bound(__k);}
90146035553Spatrick#if _LIBCPP_STD_VER > 11
90246035553Spatrick    template <typename _K2>
90346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
90446035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
90546035553Spatrick    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
90646035553Spatrick    template <typename _K2>
90746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
90846035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
90946035553Spatrick    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
91046035553Spatrick#endif
91146035553Spatrick
91246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
91346035553Spatrick    pair<iterator,iterator> equal_range(const key_type& __k)
91446035553Spatrick        {return __tree_.__equal_range_unique(__k);}
91546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
91646035553Spatrick    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
91746035553Spatrick        {return __tree_.__equal_range_unique(__k);}
91846035553Spatrick#if _LIBCPP_STD_VER > 11
91946035553Spatrick    template <typename _K2>
92046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
92146035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
92246035553Spatrick    equal_range(const _K2& __k)       {return __tree_.__equal_range_multi(__k);}
92346035553Spatrick    template <typename _K2>
92446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
92546035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
92646035553Spatrick    equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
92746035553Spatrick#endif
92846035553Spatrick};
92946035553Spatrick
930*4bdff4beSrobert#if _LIBCPP_STD_VER >= 17
93146035553Spatricktemplate<class _InputIterator,
93276d0caaeSpatrick         class _Compare = less<__iter_value_type<_InputIterator>>,
93376d0caaeSpatrick         class _Allocator = allocator<__iter_value_type<_InputIterator>>,
934*4bdff4beSrobert         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
935*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>,
936*4bdff4beSrobert         class = enable_if_t<!__is_allocator<_Compare>::value, void>>
93746035553Spatrickset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
93876d0caaeSpatrick  -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
93946035553Spatrick
94046035553Spatricktemplate<class _Key, class _Compare = less<_Key>,
94146035553Spatrick         class _Allocator = allocator<_Key>,
942*4bdff4beSrobert         class = enable_if_t<!__is_allocator<_Compare>::value, void>,
943*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
94446035553Spatrickset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
94546035553Spatrick  -> set<_Key, _Compare, _Allocator>;
94646035553Spatrick
94746035553Spatricktemplate<class _InputIterator, class _Allocator,
948*4bdff4beSrobert         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
949*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
95046035553Spatrickset(_InputIterator, _InputIterator, _Allocator)
95176d0caaeSpatrick  -> set<__iter_value_type<_InputIterator>,
95276d0caaeSpatrick         less<__iter_value_type<_InputIterator>>, _Allocator>;
95346035553Spatrick
95446035553Spatricktemplate<class _Key, class _Allocator,
955*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
95646035553Spatrickset(initializer_list<_Key>, _Allocator)
95746035553Spatrick  -> set<_Key, less<_Key>, _Allocator>;
95846035553Spatrick#endif
95946035553Spatrick
96046035553Spatrick#ifndef _LIBCPP_CXX03_LANG
96146035553Spatrick
96246035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
96346035553Spatrickset<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
96446035553Spatrick    : __tree_(_VSTD::move(__s.__tree_), __a)
96546035553Spatrick{
96646035553Spatrick    if (__a != __s.get_allocator())
96746035553Spatrick    {
96846035553Spatrick        const_iterator __e = cend();
96946035553Spatrick        while (!__s.empty())
97046035553Spatrick            insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
97146035553Spatrick    }
97246035553Spatrick}
97346035553Spatrick
97446035553Spatrick#endif // _LIBCPP_CXX03_LANG
97546035553Spatrick
97646035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
97746035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
97846035553Spatrickbool
97946035553Spatrickoperator==(const set<_Key, _Compare, _Allocator>& __x,
98046035553Spatrick           const set<_Key, _Compare, _Allocator>& __y)
98146035553Spatrick{
98246035553Spatrick    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
98346035553Spatrick}
98446035553Spatrick
98546035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
98646035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
98746035553Spatrickbool
98846035553Spatrickoperator< (const set<_Key, _Compare, _Allocator>& __x,
98946035553Spatrick           const set<_Key, _Compare, _Allocator>& __y)
99046035553Spatrick{
99146035553Spatrick    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
99246035553Spatrick}
99346035553Spatrick
99446035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
99546035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
99646035553Spatrickbool
99746035553Spatrickoperator!=(const set<_Key, _Compare, _Allocator>& __x,
99846035553Spatrick           const set<_Key, _Compare, _Allocator>& __y)
99946035553Spatrick{
100046035553Spatrick    return !(__x == __y);
100146035553Spatrick}
100246035553Spatrick
100346035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
100446035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
100546035553Spatrickbool
100646035553Spatrickoperator> (const set<_Key, _Compare, _Allocator>& __x,
100746035553Spatrick           const set<_Key, _Compare, _Allocator>& __y)
100846035553Spatrick{
100946035553Spatrick    return __y < __x;
101046035553Spatrick}
101146035553Spatrick
101246035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
101346035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
101446035553Spatrickbool
101546035553Spatrickoperator>=(const set<_Key, _Compare, _Allocator>& __x,
101646035553Spatrick           const set<_Key, _Compare, _Allocator>& __y)
101746035553Spatrick{
101846035553Spatrick    return !(__x < __y);
101946035553Spatrick}
102046035553Spatrick
102146035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
102246035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
102346035553Spatrickbool
102446035553Spatrickoperator<=(const set<_Key, _Compare, _Allocator>& __x,
102546035553Spatrick           const set<_Key, _Compare, _Allocator>& __y)
102646035553Spatrick{
102746035553Spatrick    return !(__y < __x);
102846035553Spatrick}
102946035553Spatrick
103046035553Spatrick// specialized algorithms:
103146035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
103246035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
103346035553Spatrickvoid
103446035553Spatrickswap(set<_Key, _Compare, _Allocator>& __x,
103546035553Spatrick     set<_Key, _Compare, _Allocator>& __y)
103646035553Spatrick    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
103746035553Spatrick{
103846035553Spatrick    __x.swap(__y);
103946035553Spatrick}
104046035553Spatrick
104146035553Spatrick#if _LIBCPP_STD_VER > 17
104246035553Spatricktemplate <class _Key, class _Compare, class _Allocator, class _Predicate>
104346035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
1044037e7968Spatrick    typename set<_Key, _Compare, _Allocator>::size_type
1045037e7968Spatrick    erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
104676d0caaeSpatrick  return _VSTD::__libcpp_erase_if_container(__c, __pred);
1047037e7968Spatrick}
104846035553Spatrick#endif
104946035553Spatrick
105046035553Spatricktemplate <class _Key, class _Compare = less<_Key>,
105146035553Spatrick          class _Allocator = allocator<_Key> >
105246035553Spatrickclass _LIBCPP_TEMPLATE_VIS multiset
105346035553Spatrick{
105446035553Spatrickpublic:
105546035553Spatrick    // types:
105646035553Spatrick    typedef _Key                                     key_type;
105746035553Spatrick    typedef key_type                                 value_type;
1058*4bdff4beSrobert    typedef __type_identity_t<_Compare>              key_compare;
105946035553Spatrick    typedef key_compare                              value_compare;
1060*4bdff4beSrobert    typedef __type_identity_t<_Allocator>            allocator_type;
106146035553Spatrick    typedef value_type&                              reference;
106246035553Spatrick    typedef const value_type&                        const_reference;
106346035553Spatrick
106446035553Spatrick    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
106546035553Spatrick                  "Allocator::value_type must be same type as value_type");
106646035553Spatrick
106746035553Spatrickprivate:
106846035553Spatrick    typedef __tree<value_type, value_compare, allocator_type> __base;
106946035553Spatrick    typedef allocator_traits<allocator_type>                  __alloc_traits;
1070*4bdff4beSrobert
1071*4bdff4beSrobert    static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1072*4bdff4beSrobert                  "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1073*4bdff4beSrobert                  "original allocator");
107446035553Spatrick
107546035553Spatrick    __base __tree_;
107646035553Spatrick
107746035553Spatrickpublic:
107846035553Spatrick    typedef typename __base::pointer               pointer;
107946035553Spatrick    typedef typename __base::const_pointer         const_pointer;
108046035553Spatrick    typedef typename __base::size_type             size_type;
108146035553Spatrick    typedef typename __base::difference_type       difference_type;
108246035553Spatrick    typedef typename __base::const_iterator        iterator;
108346035553Spatrick    typedef typename __base::const_iterator        const_iterator;
108446035553Spatrick    typedef _VSTD::reverse_iterator<iterator>       reverse_iterator;
108546035553Spatrick    typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
108646035553Spatrick
108746035553Spatrick#if _LIBCPP_STD_VER > 14
108846035553Spatrick    typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
108946035553Spatrick#endif
109046035553Spatrick
109146035553Spatrick    template <class _Key2, class _Compare2, class _Alloc2>
109246035553Spatrick        friend class _LIBCPP_TEMPLATE_VIS set;
109346035553Spatrick    template <class _Key2, class _Compare2, class _Alloc2>
109446035553Spatrick        friend class _LIBCPP_TEMPLATE_VIS multiset;
109546035553Spatrick
109646035553Spatrick    // construct/copy/destroy:
109746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
109846035553Spatrick    multiset()
109946035553Spatrick        _NOEXCEPT_(
110046035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
110146035553Spatrick            is_nothrow_default_constructible<key_compare>::value &&
110246035553Spatrick            is_nothrow_copy_constructible<key_compare>::value)
110346035553Spatrick        : __tree_(value_compare()) {}
110446035553Spatrick
110546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
110646035553Spatrick    explicit multiset(const value_compare& __comp)
110746035553Spatrick        _NOEXCEPT_(
110846035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
110946035553Spatrick            is_nothrow_copy_constructible<key_compare>::value)
111046035553Spatrick        : __tree_(__comp) {}
111146035553Spatrick
111246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
111346035553Spatrick    explicit multiset(const value_compare& __comp, const allocator_type& __a)
111446035553Spatrick        : __tree_(__comp, __a) {}
111546035553Spatrick    template <class _InputIterator>
111646035553Spatrick        _LIBCPP_INLINE_VISIBILITY
111746035553Spatrick        multiset(_InputIterator __f, _InputIterator __l,
111846035553Spatrick                 const value_compare& __comp = value_compare())
111946035553Spatrick        : __tree_(__comp)
112046035553Spatrick        {
112146035553Spatrick            insert(__f, __l);
112246035553Spatrick        }
112346035553Spatrick
112446035553Spatrick#if _LIBCPP_STD_VER > 11
112546035553Spatrick        template <class _InputIterator>
112646035553Spatrick        _LIBCPP_INLINE_VISIBILITY
112746035553Spatrick        multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
112846035553Spatrick            : multiset(__f, __l, key_compare(), __a) {}
112946035553Spatrick#endif
113046035553Spatrick
113146035553Spatrick    template <class _InputIterator>
113246035553Spatrick        _LIBCPP_INLINE_VISIBILITY
113346035553Spatrick        multiset(_InputIterator __f, _InputIterator __l,
113446035553Spatrick                 const value_compare& __comp, const allocator_type& __a)
113546035553Spatrick        : __tree_(__comp, __a)
113646035553Spatrick        {
113746035553Spatrick            insert(__f, __l);
113846035553Spatrick        }
113946035553Spatrick
114046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
114146035553Spatrick    multiset(const multiset& __s)
114246035553Spatrick        : __tree_(__s.__tree_.value_comp(),
114346035553Spatrick          __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc()))
114446035553Spatrick        {
114546035553Spatrick            insert(__s.begin(), __s.end());
114646035553Spatrick        }
114746035553Spatrick
114846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
114946035553Spatrick    multiset& operator=(const multiset& __s)
115046035553Spatrick        {
115146035553Spatrick            __tree_ = __s.__tree_;
115246035553Spatrick            return *this;
115346035553Spatrick        }
115446035553Spatrick
115546035553Spatrick#ifndef _LIBCPP_CXX03_LANG
115646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
115746035553Spatrick    multiset(multiset&& __s)
115846035553Spatrick        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
115946035553Spatrick        : __tree_(_VSTD::move(__s.__tree_)) {}
116046035553Spatrick
116146035553Spatrick    multiset(multiset&& __s, const allocator_type& __a);
116246035553Spatrick#endif // _LIBCPP_CXX03_LANG
116346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
116446035553Spatrick    explicit multiset(const allocator_type& __a)
116546035553Spatrick        : __tree_(__a) {}
116646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
116746035553Spatrick    multiset(const multiset& __s, const allocator_type& __a)
116846035553Spatrick        : __tree_(__s.__tree_.value_comp(), __a)
116946035553Spatrick        {
117046035553Spatrick            insert(__s.begin(), __s.end());
117146035553Spatrick        }
117246035553Spatrick
117346035553Spatrick#ifndef _LIBCPP_CXX03_LANG
117446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
117546035553Spatrick    multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
117646035553Spatrick        : __tree_(__comp)
117746035553Spatrick        {
117846035553Spatrick            insert(__il.begin(), __il.end());
117946035553Spatrick        }
118046035553Spatrick
118146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
118246035553Spatrick    multiset(initializer_list<value_type> __il, const value_compare& __comp,
118346035553Spatrick        const allocator_type& __a)
118446035553Spatrick        : __tree_(__comp, __a)
118546035553Spatrick        {
118646035553Spatrick            insert(__il.begin(), __il.end());
118746035553Spatrick        }
118846035553Spatrick
118946035553Spatrick#if _LIBCPP_STD_VER > 11
119046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
119146035553Spatrick    multiset(initializer_list<value_type> __il, const allocator_type& __a)
119246035553Spatrick        : multiset(__il, key_compare(), __a) {}
119346035553Spatrick#endif
119446035553Spatrick
119546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
119646035553Spatrick    multiset& operator=(initializer_list<value_type> __il)
119746035553Spatrick        {
119846035553Spatrick            __tree_.__assign_multi(__il.begin(), __il.end());
119946035553Spatrick            return *this;
120046035553Spatrick        }
120146035553Spatrick
120246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
120346035553Spatrick    multiset& operator=(multiset&& __s)
120446035553Spatrick        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
120546035553Spatrick        {
120646035553Spatrick            __tree_ = _VSTD::move(__s.__tree_);
120746035553Spatrick            return *this;
120846035553Spatrick        }
120946035553Spatrick#endif // _LIBCPP_CXX03_LANG
121046035553Spatrick
121146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
121246035553Spatrick    ~multiset() {
121346035553Spatrick        static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
121446035553Spatrick    }
121546035553Spatrick
121646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
121746035553Spatrick          iterator begin() _NOEXCEPT       {return __tree_.begin();}
121846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
121946035553Spatrick    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
122046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
122146035553Spatrick          iterator end() _NOEXCEPT         {return __tree_.end();}
122246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
122346035553Spatrick    const_iterator end()   const _NOEXCEPT {return __tree_.end();}
122446035553Spatrick
122546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
122646035553Spatrick          reverse_iterator rbegin() _NOEXCEPT
122746035553Spatrick            {return reverse_iterator(end());}
122846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
122946035553Spatrick    const_reverse_iterator rbegin() const _NOEXCEPT
123046035553Spatrick        {return const_reverse_iterator(end());}
123146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
123246035553Spatrick          reverse_iterator rend() _NOEXCEPT
123346035553Spatrick            {return       reverse_iterator(begin());}
123446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
123546035553Spatrick    const_reverse_iterator rend() const _NOEXCEPT
123646035553Spatrick        {return const_reverse_iterator(begin());}
123746035553Spatrick
123846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
123946035553Spatrick    const_iterator cbegin()  const _NOEXCEPT {return begin();}
124046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
124146035553Spatrick    const_iterator cend() const _NOEXCEPT {return end();}
124246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
124346035553Spatrick    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
124446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
124546035553Spatrick    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
124646035553Spatrick
124746035553Spatrick    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
124846035553Spatrick    bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
124946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
125046035553Spatrick    size_type size() const _NOEXCEPT {return __tree_.size();}
125146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
125246035553Spatrick    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
125346035553Spatrick
125446035553Spatrick    // modifiers:
125546035553Spatrick#ifndef _LIBCPP_CXX03_LANG
125646035553Spatrick    template <class... _Args>
125746035553Spatrick        _LIBCPP_INLINE_VISIBILITY
125846035553Spatrick        iterator emplace(_Args&&... __args)
125946035553Spatrick            {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
126046035553Spatrick    template <class... _Args>
126146035553Spatrick        _LIBCPP_INLINE_VISIBILITY
126246035553Spatrick        iterator emplace_hint(const_iterator __p, _Args&&... __args)
126346035553Spatrick            {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
126446035553Spatrick#endif // _LIBCPP_CXX03_LANG
126546035553Spatrick
126646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
126746035553Spatrick    iterator insert(const value_type& __v)
126846035553Spatrick        {return __tree_.__insert_multi(__v);}
126946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
127046035553Spatrick    iterator insert(const_iterator __p, const value_type& __v)
127146035553Spatrick        {return __tree_.__insert_multi(__p, __v);}
127246035553Spatrick
127346035553Spatrick    template <class _InputIterator>
127446035553Spatrick        _LIBCPP_INLINE_VISIBILITY
127546035553Spatrick        void insert(_InputIterator __f, _InputIterator __l)
127646035553Spatrick        {
127746035553Spatrick            for (const_iterator __e = cend(); __f != __l; ++__f)
127846035553Spatrick                __tree_.__insert_multi(__e, *__f);
127946035553Spatrick        }
128046035553Spatrick
128146035553Spatrick#ifndef _LIBCPP_CXX03_LANG
128246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
128346035553Spatrick    iterator insert(value_type&& __v)
128446035553Spatrick        {return __tree_.__insert_multi(_VSTD::move(__v));}
128546035553Spatrick
128646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
128746035553Spatrick    iterator insert(const_iterator __p, value_type&& __v)
128846035553Spatrick        {return __tree_.__insert_multi(__p, _VSTD::move(__v));}
128946035553Spatrick
129046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
129146035553Spatrick    void insert(initializer_list<value_type> __il)
129246035553Spatrick        {insert(__il.begin(), __il.end());}
129346035553Spatrick#endif // _LIBCPP_CXX03_LANG
129446035553Spatrick
129546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
129646035553Spatrick    iterator  erase(const_iterator __p) {return __tree_.erase(__p);}
129746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
129846035553Spatrick    size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
129946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
130046035553Spatrick    iterator  erase(const_iterator __f, const_iterator __l)
130146035553Spatrick        {return __tree_.erase(__f, __l);}
130246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
130346035553Spatrick    void clear() _NOEXCEPT {__tree_.clear();}
130446035553Spatrick
130546035553Spatrick#if _LIBCPP_STD_VER > 14
130646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
130746035553Spatrick    iterator insert(node_type&& __nh)
130846035553Spatrick    {
130946035553Spatrick        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
131046035553Spatrick            "node_type with incompatible allocator passed to multiset::insert()");
131146035553Spatrick        return __tree_.template __node_handle_insert_multi<node_type>(
131246035553Spatrick            _VSTD::move(__nh));
131346035553Spatrick    }
131446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
131546035553Spatrick    iterator insert(const_iterator __hint, node_type&& __nh)
131646035553Spatrick    {
131746035553Spatrick        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
131846035553Spatrick            "node_type with incompatible allocator passed to multiset::insert()");
131946035553Spatrick        return __tree_.template __node_handle_insert_multi<node_type>(
132046035553Spatrick            __hint, _VSTD::move(__nh));
132146035553Spatrick    }
132246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
132346035553Spatrick    node_type extract(key_type const& __key)
132446035553Spatrick    {
132546035553Spatrick        return __tree_.template __node_handle_extract<node_type>(__key);
132646035553Spatrick    }
132746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
132846035553Spatrick    node_type extract(const_iterator __it)
132946035553Spatrick    {
133046035553Spatrick        return __tree_.template __node_handle_extract<node_type>(__it);
133146035553Spatrick    }
133246035553Spatrick    template <class _Compare2>
133346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
133446035553Spatrick    void merge(multiset<key_type, _Compare2, allocator_type>& __source)
133546035553Spatrick    {
133646035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
133746035553Spatrick                       "merging container with incompatible allocator");
133846035553Spatrick        __tree_.__node_handle_merge_multi(__source.__tree_);
133946035553Spatrick    }
134046035553Spatrick    template <class _Compare2>
134146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
134246035553Spatrick    void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
134346035553Spatrick    {
134446035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
134546035553Spatrick                       "merging container with incompatible allocator");
134646035553Spatrick        __tree_.__node_handle_merge_multi(__source.__tree_);
134746035553Spatrick    }
134846035553Spatrick    template <class _Compare2>
134946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
135046035553Spatrick    void merge(set<key_type, _Compare2, allocator_type>& __source)
135146035553Spatrick    {
135246035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
135346035553Spatrick                       "merging container with incompatible allocator");
135446035553Spatrick        __tree_.__node_handle_merge_multi(__source.__tree_);
135546035553Spatrick    }
135646035553Spatrick    template <class _Compare2>
135746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
135846035553Spatrick    void merge(set<key_type, _Compare2, allocator_type>&& __source)
135946035553Spatrick    {
136046035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
136146035553Spatrick                       "merging container with incompatible allocator");
136246035553Spatrick        __tree_.__node_handle_merge_multi(__source.__tree_);
136346035553Spatrick    }
136446035553Spatrick#endif
136546035553Spatrick
136646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
136746035553Spatrick    void swap(multiset& __s)
136846035553Spatrick        _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
136946035553Spatrick        {__tree_.swap(__s.__tree_);}
137046035553Spatrick
137146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
137246035553Spatrick    allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
137346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
137446035553Spatrick    key_compare    key_comp()      const {return __tree_.value_comp();}
137546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
137646035553Spatrick    value_compare  value_comp()    const {return __tree_.value_comp();}
137746035553Spatrick
137846035553Spatrick    // set operations:
137946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
138046035553Spatrick    iterator find(const key_type& __k)             {return __tree_.find(__k);}
138146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
138246035553Spatrick    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
138346035553Spatrick#if _LIBCPP_STD_VER > 11
138446035553Spatrick    template <typename _K2>
138546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
138676d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
138746035553Spatrick    find(const _K2& __k)                           {return __tree_.find(__k);}
138846035553Spatrick    template <typename _K2>
138946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
139076d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
139146035553Spatrick    find(const _K2& __k) const                     {return __tree_.find(__k);}
139246035553Spatrick#endif
139346035553Spatrick
139446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
139546035553Spatrick    size_type      count(const key_type& __k) const
139646035553Spatrick        {return __tree_.__count_multi(__k);}
139746035553Spatrick#if _LIBCPP_STD_VER > 11
139846035553Spatrick    template <typename _K2>
139946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
140046035553Spatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
140146035553Spatrick    count(const _K2& __k) const            {return __tree_.__count_multi(__k);}
140246035553Spatrick#endif
140346035553Spatrick
140446035553Spatrick#if _LIBCPP_STD_VER > 17
140546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
140646035553Spatrick    bool contains(const key_type& __k) const {return find(__k) != end();}
140776d0caaeSpatrick    template <typename _K2>
140876d0caaeSpatrick    _LIBCPP_INLINE_VISIBILITY
140976d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
141076d0caaeSpatrick    contains(const _K2& __k) const { return find(__k) != end(); }
141146035553Spatrick#endif // _LIBCPP_STD_VER > 17
141246035553Spatrick
141346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
141446035553Spatrick    iterator lower_bound(const key_type& __k)
141546035553Spatrick        {return __tree_.lower_bound(__k);}
141646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
141746035553Spatrick    const_iterator lower_bound(const key_type& __k) const
141846035553Spatrick            {return __tree_.lower_bound(__k);}
141946035553Spatrick#if _LIBCPP_STD_VER > 11
142046035553Spatrick    template <typename _K2>
142146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
142276d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
142346035553Spatrick    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
142446035553Spatrick
142546035553Spatrick    template <typename _K2>
142646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
142776d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
142846035553Spatrick    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
142946035553Spatrick#endif
143046035553Spatrick
143146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
143246035553Spatrick    iterator upper_bound(const key_type& __k)
143346035553Spatrick            {return __tree_.upper_bound(__k);}
143446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
143546035553Spatrick    const_iterator upper_bound(const key_type& __k) const
143646035553Spatrick            {return __tree_.upper_bound(__k);}
143746035553Spatrick#if _LIBCPP_STD_VER > 11
143846035553Spatrick    template <typename _K2>
143946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
144076d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
144146035553Spatrick    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
144246035553Spatrick    template <typename _K2>
144346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
144476d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
144546035553Spatrick    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
144646035553Spatrick#endif
144746035553Spatrick
144846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
144946035553Spatrick    pair<iterator,iterator>             equal_range(const key_type& __k)
145046035553Spatrick            {return __tree_.__equal_range_multi(__k);}
145146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
145246035553Spatrick    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
145346035553Spatrick            {return __tree_.__equal_range_multi(__k);}
145446035553Spatrick#if _LIBCPP_STD_VER > 11
145546035553Spatrick    template <typename _K2>
145646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
145776d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
145846035553Spatrick    equal_range(const _K2& __k)       {return __tree_.__equal_range_multi(__k);}
145946035553Spatrick    template <typename _K2>
146046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
146176d0caaeSpatrick    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
146246035553Spatrick    equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
146346035553Spatrick#endif
146446035553Spatrick};
146546035553Spatrick
1466*4bdff4beSrobert#if _LIBCPP_STD_VER >= 17
146746035553Spatricktemplate<class _InputIterator,
146876d0caaeSpatrick         class _Compare = less<__iter_value_type<_InputIterator>>,
146976d0caaeSpatrick         class _Allocator = allocator<__iter_value_type<_InputIterator>>,
1470*4bdff4beSrobert         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
1471*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>,
1472*4bdff4beSrobert         class = enable_if_t<!__is_allocator<_Compare>::value, void>>
147346035553Spatrickmultiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
147476d0caaeSpatrick  -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
147546035553Spatrick
147646035553Spatricktemplate<class _Key, class _Compare = less<_Key>,
147746035553Spatrick         class _Allocator = allocator<_Key>,
1478*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>,
1479*4bdff4beSrobert         class = enable_if_t<!__is_allocator<_Compare>::value, void>>
148046035553Spatrickmultiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
148146035553Spatrick  -> multiset<_Key, _Compare, _Allocator>;
148246035553Spatrick
148346035553Spatricktemplate<class _InputIterator, class _Allocator,
1484*4bdff4beSrobert         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
1485*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
148646035553Spatrickmultiset(_InputIterator, _InputIterator, _Allocator)
148776d0caaeSpatrick  -> multiset<__iter_value_type<_InputIterator>,
148876d0caaeSpatrick         less<__iter_value_type<_InputIterator>>, _Allocator>;
148946035553Spatrick
149046035553Spatricktemplate<class _Key, class _Allocator,
1491*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
149246035553Spatrickmultiset(initializer_list<_Key>, _Allocator)
149346035553Spatrick  -> multiset<_Key, less<_Key>, _Allocator>;
149446035553Spatrick#endif
149546035553Spatrick
149646035553Spatrick#ifndef _LIBCPP_CXX03_LANG
149746035553Spatrick
149846035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
149946035553Spatrickmultiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
150046035553Spatrick    : __tree_(_VSTD::move(__s.__tree_), __a)
150146035553Spatrick{
150246035553Spatrick    if (__a != __s.get_allocator())
150346035553Spatrick    {
150446035553Spatrick        const_iterator __e = cend();
150546035553Spatrick        while (!__s.empty())
150646035553Spatrick            insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
150746035553Spatrick    }
150846035553Spatrick}
150946035553Spatrick
151046035553Spatrick#endif // _LIBCPP_CXX03_LANG
151146035553Spatrick
151246035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
151346035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
151446035553Spatrickbool
151546035553Spatrickoperator==(const multiset<_Key, _Compare, _Allocator>& __x,
151646035553Spatrick           const multiset<_Key, _Compare, _Allocator>& __y)
151746035553Spatrick{
151846035553Spatrick    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
151946035553Spatrick}
152046035553Spatrick
152146035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
152246035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
152346035553Spatrickbool
152446035553Spatrickoperator< (const multiset<_Key, _Compare, _Allocator>& __x,
152546035553Spatrick           const multiset<_Key, _Compare, _Allocator>& __y)
152646035553Spatrick{
152746035553Spatrick    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
152846035553Spatrick}
152946035553Spatrick
153046035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
153146035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
153246035553Spatrickbool
153346035553Spatrickoperator!=(const multiset<_Key, _Compare, _Allocator>& __x,
153446035553Spatrick           const multiset<_Key, _Compare, _Allocator>& __y)
153546035553Spatrick{
153646035553Spatrick    return !(__x == __y);
153746035553Spatrick}
153846035553Spatrick
153946035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
154046035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
154146035553Spatrickbool
154246035553Spatrickoperator> (const multiset<_Key, _Compare, _Allocator>& __x,
154346035553Spatrick           const multiset<_Key, _Compare, _Allocator>& __y)
154446035553Spatrick{
154546035553Spatrick    return __y < __x;
154646035553Spatrick}
154746035553Spatrick
154846035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
154946035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
155046035553Spatrickbool
155146035553Spatrickoperator>=(const multiset<_Key, _Compare, _Allocator>& __x,
155246035553Spatrick           const multiset<_Key, _Compare, _Allocator>& __y)
155346035553Spatrick{
155446035553Spatrick    return !(__x < __y);
155546035553Spatrick}
155646035553Spatrick
155746035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
155846035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
155946035553Spatrickbool
156046035553Spatrickoperator<=(const multiset<_Key, _Compare, _Allocator>& __x,
156146035553Spatrick           const multiset<_Key, _Compare, _Allocator>& __y)
156246035553Spatrick{
156346035553Spatrick    return !(__y < __x);
156446035553Spatrick}
156546035553Spatrick
156646035553Spatricktemplate <class _Key, class _Compare, class _Allocator>
156746035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
156846035553Spatrickvoid
156946035553Spatrickswap(multiset<_Key, _Compare, _Allocator>& __x,
157046035553Spatrick     multiset<_Key, _Compare, _Allocator>& __y)
157146035553Spatrick    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
157246035553Spatrick{
157346035553Spatrick    __x.swap(__y);
157446035553Spatrick}
157546035553Spatrick
157646035553Spatrick#if _LIBCPP_STD_VER > 17
157746035553Spatricktemplate <class _Key, class _Compare, class _Allocator, class _Predicate>
157846035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
1579037e7968Spatrick    typename multiset<_Key, _Compare, _Allocator>::size_type
1580037e7968Spatrick    erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
158176d0caaeSpatrick  return _VSTD::__libcpp_erase_if_container(__c, __pred);
1582037e7968Spatrick}
158346035553Spatrick#endif
158446035553Spatrick
158546035553Spatrick_LIBCPP_END_NAMESPACE_STD
158646035553Spatrick
1587*4bdff4beSrobert#if _LIBCPP_STD_VER > 14
1588*4bdff4beSrobert_LIBCPP_BEGIN_NAMESPACE_STD
1589*4bdff4beSrobertnamespace pmr {
1590*4bdff4beSroberttemplate <class _KeyT, class _CompareT = std::less<_KeyT>>
1591*4bdff4beSrobertusing set = std::set<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;
1592*4bdff4beSrobert
1593*4bdff4beSroberttemplate <class _KeyT, class _CompareT = std::less<_KeyT>>
1594*4bdff4beSrobertusing multiset = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;
1595*4bdff4beSrobert} // namespace pmr
1596*4bdff4beSrobert_LIBCPP_END_NAMESPACE_STD
1597*4bdff4beSrobert#endif
1598*4bdff4beSrobert
1599*4bdff4beSrobert#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1600*4bdff4beSrobert#  include <concepts>
1601*4bdff4beSrobert#  include <functional>
1602*4bdff4beSrobert#  include <iterator>
1603*4bdff4beSrobert#endif
1604*4bdff4beSrobert
160546035553Spatrick#endif // _LIBCPP_SET
1606