xref: /openbsd-src/gnu/llvm/libcxx/include/map (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_MAP
1146035553Spatrick#define _LIBCPP_MAP
1246035553Spatrick
1346035553Spatrick/*
1446035553Spatrick
1546035553Spatrick    map synopsis
1646035553Spatrick
1746035553Spatricknamespace std
1846035553Spatrick{
1946035553Spatrick
2046035553Spatricktemplate <class Key, class T, class Compare = less<Key>,
2146035553Spatrick          class Allocator = allocator<pair<const Key, T>>>
2246035553Spatrickclass map
2346035553Spatrick{
2446035553Spatrickpublic:
2546035553Spatrick    // types:
2646035553Spatrick    typedef Key                                      key_type;
2746035553Spatrick    typedef T                                        mapped_type;
2846035553Spatrick    typedef pair<const key_type, mapped_type>        value_type;
2946035553Spatrick    typedef Compare                                  key_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::pointer         pointer;
3446035553Spatrick    typedef typename allocator_type::const_pointer   const_pointer;
3546035553Spatrick    typedef typename allocator_type::size_type       size_type;
3646035553Spatrick    typedef typename allocator_type::difference_type difference_type;
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    class value_compare
4646035553Spatrick    {
4746035553Spatrick        friend class map;
4846035553Spatrick    protected:
4946035553Spatrick        key_compare comp;
5046035553Spatrick
5146035553Spatrick        value_compare(key_compare c);
5246035553Spatrick    public:
5376d0caaeSpatrick        typedef bool result_type;  // deprecated in C++17, removed in C++20
5476d0caaeSpatrick        typedef value_type first_argument_type;  // deprecated in C++17, removed in C++20
5576d0caaeSpatrick        typedef value_type second_argument_type;  // deprecated in C++17, removed in C++20
5646035553Spatrick        bool operator()(const value_type& x, const value_type& y) const;
5746035553Spatrick    };
5846035553Spatrick
5946035553Spatrick    // construct/copy/destroy:
6046035553Spatrick    map()
6146035553Spatrick        noexcept(
6246035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
6346035553Spatrick            is_nothrow_default_constructible<key_compare>::value &&
6446035553Spatrick            is_nothrow_copy_constructible<key_compare>::value);
6546035553Spatrick    explicit map(const key_compare& comp);
6646035553Spatrick    map(const key_compare& comp, const allocator_type& a);
6746035553Spatrick    template <class InputIterator>
6846035553Spatrick        map(InputIterator first, InputIterator last,
6946035553Spatrick            const key_compare& comp = key_compare());
7046035553Spatrick    template <class InputIterator>
7146035553Spatrick        map(InputIterator first, InputIterator last,
7246035553Spatrick            const key_compare& comp, const allocator_type& a);
7346035553Spatrick    map(const map& m);
7446035553Spatrick    map(map&& m)
7546035553Spatrick        noexcept(
7646035553Spatrick            is_nothrow_move_constructible<allocator_type>::value &&
7746035553Spatrick            is_nothrow_move_constructible<key_compare>::value);
7846035553Spatrick    explicit map(const allocator_type& a);
7946035553Spatrick    map(const map& m, const allocator_type& a);
8046035553Spatrick    map(map&& m, const allocator_type& a);
8146035553Spatrick    map(initializer_list<value_type> il, const key_compare& comp = key_compare());
8246035553Spatrick    map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
8346035553Spatrick    template <class InputIterator>
8446035553Spatrick        map(InputIterator first, InputIterator last, const allocator_type& a)
8546035553Spatrick            : map(first, last, Compare(), a) {}  // C++14
8646035553Spatrick    map(initializer_list<value_type> il, const allocator_type& a)
8746035553Spatrick        : map(il, Compare(), a) {}  // C++14
8846035553Spatrick   ~map();
8946035553Spatrick
9046035553Spatrick    map& operator=(const map& m);
9146035553Spatrick    map& operator=(map&& m)
9246035553Spatrick        noexcept(
9346035553Spatrick            allocator_type::propagate_on_container_move_assignment::value &&
9446035553Spatrick            is_nothrow_move_assignable<allocator_type>::value &&
9546035553Spatrick            is_nothrow_move_assignable<key_compare>::value);
9646035553Spatrick    map& operator=(initializer_list<value_type> il);
9746035553Spatrick
9846035553Spatrick    // iterators:
9946035553Spatrick          iterator begin() noexcept;
10046035553Spatrick    const_iterator begin() const noexcept;
10146035553Spatrick          iterator end() noexcept;
10246035553Spatrick    const_iterator end()   const noexcept;
10346035553Spatrick
10446035553Spatrick          reverse_iterator rbegin() noexcept;
10546035553Spatrick    const_reverse_iterator rbegin() const noexcept;
10646035553Spatrick          reverse_iterator rend() noexcept;
10746035553Spatrick    const_reverse_iterator rend()   const noexcept;
10846035553Spatrick
10946035553Spatrick    const_iterator         cbegin()  const noexcept;
11046035553Spatrick    const_iterator         cend()    const noexcept;
11146035553Spatrick    const_reverse_iterator crbegin() const noexcept;
11246035553Spatrick    const_reverse_iterator crend()   const noexcept;
11346035553Spatrick
11446035553Spatrick    // capacity:
11546035553Spatrick    bool      empty()    const noexcept;
11646035553Spatrick    size_type size()     const noexcept;
11746035553Spatrick    size_type max_size() const noexcept;
11846035553Spatrick
11946035553Spatrick    // element access:
12046035553Spatrick    mapped_type& operator[](const key_type& k);
12146035553Spatrick    mapped_type& operator[](key_type&& k);
12246035553Spatrick
12346035553Spatrick          mapped_type& at(const key_type& k);
12446035553Spatrick    const mapped_type& at(const key_type& k) const;
12546035553Spatrick
12646035553Spatrick    // modifiers:
12746035553Spatrick    template <class... Args>
12846035553Spatrick        pair<iterator, bool> emplace(Args&&... args);
12946035553Spatrick    template <class... Args>
13046035553Spatrick        iterator emplace_hint(const_iterator position, Args&&... args);
13146035553Spatrick    pair<iterator, bool> insert(const value_type& v);
13246035553Spatrick    pair<iterator, bool> insert(      value_type&& v);                                // C++17
13346035553Spatrick    template <class P>
13446035553Spatrick        pair<iterator, bool> insert(P&& p);
13546035553Spatrick    iterator insert(const_iterator position, const value_type& v);
13646035553Spatrick    iterator insert(const_iterator position,       value_type&& v);                   // C++17
13746035553Spatrick    template <class P>
13846035553Spatrick        iterator insert(const_iterator position, P&& p);
13946035553Spatrick    template <class InputIterator>
14046035553Spatrick        void insert(InputIterator first, InputIterator last);
14146035553Spatrick    void insert(initializer_list<value_type> il);
14246035553Spatrick
14346035553Spatrick    node_type extract(const_iterator position);                                       // C++17
14446035553Spatrick    node_type extract(const key_type& x);                                             // C++17
14546035553Spatrick    insert_return_type insert(node_type&& nh);                                        // C++17
14646035553Spatrick    iterator insert(const_iterator hint, node_type&& nh);                             // C++17
14746035553Spatrick
14846035553Spatrick    template <class... Args>
14946035553Spatrick        pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);          // C++17
15046035553Spatrick    template <class... Args>
15146035553Spatrick        pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);               // C++17
15246035553Spatrick    template <class... Args>
15346035553Spatrick        iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
15446035553Spatrick    template <class... Args>
15546035553Spatrick        iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);      // C++17
15646035553Spatrick    template <class M>
15746035553Spatrick        pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);            // C++17
15846035553Spatrick    template <class M>
15946035553Spatrick        pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);                 // C++17
16046035553Spatrick    template <class M>
16146035553Spatrick        iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);   // C++17
16246035553Spatrick    template <class M>
16346035553Spatrick        iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);        // C++17
16446035553Spatrick
16546035553Spatrick    iterator  erase(const_iterator position);
16646035553Spatrick    iterator  erase(iterator position); // C++14
16746035553Spatrick    size_type erase(const key_type& k);
16846035553Spatrick    iterator  erase(const_iterator first, const_iterator last);
16946035553Spatrick    void clear() noexcept;
17046035553Spatrick
17146035553Spatrick    template<class C2>
17246035553Spatrick      void merge(map<Key, T, C2, Allocator>& source);         // C++17
17346035553Spatrick    template<class C2>
17446035553Spatrick      void merge(map<Key, T, C2, Allocator>&& source);        // C++17
17546035553Spatrick    template<class C2>
17646035553Spatrick      void merge(multimap<Key, T, C2, Allocator>& source);    // C++17
17746035553Spatrick    template<class C2>
17846035553Spatrick      void merge(multimap<Key, T, C2, Allocator>&& source);   // C++17
17946035553Spatrick
18046035553Spatrick    void swap(map& m)
18146035553Spatrick        noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
18246035553Spatrick            is_nothrow_swappable<key_compare>::value); // C++17
18346035553Spatrick
18446035553Spatrick    // observers:
18546035553Spatrick    allocator_type get_allocator() const noexcept;
18646035553Spatrick    key_compare    key_comp()      const;
18746035553Spatrick    value_compare  value_comp()    const;
18846035553Spatrick
18946035553Spatrick    // map operations:
19046035553Spatrick          iterator find(const key_type& k);
19146035553Spatrick    const_iterator find(const key_type& k) const;
19246035553Spatrick    template<typename K>
19346035553Spatrick        iterator find(const K& x);              // C++14
19446035553Spatrick    template<typename K>
19546035553Spatrick        const_iterator find(const K& x) const;  // C++14
19676d0caaeSpatrick
19746035553Spatrick    template<typename K>
19846035553Spatrick      size_type count(const K& x) const;        // C++14
19946035553Spatrick    size_type      count(const key_type& k) const;
20076d0caaeSpatrick
20146035553Spatrick    bool           contains(const key_type& x) const;  // C++20
20276d0caaeSpatrick    template<class K> bool contains(const K& x) const; // C++20
20376d0caaeSpatrick
20446035553Spatrick          iterator lower_bound(const key_type& k);
20546035553Spatrick    const_iterator lower_bound(const key_type& k) const;
20646035553Spatrick    template<typename K>
20746035553Spatrick        iterator lower_bound(const K& x);              // C++14
20846035553Spatrick    template<typename K>
20946035553Spatrick        const_iterator lower_bound(const K& x) const;  // C++14
21046035553Spatrick
21146035553Spatrick          iterator upper_bound(const key_type& k);
21246035553Spatrick    const_iterator upper_bound(const key_type& k) const;
21346035553Spatrick    template<typename K>
21446035553Spatrick        iterator upper_bound(const K& x);              // C++14
21546035553Spatrick    template<typename K>
21646035553Spatrick        const_iterator upper_bound(const K& x) const;  // C++14
21746035553Spatrick
21846035553Spatrick    pair<iterator,iterator>             equal_range(const key_type& k);
21946035553Spatrick    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
22046035553Spatrick    template<typename K>
22146035553Spatrick        pair<iterator,iterator>             equal_range(const K& x);        // C++14
22246035553Spatrick    template<typename K>
22346035553Spatrick        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
22446035553Spatrick};
22546035553Spatrick
226*4bdff4beSroberttemplate <class InputIterator,
227*4bdff4beSrobert      class Compare = less<iter_key_t<InputIterator>>,
228*4bdff4beSrobert      class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
229*4bdff4beSrobertmap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
230*4bdff4beSrobert  -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17
231*4bdff4beSrobert
232*4bdff4beSroberttemplate<class Key, class T, class Compare = less<Key>,
233*4bdff4beSrobert    class Allocator = allocator<pair<const Key, T>>>
234*4bdff4beSrobertmap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
235*4bdff4beSrobert  -> map<Key, T, Compare, Allocator>; // C++17
236*4bdff4beSrobert
237*4bdff4beSroberttemplate <class InputIterator, class Allocator>
238*4bdff4beSrobertmap(InputIterator, InputIterator, Allocator)
239*4bdff4beSrobert  -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, less<iter_key_t<InputIterator>>,
240*4bdff4beSrobert    Allocator>; // C++17
241*4bdff4beSrobert
242*4bdff4beSroberttemplate<class Key, class T, class Allocator>
243*4bdff4beSrobertmap(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>; // C++17
244*4bdff4beSrobert
24546035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
24646035553Spatrickbool
24746035553Spatrickoperator==(const map<Key, T, Compare, Allocator>& x,
24846035553Spatrick           const map<Key, T, Compare, Allocator>& y);
24946035553Spatrick
25046035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
25146035553Spatrickbool
25246035553Spatrickoperator< (const map<Key, T, Compare, Allocator>& x,
25346035553Spatrick           const map<Key, T, Compare, Allocator>& y);
25446035553Spatrick
25546035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
25646035553Spatrickbool
25746035553Spatrickoperator!=(const map<Key, T, Compare, Allocator>& x,
25846035553Spatrick           const map<Key, T, Compare, Allocator>& y);
25946035553Spatrick
26046035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
26146035553Spatrickbool
26246035553Spatrickoperator> (const map<Key, T, Compare, Allocator>& x,
26346035553Spatrick           const map<Key, T, Compare, Allocator>& y);
26446035553Spatrick
26546035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
26646035553Spatrickbool
26746035553Spatrickoperator>=(const map<Key, T, Compare, Allocator>& x,
26846035553Spatrick           const map<Key, T, Compare, Allocator>& y);
26946035553Spatrick
27046035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
27146035553Spatrickbool
27246035553Spatrickoperator<=(const map<Key, T, Compare, Allocator>& x,
27346035553Spatrick           const map<Key, T, Compare, Allocator>& y);
27446035553Spatrick
27546035553Spatrick// specialized algorithms:
27646035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
27746035553Spatrickvoid
27846035553Spatrickswap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y)
27946035553Spatrick    noexcept(noexcept(x.swap(y)));
28046035553Spatrick
28146035553Spatricktemplate <class Key, class T, class Compare, class Allocator, class Predicate>
282037e7968Spatricktypename map<Key, T, Compare, Allocator>::size_type
283037e7968Spatrickerase_if(map<Key, T, Compare, Allocator>& c, Predicate pred);  // C++20
28446035553Spatrick
28546035553Spatrick
28646035553Spatricktemplate <class Key, class T, class Compare = less<Key>,
28746035553Spatrick          class Allocator = allocator<pair<const Key, T>>>
28846035553Spatrickclass multimap
28946035553Spatrick{
29046035553Spatrickpublic:
29146035553Spatrick    // types:
29246035553Spatrick    typedef Key                                      key_type;
29346035553Spatrick    typedef T                                        mapped_type;
29446035553Spatrick    typedef pair<const key_type,mapped_type>         value_type;
29546035553Spatrick    typedef Compare                                  key_compare;
29646035553Spatrick    typedef Allocator                                allocator_type;
29746035553Spatrick    typedef typename allocator_type::reference       reference;
29846035553Spatrick    typedef typename allocator_type::const_reference const_reference;
29946035553Spatrick    typedef typename allocator_type::size_type       size_type;
30046035553Spatrick    typedef typename allocator_type::difference_type difference_type;
30146035553Spatrick    typedef typename allocator_type::pointer         pointer;
30246035553Spatrick    typedef typename allocator_type::const_pointer   const_pointer;
30346035553Spatrick
30446035553Spatrick    typedef implementation-defined                   iterator;
30546035553Spatrick    typedef implementation-defined                   const_iterator;
30646035553Spatrick    typedef std::reverse_iterator<iterator>          reverse_iterator;
30746035553Spatrick    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
30846035553Spatrick    typedef unspecified                              node_type;              // C++17
30946035553Spatrick
31046035553Spatrick    class value_compare
31146035553Spatrick    {
31246035553Spatrick        friend class multimap;
31346035553Spatrick    protected:
31446035553Spatrick        key_compare comp;
31546035553Spatrick        value_compare(key_compare c);
31646035553Spatrick    public:
31776d0caaeSpatrick        typedef bool result_type;  // deprecated in C++17, removed in C++20
31876d0caaeSpatrick        typedef value_type first_argument_type;  // deprecated in C++17, removed in C++20
31976d0caaeSpatrick        typedef value_type second_argument_type;  // deprecated in C++17, removed in C++20
32046035553Spatrick        bool operator()(const value_type& x, const value_type& y) const;
32146035553Spatrick    };
32246035553Spatrick
32346035553Spatrick    // construct/copy/destroy:
32446035553Spatrick    multimap()
32546035553Spatrick        noexcept(
32646035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
32746035553Spatrick            is_nothrow_default_constructible<key_compare>::value &&
32846035553Spatrick            is_nothrow_copy_constructible<key_compare>::value);
32946035553Spatrick    explicit multimap(const key_compare& comp);
33046035553Spatrick    multimap(const key_compare& comp, const allocator_type& a);
33146035553Spatrick    template <class InputIterator>
33246035553Spatrick        multimap(InputIterator first, InputIterator last, const key_compare& comp);
33346035553Spatrick    template <class InputIterator>
33446035553Spatrick        multimap(InputIterator first, InputIterator last, const key_compare& comp,
33546035553Spatrick                 const allocator_type& a);
33646035553Spatrick    multimap(const multimap& m);
33746035553Spatrick    multimap(multimap&& m)
33846035553Spatrick        noexcept(
33946035553Spatrick            is_nothrow_move_constructible<allocator_type>::value &&
34046035553Spatrick            is_nothrow_move_constructible<key_compare>::value);
34146035553Spatrick    explicit multimap(const allocator_type& a);
34246035553Spatrick    multimap(const multimap& m, const allocator_type& a);
34346035553Spatrick    multimap(multimap&& m, const allocator_type& a);
34446035553Spatrick    multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
34546035553Spatrick    multimap(initializer_list<value_type> il, const key_compare& comp,
34646035553Spatrick             const allocator_type& a);
34746035553Spatrick    template <class InputIterator>
34846035553Spatrick        multimap(InputIterator first, InputIterator last, const allocator_type& a)
34946035553Spatrick            : multimap(first, last, Compare(), a) {} // C++14
35046035553Spatrick    multimap(initializer_list<value_type> il, const allocator_type& a)
35146035553Spatrick        : multimap(il, Compare(), a) {} // C++14
35246035553Spatrick    ~multimap();
35346035553Spatrick
35446035553Spatrick    multimap& operator=(const multimap& m);
35546035553Spatrick    multimap& operator=(multimap&& m)
35646035553Spatrick        noexcept(
35746035553Spatrick            allocator_type::propagate_on_container_move_assignment::value &&
35846035553Spatrick            is_nothrow_move_assignable<allocator_type>::value &&
35946035553Spatrick            is_nothrow_move_assignable<key_compare>::value);
36046035553Spatrick    multimap& operator=(initializer_list<value_type> il);
36146035553Spatrick
36246035553Spatrick    // iterators:
36346035553Spatrick          iterator begin() noexcept;
36446035553Spatrick    const_iterator begin() const noexcept;
36546035553Spatrick          iterator end() noexcept;
36646035553Spatrick    const_iterator end()   const noexcept;
36746035553Spatrick
36846035553Spatrick          reverse_iterator rbegin() noexcept;
36946035553Spatrick    const_reverse_iterator rbegin() const noexcept;
37046035553Spatrick          reverse_iterator rend() noexcept;
37146035553Spatrick    const_reverse_iterator rend()   const noexcept;
37246035553Spatrick
37346035553Spatrick    const_iterator         cbegin()  const noexcept;
37446035553Spatrick    const_iterator         cend()    const noexcept;
37546035553Spatrick    const_reverse_iterator crbegin() const noexcept;
37646035553Spatrick    const_reverse_iterator crend()   const noexcept;
37746035553Spatrick
37846035553Spatrick    // capacity:
37946035553Spatrick    bool      empty()    const noexcept;
38046035553Spatrick    size_type size()     const noexcept;
38146035553Spatrick    size_type max_size() const noexcept;
38246035553Spatrick
38346035553Spatrick    // modifiers:
38446035553Spatrick    template <class... Args>
38546035553Spatrick        iterator emplace(Args&&... args);
38646035553Spatrick    template <class... Args>
38746035553Spatrick        iterator emplace_hint(const_iterator position, Args&&... args);
38846035553Spatrick    iterator insert(const value_type& v);
38946035553Spatrick    iterator insert(      value_type&& v);                                            // C++17
39046035553Spatrick    template <class P>
39146035553Spatrick        iterator insert(P&& p);
39246035553Spatrick    iterator insert(const_iterator position, const value_type& v);
39346035553Spatrick    iterator insert(const_iterator position,       value_type&& v);                   // C++17
39446035553Spatrick    template <class P>
39546035553Spatrick        iterator insert(const_iterator position, P&& p);
39646035553Spatrick    template <class InputIterator>
39746035553Spatrick        void insert(InputIterator first, InputIterator last);
39846035553Spatrick    void insert(initializer_list<value_type> il);
39946035553Spatrick
40046035553Spatrick    node_type extract(const_iterator position);                                       // C++17
40146035553Spatrick    node_type extract(const key_type& x);                                             // C++17
40246035553Spatrick    iterator insert(node_type&& nh);                                                  // C++17
40346035553Spatrick    iterator insert(const_iterator hint, node_type&& nh);                             // C++17
40446035553Spatrick
40546035553Spatrick    iterator  erase(const_iterator position);
40646035553Spatrick    iterator  erase(iterator position); // C++14
40746035553Spatrick    size_type erase(const key_type& k);
40846035553Spatrick    iterator  erase(const_iterator first, const_iterator last);
40946035553Spatrick    void clear() noexcept;
41046035553Spatrick
41146035553Spatrick    template<class C2>
41246035553Spatrick      void merge(multimap<Key, T, C2, Allocator>& source);    // C++17
41346035553Spatrick    template<class C2>
41446035553Spatrick      void merge(multimap<Key, T, C2, Allocator>&& source);   // C++17
41546035553Spatrick    template<class C2>
41646035553Spatrick      void merge(map<Key, T, C2, Allocator>& source);         // C++17
41746035553Spatrick    template<class C2>
41846035553Spatrick      void merge(map<Key, T, C2, Allocator>&& source);        // C++17
41946035553Spatrick
42046035553Spatrick    void swap(multimap& m)
42146035553Spatrick        noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
42246035553Spatrick            is_nothrow_swappable<key_compare>::value); // C++17
42346035553Spatrick
42446035553Spatrick    // observers:
42546035553Spatrick    allocator_type get_allocator() const noexcept;
42646035553Spatrick    key_compare    key_comp()      const;
42746035553Spatrick    value_compare  value_comp()    const;
42846035553Spatrick
42946035553Spatrick    // map operations:
43046035553Spatrick          iterator find(const key_type& k);
43146035553Spatrick    const_iterator find(const key_type& k) const;
43246035553Spatrick    template<typename K>
43346035553Spatrick        iterator find(const K& x);              // C++14
43446035553Spatrick    template<typename K>
43546035553Spatrick        const_iterator find(const K& x) const;  // C++14
43676d0caaeSpatrick
43746035553Spatrick    template<typename K>
43846035553Spatrick      size_type count(const K& x) const;        // C++14
43946035553Spatrick    size_type      count(const key_type& k) const;
44076d0caaeSpatrick
44146035553Spatrick    bool           contains(const key_type& x) const;  // C++20
44276d0caaeSpatrick    template<class K> bool contains(const K& x) const; // C++20
44376d0caaeSpatrick
44446035553Spatrick          iterator lower_bound(const key_type& k);
44546035553Spatrick    const_iterator lower_bound(const key_type& k) const;
44646035553Spatrick    template<typename K>
44746035553Spatrick        iterator lower_bound(const K& x);              // C++14
44846035553Spatrick    template<typename K>
44946035553Spatrick        const_iterator lower_bound(const K& x) const;  // C++14
45046035553Spatrick
45146035553Spatrick          iterator upper_bound(const key_type& k);
45246035553Spatrick    const_iterator upper_bound(const key_type& k) const;
45346035553Spatrick    template<typename K>
45446035553Spatrick        iterator upper_bound(const K& x);              // C++14
45546035553Spatrick    template<typename K>
45646035553Spatrick        const_iterator upper_bound(const K& x) const;  // C++14
45746035553Spatrick
45846035553Spatrick    pair<iterator,iterator>             equal_range(const key_type& k);
45946035553Spatrick    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
46046035553Spatrick    template<typename K>
46146035553Spatrick        pair<iterator,iterator>             equal_range(const K& x);        // C++14
46246035553Spatrick    template<typename K>
46346035553Spatrick        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
46446035553Spatrick};
46546035553Spatrick
466*4bdff4beSroberttemplate <class InputIterator,
467*4bdff4beSrobert      class Compare = less<iter_key_t<InputIterator>>,
468*4bdff4beSrobert      class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
469*4bdff4beSrobertmultimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
470*4bdff4beSrobert  -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17
471*4bdff4beSrobert
472*4bdff4beSroberttemplate<class Key, class T, class Compare = less<Key>,
473*4bdff4beSrobert    class Allocator = allocator<pair<const Key, T>>>
474*4bdff4beSrobertmultimap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
475*4bdff4beSrobert  -> multimap<Key, T, Compare, Allocator>; // C++17
476*4bdff4beSrobert
477*4bdff4beSroberttemplate <class InputIterator, class Allocator>
478*4bdff4beSrobertmultimap(InputIterator, InputIterator, Allocator)
479*4bdff4beSrobert  -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
480*4bdff4beSrobert    less<iter_key_t<InputIterator>>, Allocator>; // C++17
481*4bdff4beSrobert
482*4bdff4beSroberttemplate<class Key, class T, class Allocator>
483*4bdff4beSrobertmultimap(initializer_list<pair<const Key, T>>, Allocator)
484*4bdff4beSrobert  -> multimap<Key, T, less<Key>, Allocator>; // C++17
485*4bdff4beSrobert
48646035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
48746035553Spatrickbool
48846035553Spatrickoperator==(const multimap<Key, T, Compare, Allocator>& x,
48946035553Spatrick           const multimap<Key, T, Compare, Allocator>& y);
49046035553Spatrick
49146035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
49246035553Spatrickbool
49346035553Spatrickoperator< (const multimap<Key, T, Compare, Allocator>& x,
49446035553Spatrick           const multimap<Key, T, Compare, Allocator>& y);
49546035553Spatrick
49646035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
49746035553Spatrickbool
49846035553Spatrickoperator!=(const multimap<Key, T, Compare, Allocator>& x,
49946035553Spatrick           const multimap<Key, T, Compare, Allocator>& y);
50046035553Spatrick
50146035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
50246035553Spatrickbool
50346035553Spatrickoperator> (const multimap<Key, T, Compare, Allocator>& x,
50446035553Spatrick           const multimap<Key, T, Compare, Allocator>& y);
50546035553Spatrick
50646035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
50746035553Spatrickbool
50846035553Spatrickoperator>=(const multimap<Key, T, Compare, Allocator>& x,
50946035553Spatrick           const multimap<Key, T, Compare, Allocator>& y);
51046035553Spatrick
51146035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
51246035553Spatrickbool
51346035553Spatrickoperator<=(const multimap<Key, T, Compare, Allocator>& x,
51446035553Spatrick           const multimap<Key, T, Compare, Allocator>& y);
51546035553Spatrick
51646035553Spatrick// specialized algorithms:
51746035553Spatricktemplate <class Key, class T, class Compare, class Allocator>
51846035553Spatrickvoid
51946035553Spatrickswap(multimap<Key, T, Compare, Allocator>& x,
52046035553Spatrick     multimap<Key, T, Compare, Allocator>& y)
52146035553Spatrick    noexcept(noexcept(x.swap(y)));
52246035553Spatrick
52346035553Spatricktemplate <class Key, class T, class Compare, class Allocator, class Predicate>
524037e7968Spatricktypename multimap<Key, T, Compare, Allocator>::size_type
525037e7968Spatrickerase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred);  // C++20
52646035553Spatrick
52746035553Spatrick}  // std
52846035553Spatrick
52946035553Spatrick*/
53046035553Spatrick
531*4bdff4beSrobert#include <__algorithm/equal.h>
532*4bdff4beSrobert#include <__algorithm/lexicographical_compare.h>
533*4bdff4beSrobert#include <__assert> // all public C++ headers provide the assertion handler
53446035553Spatrick#include <__config>
535*4bdff4beSrobert#include <__functional/binary_function.h>
53676d0caaeSpatrick#include <__functional/is_transparent.h>
537*4bdff4beSrobert#include <__functional/operations.h>
538*4bdff4beSrobert#include <__iterator/erase_if_container.h>
539*4bdff4beSrobert#include <__iterator/iterator_traits.h>
540*4bdff4beSrobert#include <__iterator/reverse_iterator.h>
541*4bdff4beSrobert#include <__memory/allocator.h>
542*4bdff4beSrobert#include <__memory_resource/polymorphic_allocator.h>
54346035553Spatrick#include <__node_handle>
54476d0caaeSpatrick#include <__tree>
545*4bdff4beSrobert#include <__type_traits/is_allocator.h>
54676d0caaeSpatrick#include <__utility/forward.h>
547*4bdff4beSrobert#include <__utility/piecewise_construct.h>
548*4bdff4beSrobert#include <__utility/swap.h>
549*4bdff4beSrobert#include <tuple>
55046035553Spatrick#include <type_traits>
55146035553Spatrick#include <version>
55246035553Spatrick
553*4bdff4beSrobert// standard-mandated includes
554*4bdff4beSrobert
555*4bdff4beSrobert// [iterator.range]
556*4bdff4beSrobert#include <__iterator/access.h>
557*4bdff4beSrobert#include <__iterator/data.h>
558*4bdff4beSrobert#include <__iterator/empty.h>
559*4bdff4beSrobert#include <__iterator/reverse_access.h>
560*4bdff4beSrobert#include <__iterator/size.h>
561*4bdff4beSrobert
562*4bdff4beSrobert// [associative.map.syn]
563*4bdff4beSrobert#include <compare>
564*4bdff4beSrobert#include <initializer_list>
565*4bdff4beSrobert
56646035553Spatrick#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
56746035553Spatrick#  pragma GCC system_header
56846035553Spatrick#endif
56946035553Spatrick
57046035553Spatrick_LIBCPP_BEGIN_NAMESPACE_STD
57146035553Spatrick
57246035553Spatricktemplate <class _Key, class _CP, class _Compare,
57346035553Spatrick          bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
57446035553Spatrickclass __map_value_compare
57546035553Spatrick    : private _Compare
57646035553Spatrick{
57746035553Spatrickpublic:
57846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
57946035553Spatrick    __map_value_compare()
58046035553Spatrick        _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
58146035553Spatrick        : _Compare() {}
58246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
583*4bdff4beSrobert    __map_value_compare(_Compare __c)
58446035553Spatrick        _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
585*4bdff4beSrobert        : _Compare(__c) {}
58646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
58746035553Spatrick    const _Compare& key_comp() const _NOEXCEPT {return *this;}
58846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
58946035553Spatrick    bool operator()(const _CP& __x, const _CP& __y) const
59046035553Spatrick        {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first);}
59146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
59246035553Spatrick    bool operator()(const _CP& __x, const _Key& __y) const
59346035553Spatrick        {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);}
59446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
59546035553Spatrick    bool operator()(const _Key& __x, const _CP& __y) const
59646035553Spatrick        {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);}
59746035553Spatrick    void swap(__map_value_compare& __y)
59846035553Spatrick        _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
59946035553Spatrick    {
60046035553Spatrick      using _VSTD::swap;
60146035553Spatrick      swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y));
60246035553Spatrick    }
60346035553Spatrick
60446035553Spatrick#if _LIBCPP_STD_VER > 11
60546035553Spatrick    template <typename _K2>
60646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
607*4bdff4beSrobert    bool operator()(const _K2& __x, const _CP& __y) const
60846035553Spatrick        {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);}
60946035553Spatrick
61046035553Spatrick    template <typename _K2>
61146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
612*4bdff4beSrobert    bool operator()(const _CP& __x, const _K2& __y) const
61346035553Spatrick        {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);}
61446035553Spatrick#endif
61546035553Spatrick};
61646035553Spatrick
61746035553Spatricktemplate <class _Key, class _CP, class _Compare>
61846035553Spatrickclass __map_value_compare<_Key, _CP, _Compare, false>
61946035553Spatrick{
620*4bdff4beSrobert    _Compare __comp_;
62146035553Spatrick
62246035553Spatrickpublic:
62346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
62446035553Spatrick    __map_value_compare()
62546035553Spatrick        _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
626*4bdff4beSrobert        : __comp_() {}
62746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
628*4bdff4beSrobert    __map_value_compare(_Compare __c)
62946035553Spatrick        _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
630*4bdff4beSrobert        : __comp_(__c) {}
63146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
632*4bdff4beSrobert    const _Compare& key_comp() const _NOEXCEPT {return __comp_;}
63346035553Spatrick
63446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
63546035553Spatrick    bool operator()(const _CP& __x, const _CP& __y) const
636*4bdff4beSrobert        {return __comp_(__x.__get_value().first, __y.__get_value().first);}
63746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
63846035553Spatrick    bool operator()(const _CP& __x, const _Key& __y) const
639*4bdff4beSrobert        {return __comp_(__x.__get_value().first, __y);}
64046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
64146035553Spatrick    bool operator()(const _Key& __x, const _CP& __y) const
642*4bdff4beSrobert        {return __comp_(__x, __y.__get_value().first);}
64346035553Spatrick    void swap(__map_value_compare& __y)
64446035553Spatrick        _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
64546035553Spatrick    {
64646035553Spatrick        using _VSTD::swap;
647*4bdff4beSrobert        swap(__comp_, __y.__comp_);
64846035553Spatrick    }
64946035553Spatrick
65046035553Spatrick#if _LIBCPP_STD_VER > 11
65146035553Spatrick    template <typename _K2>
65246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
653*4bdff4beSrobert    bool operator()(const _K2& __x, const _CP& __y) const
654*4bdff4beSrobert        {return __comp_(__x, __y.__get_value().first);}
65546035553Spatrick
65646035553Spatrick    template <typename _K2>
65746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
658*4bdff4beSrobert    bool operator()(const _CP& __x, const _K2& __y) const
659*4bdff4beSrobert        {return __comp_(__x.__get_value().first, __y);}
66046035553Spatrick#endif
66146035553Spatrick};
66246035553Spatrick
66346035553Spatricktemplate <class _Key, class _CP, class _Compare, bool __b>
66446035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
66546035553Spatrickvoid
66646035553Spatrickswap(__map_value_compare<_Key, _CP, _Compare, __b>& __x,
66746035553Spatrick     __map_value_compare<_Key, _CP, _Compare, __b>& __y)
66846035553Spatrick    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
66946035553Spatrick{
67046035553Spatrick    __x.swap(__y);
67146035553Spatrick}
67246035553Spatrick
67346035553Spatricktemplate <class _Allocator>
67446035553Spatrickclass __map_node_destructor
67546035553Spatrick{
67646035553Spatrick    typedef _Allocator                          allocator_type;
67746035553Spatrick    typedef allocator_traits<allocator_type>    __alloc_traits;
67846035553Spatrick
67946035553Spatrickpublic:
68046035553Spatrick    typedef typename __alloc_traits::pointer    pointer;
68146035553Spatrick
68246035553Spatrickprivate:
68346035553Spatrick    allocator_type& __na_;
68446035553Spatrick
68546035553Spatrick    __map_node_destructor& operator=(const __map_node_destructor&);
68646035553Spatrick
68746035553Spatrickpublic:
68846035553Spatrick    bool __first_constructed;
68946035553Spatrick    bool __second_constructed;
69046035553Spatrick
69146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
69246035553Spatrick    explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT
69346035553Spatrick        : __na_(__na),
69446035553Spatrick          __first_constructed(false),
69546035553Spatrick          __second_constructed(false)
69646035553Spatrick        {}
69746035553Spatrick
69846035553Spatrick#ifndef _LIBCPP_CXX03_LANG
69946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
70046035553Spatrick    __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT
70146035553Spatrick        : __na_(__x.__na_),
70246035553Spatrick          __first_constructed(__x.__value_constructed),
70346035553Spatrick          __second_constructed(__x.__value_constructed)
70446035553Spatrick        {
70546035553Spatrick            __x.__value_constructed = false;
70646035553Spatrick        }
70746035553Spatrick#endif // _LIBCPP_CXX03_LANG
70846035553Spatrick
70946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
71046035553Spatrick    void operator()(pointer __p) _NOEXCEPT
71146035553Spatrick    {
71246035553Spatrick        if (__second_constructed)
71346035553Spatrick            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
71446035553Spatrick        if (__first_constructed)
71546035553Spatrick            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
71646035553Spatrick        if (__p)
71746035553Spatrick            __alloc_traits::deallocate(__na_, __p, 1);
71846035553Spatrick    }
71946035553Spatrick};
72046035553Spatrick
72146035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
72246035553Spatrick    class map;
72346035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
72446035553Spatrick    class multimap;
72546035553Spatricktemplate <class _TreeIterator> class __map_const_iterator;
72646035553Spatrick
72746035553Spatrick#ifndef _LIBCPP_CXX03_LANG
72846035553Spatrick
72946035553Spatricktemplate <class _Key, class _Tp>
73076d0caaeSpatrickstruct _LIBCPP_STANDALONE_DEBUG __value_type
73146035553Spatrick{
73246035553Spatrick    typedef _Key                                     key_type;
73346035553Spatrick    typedef _Tp                                      mapped_type;
73446035553Spatrick    typedef pair<const key_type, mapped_type>        value_type;
73546035553Spatrick    typedef pair<key_type&, mapped_type&>            __nc_ref_pair_type;
73646035553Spatrick    typedef pair<key_type&&, mapped_type&&>          __nc_rref_pair_type;
73746035553Spatrick
73846035553Spatrickprivate:
739*4bdff4beSrobert    value_type __cc_;
74046035553Spatrick
74146035553Spatrickpublic:
74246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
74346035553Spatrick    value_type& __get_value()
74446035553Spatrick    {
74546035553Spatrick#if _LIBCPP_STD_VER > 14
746*4bdff4beSrobert        return *_VSTD::launder(_VSTD::addressof(__cc_));
74746035553Spatrick#else
748*4bdff4beSrobert        return __cc_;
74946035553Spatrick#endif
75046035553Spatrick    }
75146035553Spatrick
75246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
75346035553Spatrick    const value_type& __get_value() const
75446035553Spatrick    {
75546035553Spatrick#if _LIBCPP_STD_VER > 14
756*4bdff4beSrobert        return *_VSTD::launder(_VSTD::addressof(__cc_));
75746035553Spatrick#else
758*4bdff4beSrobert        return __cc_;
75946035553Spatrick#endif
76046035553Spatrick    }
76146035553Spatrick
76246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
76346035553Spatrick    __nc_ref_pair_type __ref()
76446035553Spatrick    {
76546035553Spatrick        value_type& __v = __get_value();
76646035553Spatrick        return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
76746035553Spatrick    }
76846035553Spatrick
76946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
77046035553Spatrick    __nc_rref_pair_type __move()
77146035553Spatrick    {
77246035553Spatrick        value_type& __v = __get_value();
77346035553Spatrick        return __nc_rref_pair_type(
77446035553Spatrick            _VSTD::move(const_cast<key_type&>(__v.first)),
77546035553Spatrick            _VSTD::move(__v.second));
77646035553Spatrick    }
77746035553Spatrick
77846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
77946035553Spatrick    __value_type& operator=(const __value_type& __v)
78046035553Spatrick    {
78146035553Spatrick        __ref() = __v.__get_value();
78246035553Spatrick        return *this;
78346035553Spatrick    }
78446035553Spatrick
78546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
78646035553Spatrick    __value_type& operator=(__value_type&& __v)
78746035553Spatrick    {
78846035553Spatrick        __ref() = __v.__move();
78946035553Spatrick        return *this;
79046035553Spatrick    }
79146035553Spatrick
79246035553Spatrick    template <class _ValueTp,
793*4bdff4beSrobert              class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value>
79446035553Spatrick             >
79546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
79646035553Spatrick    __value_type& operator=(_ValueTp&& __v)
79746035553Spatrick    {
79846035553Spatrick        __ref() = _VSTD::forward<_ValueTp>(__v);
79946035553Spatrick        return *this;
80046035553Spatrick    }
80146035553Spatrick
80246035553Spatrickprivate:
803*4bdff4beSrobert    __value_type() = delete;
804*4bdff4beSrobert    ~__value_type() = delete;
805*4bdff4beSrobert    __value_type(const __value_type&) = delete;
806*4bdff4beSrobert    __value_type(__value_type&&) = delete;
80746035553Spatrick};
80846035553Spatrick
80946035553Spatrick#else
81046035553Spatrick
81146035553Spatricktemplate <class _Key, class _Tp>
81246035553Spatrickstruct __value_type
81346035553Spatrick{
81446035553Spatrick    typedef _Key                                     key_type;
81546035553Spatrick    typedef _Tp                                      mapped_type;
81646035553Spatrick    typedef pair<const key_type, mapped_type>        value_type;
81746035553Spatrick
81846035553Spatrickprivate:
819*4bdff4beSrobert    value_type __cc_;
82046035553Spatrick
82146035553Spatrickpublic:
82246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
823*4bdff4beSrobert    value_type& __get_value() { return __cc_; }
82446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
825*4bdff4beSrobert    const value_type& __get_value() const { return __cc_; }
82646035553Spatrick
82746035553Spatrickprivate:
82846035553Spatrick   __value_type();
82946035553Spatrick   __value_type(__value_type const&);
83046035553Spatrick   __value_type& operator=(__value_type const&);
83146035553Spatrick   ~__value_type();
83246035553Spatrick};
83346035553Spatrick
83446035553Spatrick#endif // _LIBCPP_CXX03_LANG
83546035553Spatrick
83646035553Spatricktemplate <class _Tp>
83746035553Spatrickstruct __extract_key_value_types;
83846035553Spatrick
83946035553Spatricktemplate <class _Key, class _Tp>
84046035553Spatrickstruct __extract_key_value_types<__value_type<_Key, _Tp> >
84146035553Spatrick{
84246035553Spatrick  typedef _Key const __key_type;
84346035553Spatrick  typedef _Tp        __mapped_type;
84446035553Spatrick};
84546035553Spatrick
84646035553Spatricktemplate <class _TreeIterator>
84746035553Spatrickclass _LIBCPP_TEMPLATE_VIS __map_iterator
84846035553Spatrick{
84946035553Spatrick    typedef typename _TreeIterator::_NodeTypes                   _NodeTypes;
85046035553Spatrick    typedef typename _TreeIterator::__pointer_traits             __pointer_traits;
85146035553Spatrick
85246035553Spatrick    _TreeIterator __i_;
85346035553Spatrick
85446035553Spatrickpublic:
85546035553Spatrick    typedef bidirectional_iterator_tag                           iterator_category;
85646035553Spatrick    typedef typename _NodeTypes::__map_value_type                value_type;
85746035553Spatrick    typedef typename _TreeIterator::difference_type              difference_type;
85846035553Spatrick    typedef value_type&                                          reference;
85946035553Spatrick    typedef typename _NodeTypes::__map_value_type_pointer        pointer;
86046035553Spatrick
86146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
86246035553Spatrick    __map_iterator() _NOEXCEPT {}
86346035553Spatrick
86446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
86546035553Spatrick    __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
86646035553Spatrick
86746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
86846035553Spatrick    reference operator*() const {return __i_->__get_value();}
86946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
87046035553Spatrick    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
87146035553Spatrick
87246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
87346035553Spatrick    __map_iterator& operator++() {++__i_; return *this;}
87446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
87546035553Spatrick    __map_iterator operator++(int)
87646035553Spatrick    {
87746035553Spatrick        __map_iterator __t(*this);
87846035553Spatrick        ++(*this);
87946035553Spatrick        return __t;
88046035553Spatrick    }
88146035553Spatrick
88246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
88346035553Spatrick    __map_iterator& operator--() {--__i_; return *this;}
88446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
88546035553Spatrick    __map_iterator operator--(int)
88646035553Spatrick    {
88746035553Spatrick        __map_iterator __t(*this);
88846035553Spatrick        --(*this);
88946035553Spatrick        return __t;
89046035553Spatrick    }
89146035553Spatrick
89246035553Spatrick    friend _LIBCPP_INLINE_VISIBILITY
89346035553Spatrick    bool operator==(const __map_iterator& __x, const __map_iterator& __y)
89446035553Spatrick        {return __x.__i_ == __y.__i_;}
89546035553Spatrick    friend
89646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
89746035553Spatrick    bool operator!=(const __map_iterator& __x, const __map_iterator& __y)
89846035553Spatrick        {return __x.__i_ != __y.__i_;}
89946035553Spatrick
90046035553Spatrick    template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
90146035553Spatrick    template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
90246035553Spatrick    template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
90346035553Spatrick};
90446035553Spatrick
90546035553Spatricktemplate <class _TreeIterator>
90646035553Spatrickclass _LIBCPP_TEMPLATE_VIS __map_const_iterator
90746035553Spatrick{
90846035553Spatrick    typedef typename _TreeIterator::_NodeTypes                   _NodeTypes;
90946035553Spatrick    typedef typename _TreeIterator::__pointer_traits             __pointer_traits;
91046035553Spatrick
91146035553Spatrick    _TreeIterator __i_;
91246035553Spatrick
91346035553Spatrickpublic:
91446035553Spatrick    typedef bidirectional_iterator_tag                           iterator_category;
91546035553Spatrick    typedef typename _NodeTypes::__map_value_type                value_type;
91646035553Spatrick    typedef typename _TreeIterator::difference_type              difference_type;
91746035553Spatrick    typedef const value_type&                                    reference;
91846035553Spatrick    typedef typename _NodeTypes::__const_map_value_type_pointer  pointer;
91946035553Spatrick
92046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
92146035553Spatrick    __map_const_iterator() _NOEXCEPT {}
92246035553Spatrick
92346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
92446035553Spatrick    __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
92546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
92646035553Spatrick    __map_const_iterator(__map_iterator<
92746035553Spatrick        typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT
92846035553Spatrick        : __i_(__i.__i_) {}
92946035553Spatrick
93046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
93146035553Spatrick    reference operator*() const {return __i_->__get_value();}
93246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
93346035553Spatrick    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
93446035553Spatrick
93546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
93646035553Spatrick    __map_const_iterator& operator++() {++__i_; return *this;}
93746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
93846035553Spatrick    __map_const_iterator operator++(int)
93946035553Spatrick    {
94046035553Spatrick        __map_const_iterator __t(*this);
94146035553Spatrick        ++(*this);
94246035553Spatrick        return __t;
94346035553Spatrick    }
94446035553Spatrick
94546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
94646035553Spatrick    __map_const_iterator& operator--() {--__i_; return *this;}
94746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
94846035553Spatrick    __map_const_iterator operator--(int)
94946035553Spatrick    {
95046035553Spatrick        __map_const_iterator __t(*this);
95146035553Spatrick        --(*this);
95246035553Spatrick        return __t;
95346035553Spatrick    }
95446035553Spatrick
95546035553Spatrick    friend _LIBCPP_INLINE_VISIBILITY
95646035553Spatrick    bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y)
95746035553Spatrick        {return __x.__i_ == __y.__i_;}
95846035553Spatrick    friend _LIBCPP_INLINE_VISIBILITY
95946035553Spatrick    bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y)
96046035553Spatrick        {return __x.__i_ != __y.__i_;}
96146035553Spatrick
96246035553Spatrick    template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
96346035553Spatrick    template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
96446035553Spatrick    template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;
96546035553Spatrick};
96646035553Spatrick
96746035553Spatricktemplate <class _Key, class _Tp, class _Compare = less<_Key>,
96846035553Spatrick          class _Allocator = allocator<pair<const _Key, _Tp> > >
96946035553Spatrickclass _LIBCPP_TEMPLATE_VIS map
97046035553Spatrick{
97146035553Spatrickpublic:
97246035553Spatrick    // types:
97346035553Spatrick    typedef _Key                                     key_type;
97446035553Spatrick    typedef _Tp                                      mapped_type;
97546035553Spatrick    typedef pair<const key_type, mapped_type>        value_type;
976*4bdff4beSrobert    typedef __type_identity_t<_Compare>              key_compare;
977*4bdff4beSrobert    typedef __type_identity_t<_Allocator>            allocator_type;
97846035553Spatrick    typedef value_type&                              reference;
97946035553Spatrick    typedef const value_type&                        const_reference;
98046035553Spatrick
98146035553Spatrick    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
98246035553Spatrick                  "Allocator::value_type must be same type as value_type");
98346035553Spatrick
98446035553Spatrick    class _LIBCPP_TEMPLATE_VIS value_compare
985*4bdff4beSrobert        : public __binary_function<value_type, value_type, bool>
98646035553Spatrick    {
98746035553Spatrick        friend class map;
98846035553Spatrick    protected:
98946035553Spatrick        key_compare comp;
99046035553Spatrick
991*4bdff4beSrobert        _LIBCPP_INLINE_VISIBILITY value_compare(key_compare __c) : comp(__c) {}
99246035553Spatrick    public:
99346035553Spatrick        _LIBCPP_INLINE_VISIBILITY
99446035553Spatrick        bool operator()(const value_type& __x, const value_type& __y) const
99546035553Spatrick            {return comp(__x.first, __y.first);}
99646035553Spatrick    };
99746035553Spatrick
99846035553Spatrickprivate:
99946035553Spatrick
100046035553Spatrick    typedef _VSTD::__value_type<key_type, mapped_type>             __value_type;
100146035553Spatrick    typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
1002*4bdff4beSrobert    typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
100346035553Spatrick    typedef __tree<__value_type, __vc, __allocator_type>   __base;
100446035553Spatrick    typedef typename __base::__node_traits                 __node_traits;
100546035553Spatrick    typedef allocator_traits<allocator_type>               __alloc_traits;
100646035553Spatrick
1007*4bdff4beSrobert    static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1008*4bdff4beSrobert                  "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1009*4bdff4beSrobert                  "original allocator");
1010*4bdff4beSrobert
101146035553Spatrick    __base __tree_;
101246035553Spatrick
101346035553Spatrickpublic:
101446035553Spatrick    typedef typename __alloc_traits::pointer               pointer;
101546035553Spatrick    typedef typename __alloc_traits::const_pointer         const_pointer;
101646035553Spatrick    typedef typename __alloc_traits::size_type             size_type;
101746035553Spatrick    typedef typename __alloc_traits::difference_type       difference_type;
101846035553Spatrick    typedef __map_iterator<typename __base::iterator>             iterator;
101946035553Spatrick    typedef __map_const_iterator<typename __base::const_iterator> const_iterator;
102046035553Spatrick    typedef _VSTD::reverse_iterator<iterator>               reverse_iterator;
102146035553Spatrick    typedef _VSTD::reverse_iterator<const_iterator>         const_reverse_iterator;
102246035553Spatrick
102346035553Spatrick#if _LIBCPP_STD_VER > 14
102446035553Spatrick    typedef __map_node_handle<typename __base::__node, allocator_type> node_type;
102546035553Spatrick    typedef __insert_return_type<iterator, node_type> insert_return_type;
102646035553Spatrick#endif
102746035553Spatrick
102846035553Spatrick    template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
102946035553Spatrick        friend class _LIBCPP_TEMPLATE_VIS map;
103046035553Spatrick    template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
103146035553Spatrick        friend class _LIBCPP_TEMPLATE_VIS multimap;
103246035553Spatrick
103346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
103446035553Spatrick    map()
103546035553Spatrick        _NOEXCEPT_(
103646035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
103746035553Spatrick            is_nothrow_default_constructible<key_compare>::value &&
103846035553Spatrick            is_nothrow_copy_constructible<key_compare>::value)
103946035553Spatrick        : __tree_(__vc(key_compare())) {}
104046035553Spatrick
104146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
104246035553Spatrick    explicit map(const key_compare& __comp)
104346035553Spatrick        _NOEXCEPT_(
104446035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
104546035553Spatrick            is_nothrow_copy_constructible<key_compare>::value)
104646035553Spatrick        : __tree_(__vc(__comp)) {}
104746035553Spatrick
104846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
104946035553Spatrick    explicit map(const key_compare& __comp, const allocator_type& __a)
105046035553Spatrick        : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
105146035553Spatrick
105246035553Spatrick    template <class _InputIterator>
105346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
105446035553Spatrick        map(_InputIterator __f, _InputIterator __l,
105546035553Spatrick            const key_compare& __comp = key_compare())
105646035553Spatrick        : __tree_(__vc(__comp))
105746035553Spatrick        {
105846035553Spatrick            insert(__f, __l);
105946035553Spatrick        }
106046035553Spatrick
106146035553Spatrick    template <class _InputIterator>
106246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
106346035553Spatrick        map(_InputIterator __f, _InputIterator __l,
106446035553Spatrick            const key_compare& __comp, const allocator_type& __a)
106546035553Spatrick        : __tree_(__vc(__comp), typename __base::allocator_type(__a))
106646035553Spatrick        {
106746035553Spatrick            insert(__f, __l);
106846035553Spatrick        }
106946035553Spatrick
107046035553Spatrick#if _LIBCPP_STD_VER > 11
107146035553Spatrick    template <class _InputIterator>
107246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
107346035553Spatrick    map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
107446035553Spatrick        : map(__f, __l, key_compare(), __a) {}
107546035553Spatrick#endif
107646035553Spatrick
107746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
107846035553Spatrick    map(const map& __m)
107946035553Spatrick        : __tree_(__m.__tree_)
108046035553Spatrick        {
108146035553Spatrick            insert(__m.begin(), __m.end());
108246035553Spatrick        }
108346035553Spatrick
108446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
108546035553Spatrick    map& operator=(const map& __m)
108646035553Spatrick        {
108746035553Spatrick#ifndef _LIBCPP_CXX03_LANG
108846035553Spatrick            __tree_ = __m.__tree_;
108946035553Spatrick#else
1090*4bdff4beSrobert            if (this != _VSTD::addressof(__m)) {
109146035553Spatrick                __tree_.clear();
109246035553Spatrick                __tree_.value_comp() = __m.__tree_.value_comp();
109346035553Spatrick                __tree_.__copy_assign_alloc(__m.__tree_);
109446035553Spatrick                insert(__m.begin(), __m.end());
109546035553Spatrick            }
109646035553Spatrick#endif
109746035553Spatrick            return *this;
109846035553Spatrick        }
109946035553Spatrick
110046035553Spatrick#ifndef _LIBCPP_CXX03_LANG
110146035553Spatrick
110246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
110346035553Spatrick    map(map&& __m)
110446035553Spatrick        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
110546035553Spatrick        : __tree_(_VSTD::move(__m.__tree_))
110646035553Spatrick        {
110746035553Spatrick        }
110846035553Spatrick
110946035553Spatrick    map(map&& __m, const allocator_type& __a);
111046035553Spatrick
111146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
111246035553Spatrick    map& operator=(map&& __m)
111346035553Spatrick        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
111446035553Spatrick        {
111546035553Spatrick            __tree_ = _VSTD::move(__m.__tree_);
111646035553Spatrick            return *this;
111746035553Spatrick        }
111846035553Spatrick
111946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
112046035553Spatrick    map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
112146035553Spatrick        : __tree_(__vc(__comp))
112246035553Spatrick        {
112346035553Spatrick            insert(__il.begin(), __il.end());
112446035553Spatrick        }
112546035553Spatrick
112646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
112746035553Spatrick    map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
112846035553Spatrick        : __tree_(__vc(__comp), typename __base::allocator_type(__a))
112946035553Spatrick        {
113046035553Spatrick            insert(__il.begin(), __il.end());
113146035553Spatrick        }
113246035553Spatrick
113346035553Spatrick#if _LIBCPP_STD_VER > 11
113446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
113546035553Spatrick    map(initializer_list<value_type> __il, const allocator_type& __a)
113646035553Spatrick        : map(__il, key_compare(), __a) {}
113746035553Spatrick#endif
113846035553Spatrick
113946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
114046035553Spatrick    map& operator=(initializer_list<value_type> __il)
114146035553Spatrick        {
114246035553Spatrick            __tree_.__assign_unique(__il.begin(), __il.end());
114346035553Spatrick            return *this;
114446035553Spatrick        }
114546035553Spatrick
114646035553Spatrick#endif // _LIBCPP_CXX03_LANG
114746035553Spatrick
114846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
114946035553Spatrick    explicit map(const allocator_type& __a)
115046035553Spatrick        : __tree_(typename __base::allocator_type(__a))
115146035553Spatrick        {
115246035553Spatrick        }
115346035553Spatrick
115446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
115546035553Spatrick    map(const map& __m, const allocator_type& __a)
115646035553Spatrick        : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
115746035553Spatrick        {
115846035553Spatrick            insert(__m.begin(), __m.end());
115946035553Spatrick        }
116046035553Spatrick
116146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
116246035553Spatrick    ~map() {
116346035553Spatrick        static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
116446035553Spatrick    }
116546035553Spatrick
116646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
116746035553Spatrick          iterator begin() _NOEXCEPT {return __tree_.begin();}
116846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
116946035553Spatrick    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
117046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
117146035553Spatrick          iterator end() _NOEXCEPT {return __tree_.end();}
117246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
117346035553Spatrick    const_iterator end() const _NOEXCEPT {return __tree_.end();}
117446035553Spatrick
117546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
117646035553Spatrick          reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
117746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
117846035553Spatrick    const_reverse_iterator rbegin() const _NOEXCEPT
117946035553Spatrick        {return const_reverse_iterator(end());}
118046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
118146035553Spatrick          reverse_iterator rend() _NOEXCEPT
118246035553Spatrick            {return       reverse_iterator(begin());}
118346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
118446035553Spatrick    const_reverse_iterator rend() const _NOEXCEPT
118546035553Spatrick        {return const_reverse_iterator(begin());}
118646035553Spatrick
118746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
118846035553Spatrick    const_iterator cbegin() const _NOEXCEPT {return begin();}
118946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
119046035553Spatrick    const_iterator cend() const _NOEXCEPT {return end();}
119146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
119246035553Spatrick    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
119346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
119446035553Spatrick    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
119546035553Spatrick
119646035553Spatrick    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
119746035553Spatrick    bool      empty() const _NOEXCEPT {return __tree_.size() == 0;}
119846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
119946035553Spatrick    size_type size() const _NOEXCEPT {return __tree_.size();}
120046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
120146035553Spatrick    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
120246035553Spatrick
120346035553Spatrick    mapped_type& operator[](const key_type& __k);
120446035553Spatrick#ifndef _LIBCPP_CXX03_LANG
120546035553Spatrick    mapped_type& operator[](key_type&& __k);
120646035553Spatrick#endif
120746035553Spatrick
120846035553Spatrick          mapped_type& at(const key_type& __k);
120946035553Spatrick    const mapped_type& at(const key_type& __k) const;
121046035553Spatrick
121146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
121246035553Spatrick    allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
121346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
121446035553Spatrick    key_compare    key_comp()      const {return __tree_.value_comp().key_comp();}
121546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
121646035553Spatrick    value_compare  value_comp()    const {return value_compare(__tree_.value_comp().key_comp());}
121746035553Spatrick
121846035553Spatrick#ifndef _LIBCPP_CXX03_LANG
121946035553Spatrick    template <class ..._Args>
122046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
122146035553Spatrick    pair<iterator, bool> emplace(_Args&& ...__args) {
122246035553Spatrick        return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
122346035553Spatrick    }
122446035553Spatrick
122546035553Spatrick    template <class ..._Args>
122646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
122746035553Spatrick    iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
122846035553Spatrick        return __tree_.__emplace_hint_unique(__p.__i_, _VSTD::forward<_Args>(__args)...);
122946035553Spatrick    }
123046035553Spatrick
123146035553Spatrick    template <class _Pp,
1232*4bdff4beSrobert              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
123346035553Spatrick        _LIBCPP_INLINE_VISIBILITY
123446035553Spatrick        pair<iterator, bool> insert(_Pp&& __p)
123546035553Spatrick            {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));}
123646035553Spatrick
123746035553Spatrick    template <class _Pp,
1238*4bdff4beSrobert              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
123946035553Spatrick        _LIBCPP_INLINE_VISIBILITY
124046035553Spatrick        iterator insert(const_iterator __pos, _Pp&& __p)
124146035553Spatrick            {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
124246035553Spatrick
124346035553Spatrick#endif // _LIBCPP_CXX03_LANG
124446035553Spatrick
124546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
124646035553Spatrick    pair<iterator, bool>
124746035553Spatrick        insert(const value_type& __v) {return __tree_.__insert_unique(__v);}
124846035553Spatrick
124946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
125046035553Spatrick    iterator
125146035553Spatrick        insert(const_iterator __p, const value_type& __v)
125246035553Spatrick            {return __tree_.__insert_unique(__p.__i_, __v);}
125346035553Spatrick
125446035553Spatrick#ifndef _LIBCPP_CXX03_LANG
125546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
125646035553Spatrick    pair<iterator, bool>
125746035553Spatrick    insert(value_type&& __v) {return __tree_.__insert_unique(_VSTD::move(__v));}
125846035553Spatrick
125946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
126046035553Spatrick    iterator insert(const_iterator __p,  value_type&& __v)
126146035553Spatrick    {return __tree_.__insert_unique(__p.__i_, _VSTD::move(__v));}
126246035553Spatrick
126346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
126446035553Spatrick    void insert(initializer_list<value_type> __il)
126546035553Spatrick        {insert(__il.begin(), __il.end());}
126646035553Spatrick#endif
126746035553Spatrick
126846035553Spatrick    template <class _InputIterator>
126946035553Spatrick        _LIBCPP_INLINE_VISIBILITY
127046035553Spatrick        void insert(_InputIterator __f, _InputIterator __l)
127146035553Spatrick        {
127246035553Spatrick            for (const_iterator __e = cend(); __f != __l; ++__f)
127346035553Spatrick                insert(__e.__i_, *__f);
127446035553Spatrick        }
127546035553Spatrick
127646035553Spatrick#if _LIBCPP_STD_VER > 14
127746035553Spatrick
127846035553Spatrick    template <class... _Args>
127946035553Spatrick        _LIBCPP_INLINE_VISIBILITY
128046035553Spatrick        pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
128146035553Spatrick    {
128246035553Spatrick        return __tree_.__emplace_unique_key_args(__k,
128346035553Spatrick            _VSTD::piecewise_construct,
128446035553Spatrick            _VSTD::forward_as_tuple(__k),
128546035553Spatrick            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
128646035553Spatrick    }
128746035553Spatrick
128846035553Spatrick    template <class... _Args>
128946035553Spatrick        _LIBCPP_INLINE_VISIBILITY
129046035553Spatrick        pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
129146035553Spatrick    {
129246035553Spatrick        return __tree_.__emplace_unique_key_args(__k,
129346035553Spatrick            _VSTD::piecewise_construct,
129446035553Spatrick            _VSTD::forward_as_tuple(_VSTD::move(__k)),
129546035553Spatrick            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
129646035553Spatrick    }
129746035553Spatrick
129846035553Spatrick    template <class... _Args>
129946035553Spatrick        _LIBCPP_INLINE_VISIBILITY
130046035553Spatrick        iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
130146035553Spatrick    {
130246035553Spatrick        return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
130346035553Spatrick            _VSTD::piecewise_construct,
130446035553Spatrick            _VSTD::forward_as_tuple(__k),
130576d0caaeSpatrick            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
130646035553Spatrick    }
130746035553Spatrick
130846035553Spatrick    template <class... _Args>
130946035553Spatrick        _LIBCPP_INLINE_VISIBILITY
131046035553Spatrick        iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
131146035553Spatrick    {
131246035553Spatrick        return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
131346035553Spatrick            _VSTD::piecewise_construct,
131446035553Spatrick            _VSTD::forward_as_tuple(_VSTD::move(__k)),
131576d0caaeSpatrick            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
131646035553Spatrick    }
131746035553Spatrick
131846035553Spatrick    template <class _Vp>
131946035553Spatrick        _LIBCPP_INLINE_VISIBILITY
132046035553Spatrick        pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
132146035553Spatrick    {
132246035553Spatrick        iterator __p = lower_bound(__k);
132346035553Spatrick        if ( __p != end() && !key_comp()(__k, __p->first))
132446035553Spatrick        {
132546035553Spatrick            __p->second = _VSTD::forward<_Vp>(__v);
132646035553Spatrick            return _VSTD::make_pair(__p, false);
132746035553Spatrick        }
132846035553Spatrick        return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
132946035553Spatrick    }
133046035553Spatrick
133146035553Spatrick    template <class _Vp>
133246035553Spatrick        _LIBCPP_INLINE_VISIBILITY
133346035553Spatrick        pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
133446035553Spatrick    {
133546035553Spatrick        iterator __p = lower_bound(__k);
133646035553Spatrick        if ( __p != end() && !key_comp()(__k, __p->first))
133746035553Spatrick        {
133846035553Spatrick            __p->second = _VSTD::forward<_Vp>(__v);
133946035553Spatrick            return _VSTD::make_pair(__p, false);
134046035553Spatrick        }
134146035553Spatrick        return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true);
134246035553Spatrick    }
134346035553Spatrick
134446035553Spatrick    template <class _Vp>
134576d0caaeSpatrick    _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
134676d0caaeSpatrick                                                        const key_type& __k,
134776d0caaeSpatrick                                                        _Vp&& __v) {
134876d0caaeSpatrick      auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
134976d0caaeSpatrick          __h.__i_, __k, __k, _VSTD::forward<_Vp>(__v));
135076d0caaeSpatrick
135176d0caaeSpatrick      if (!__inserted)
135276d0caaeSpatrick        __r->__get_value().second = _VSTD::forward<_Vp>(__v);
135376d0caaeSpatrick
135476d0caaeSpatrick      return __r;
135546035553Spatrick    }
135646035553Spatrick
135746035553Spatrick    template <class _Vp>
135876d0caaeSpatrick    _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
135976d0caaeSpatrick                                                        key_type&& __k,
136076d0caaeSpatrick                                                        _Vp&& __v) {
136176d0caaeSpatrick      auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
136276d0caaeSpatrick          __h.__i_, __k, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
136376d0caaeSpatrick
136476d0caaeSpatrick      if (!__inserted)
136576d0caaeSpatrick        __r->__get_value().second = _VSTD::forward<_Vp>(__v);
136676d0caaeSpatrick
136776d0caaeSpatrick      return __r;
136846035553Spatrick    }
136946035553Spatrick
137046035553Spatrick#endif // _LIBCPP_STD_VER > 14
137146035553Spatrick
137246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
137346035553Spatrick    iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
137446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
137546035553Spatrick    iterator erase(iterator __p)       {return __tree_.erase(__p.__i_);}
137646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
137746035553Spatrick    size_type erase(const key_type& __k)
137846035553Spatrick        {return __tree_.__erase_unique(__k);}
137946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
138046035553Spatrick    iterator  erase(const_iterator __f, const_iterator __l)
138146035553Spatrick        {return __tree_.erase(__f.__i_, __l.__i_);}
138246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
138346035553Spatrick    void clear() _NOEXCEPT {__tree_.clear();}
138446035553Spatrick
138546035553Spatrick#if _LIBCPP_STD_VER > 14
138646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
138746035553Spatrick    insert_return_type insert(node_type&& __nh)
138846035553Spatrick    {
138946035553Spatrick        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
139046035553Spatrick            "node_type with incompatible allocator passed to map::insert()");
139146035553Spatrick        return __tree_.template __node_handle_insert_unique<
139246035553Spatrick            node_type, insert_return_type>(_VSTD::move(__nh));
139346035553Spatrick    }
139446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
139546035553Spatrick    iterator insert(const_iterator __hint, node_type&& __nh)
139646035553Spatrick    {
139746035553Spatrick        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
139846035553Spatrick            "node_type with incompatible allocator passed to map::insert()");
139946035553Spatrick        return __tree_.template __node_handle_insert_unique<node_type>(
140046035553Spatrick            __hint.__i_, _VSTD::move(__nh));
140146035553Spatrick    }
140246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
140346035553Spatrick    node_type extract(key_type const& __key)
140446035553Spatrick    {
140546035553Spatrick        return __tree_.template __node_handle_extract<node_type>(__key);
140646035553Spatrick    }
140746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
140846035553Spatrick    node_type extract(const_iterator __it)
140946035553Spatrick    {
141046035553Spatrick        return __tree_.template __node_handle_extract<node_type>(__it.__i_);
141146035553Spatrick    }
141246035553Spatrick    template <class _Compare2>
141346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
141446035553Spatrick    void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source)
141546035553Spatrick    {
141646035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
141746035553Spatrick                       "merging container with incompatible allocator");
141846035553Spatrick        __tree_.__node_handle_merge_unique(__source.__tree_);
141946035553Spatrick    }
142046035553Spatrick    template <class _Compare2>
142146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
142246035553Spatrick    void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source)
142346035553Spatrick    {
142446035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
142546035553Spatrick                       "merging container with incompatible allocator");
142646035553Spatrick        __tree_.__node_handle_merge_unique(__source.__tree_);
142746035553Spatrick    }
142846035553Spatrick    template <class _Compare2>
142946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
143046035553Spatrick    void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source)
143146035553Spatrick    {
143246035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
143346035553Spatrick                       "merging container with incompatible allocator");
143446035553Spatrick        __tree_.__node_handle_merge_unique(__source.__tree_);
143546035553Spatrick    }
143646035553Spatrick    template <class _Compare2>
143746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
143846035553Spatrick    void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source)
143946035553Spatrick    {
144046035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
144146035553Spatrick                       "merging container with incompatible allocator");
144246035553Spatrick        __tree_.__node_handle_merge_unique(__source.__tree_);
144346035553Spatrick    }
144446035553Spatrick#endif
144546035553Spatrick
144646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
144746035553Spatrick    void swap(map& __m)
144846035553Spatrick        _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
144946035553Spatrick        {__tree_.swap(__m.__tree_);}
145046035553Spatrick
145146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
145246035553Spatrick    iterator find(const key_type& __k)             {return __tree_.find(__k);}
145346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
145446035553Spatrick    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
145546035553Spatrick#if _LIBCPP_STD_VER > 11
145646035553Spatrick    template <typename _K2>
145746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
1458*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
145946035553Spatrick    find(const _K2& __k)                           {return __tree_.find(__k);}
146046035553Spatrick    template <typename _K2>
146146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
1462*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
146346035553Spatrick    find(const _K2& __k) const                     {return __tree_.find(__k);}
146446035553Spatrick#endif
146546035553Spatrick
146646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
146746035553Spatrick    size_type      count(const key_type& __k) const
146846035553Spatrick        {return __tree_.__count_unique(__k);}
146946035553Spatrick#if _LIBCPP_STD_VER > 11
147046035553Spatrick    template <typename _K2>
147146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
1472*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type>
147346035553Spatrick    count(const _K2& __k) const {return __tree_.__count_multi(__k);}
147446035553Spatrick#endif
147546035553Spatrick
147646035553Spatrick#if _LIBCPP_STD_VER > 17
147746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
147846035553Spatrick    bool contains(const key_type& __k) const {return find(__k) != end();}
147976d0caaeSpatrick    template <typename _K2>
148076d0caaeSpatrick    _LIBCPP_INLINE_VISIBILITY
1481*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, bool>
148276d0caaeSpatrick    contains(const _K2& __k) const { return find(__k) != end(); }
148346035553Spatrick#endif // _LIBCPP_STD_VER > 17
148446035553Spatrick
148546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
148646035553Spatrick    iterator lower_bound(const key_type& __k)
148746035553Spatrick        {return __tree_.lower_bound(__k);}
148846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
148946035553Spatrick    const_iterator lower_bound(const key_type& __k) const
149046035553Spatrick        {return __tree_.lower_bound(__k);}
149146035553Spatrick#if _LIBCPP_STD_VER > 11
149246035553Spatrick    template <typename _K2>
149346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
1494*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
149546035553Spatrick    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
149646035553Spatrick
149746035553Spatrick    template <typename _K2>
149846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
1499*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
150046035553Spatrick    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
150146035553Spatrick#endif
150246035553Spatrick
150346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
150446035553Spatrick    iterator upper_bound(const key_type& __k)
150546035553Spatrick        {return __tree_.upper_bound(__k);}
150646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
150746035553Spatrick    const_iterator upper_bound(const key_type& __k) const
150846035553Spatrick        {return __tree_.upper_bound(__k);}
150946035553Spatrick#if _LIBCPP_STD_VER > 11
151046035553Spatrick    template <typename _K2>
151146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
1512*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
151346035553Spatrick    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
151446035553Spatrick    template <typename _K2>
151546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
1516*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
151746035553Spatrick    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
151846035553Spatrick#endif
151946035553Spatrick
152046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
152146035553Spatrick    pair<iterator,iterator> equal_range(const key_type& __k)
152246035553Spatrick        {return __tree_.__equal_range_unique(__k);}
152346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
152446035553Spatrick    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
152546035553Spatrick        {return __tree_.__equal_range_unique(__k);}
152646035553Spatrick#if _LIBCPP_STD_VER > 11
152746035553Spatrick    template <typename _K2>
152846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
1529*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>>
153046035553Spatrick    equal_range(const _K2& __k)       {return __tree_.__equal_range_multi(__k);}
153146035553Spatrick    template <typename _K2>
153246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
1533*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>>
153446035553Spatrick    equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
153546035553Spatrick#endif
153646035553Spatrick
153746035553Spatrickprivate:
153846035553Spatrick    typedef typename __base::__node                    __node;
153946035553Spatrick    typedef typename __base::__node_allocator          __node_allocator;
154046035553Spatrick    typedef typename __base::__node_pointer            __node_pointer;
154146035553Spatrick    typedef typename __base::__node_base_pointer       __node_base_pointer;
154246035553Spatrick    typedef typename __base::__parent_pointer          __parent_pointer;
154346035553Spatrick
154446035553Spatrick    typedef __map_node_destructor<__node_allocator> _Dp;
154546035553Spatrick    typedef unique_ptr<__node, _Dp> __node_holder;
154646035553Spatrick
154746035553Spatrick#ifdef _LIBCPP_CXX03_LANG
154846035553Spatrick    __node_holder __construct_node_with_key(const key_type& __k);
154946035553Spatrick#endif
155046035553Spatrick};
155146035553Spatrick
1552*4bdff4beSrobert#if _LIBCPP_STD_VER >= 17
155346035553Spatricktemplate<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>,
155446035553Spatrick         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
1555*4bdff4beSrobert         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
1556*4bdff4beSrobert         class = enable_if_t<!__is_allocator<_Compare>::value, void>,
1557*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
155846035553Spatrickmap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
155946035553Spatrick  -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
156046035553Spatrick
156146035553Spatricktemplate<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>,
156246035553Spatrick         class _Allocator = allocator<pair<const _Key, _Tp>>,
1563*4bdff4beSrobert         class = enable_if_t<!__is_allocator<_Compare>::value, void>,
1564*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
156546035553Spatrickmap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
156646035553Spatrick  -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
156746035553Spatrick
156846035553Spatricktemplate<class _InputIterator, class _Allocator,
1569*4bdff4beSrobert         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
1570*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
157146035553Spatrickmap(_InputIterator, _InputIterator, _Allocator)
157246035553Spatrick  -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
157346035553Spatrick         less<__iter_key_type<_InputIterator>>, _Allocator>;
157446035553Spatrick
157546035553Spatricktemplate<class _Key, class _Tp, class _Allocator,
1576*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
157746035553Spatrickmap(initializer_list<pair<_Key, _Tp>>, _Allocator)
157846035553Spatrick  -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
157946035553Spatrick#endif
158046035553Spatrick
158146035553Spatrick#ifndef _LIBCPP_CXX03_LANG
158246035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
158346035553Spatrickmap<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
158446035553Spatrick    : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
158546035553Spatrick{
158646035553Spatrick    if (__a != __m.get_allocator())
158746035553Spatrick    {
158846035553Spatrick        const_iterator __e = cend();
158946035553Spatrick        while (!__m.empty())
159046035553Spatrick            __tree_.__insert_unique(__e.__i_,
159146035553Spatrick                    __m.__tree_.remove(__m.begin().__i_)->__value_.__move());
159246035553Spatrick    }
159346035553Spatrick}
159446035553Spatrick
159546035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
159646035553Spatrick_Tp&
159746035553Spatrickmap<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
159846035553Spatrick{
159946035553Spatrick    return __tree_.__emplace_unique_key_args(__k,
160046035553Spatrick        _VSTD::piecewise_construct,
160146035553Spatrick        _VSTD::forward_as_tuple(__k),
160246035553Spatrick        _VSTD::forward_as_tuple()).first->__get_value().second;
160346035553Spatrick}
160446035553Spatrick
160546035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
160646035553Spatrick_Tp&
160746035553Spatrickmap<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k)
160846035553Spatrick{
160946035553Spatrick    return __tree_.__emplace_unique_key_args(__k,
161046035553Spatrick        _VSTD::piecewise_construct,
161146035553Spatrick        _VSTD::forward_as_tuple(_VSTD::move(__k)),
161246035553Spatrick        _VSTD::forward_as_tuple()).first->__get_value().second;
161346035553Spatrick}
161446035553Spatrick
161546035553Spatrick#else // _LIBCPP_CXX03_LANG
161646035553Spatrick
161746035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
161846035553Spatricktypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
161946035553Spatrickmap<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k)
162046035553Spatrick{
162146035553Spatrick    __node_allocator& __na = __tree_.__node_alloc();
162246035553Spatrick    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
162346035553Spatrick    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k);
162446035553Spatrick    __h.get_deleter().__first_constructed = true;
162546035553Spatrick    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
162646035553Spatrick    __h.get_deleter().__second_constructed = true;
162776d0caaeSpatrick    return __h;
162846035553Spatrick}
162946035553Spatrick
163046035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
163146035553Spatrick_Tp&
163246035553Spatrickmap<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
163346035553Spatrick{
163446035553Spatrick    __parent_pointer __parent;
163546035553Spatrick    __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
163646035553Spatrick    __node_pointer __r = static_cast<__node_pointer>(__child);
163746035553Spatrick    if (__child == nullptr)
163846035553Spatrick    {
163946035553Spatrick        __node_holder __h = __construct_node_with_key(__k);
164046035553Spatrick        __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
164146035553Spatrick        __r = __h.release();
164246035553Spatrick    }
164346035553Spatrick    return __r->__value_.__get_value().second;
164446035553Spatrick}
164546035553Spatrick
164646035553Spatrick#endif // _LIBCPP_CXX03_LANG
164746035553Spatrick
164846035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
164946035553Spatrick_Tp&
165046035553Spatrickmap<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
165146035553Spatrick{
165246035553Spatrick    __parent_pointer __parent;
165346035553Spatrick    __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
165446035553Spatrick    if (__child == nullptr)
165546035553Spatrick        __throw_out_of_range("map::at:  key not found");
165646035553Spatrick    return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
165746035553Spatrick}
165846035553Spatrick
165946035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
166046035553Spatrickconst _Tp&
166146035553Spatrickmap<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
166246035553Spatrick{
166346035553Spatrick    __parent_pointer __parent;
166446035553Spatrick    __node_base_pointer __child = __tree_.__find_equal(__parent, __k);
166546035553Spatrick    if (__child == nullptr)
166646035553Spatrick        __throw_out_of_range("map::at:  key not found");
166746035553Spatrick    return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
166846035553Spatrick}
166946035553Spatrick
167046035553Spatrick
167146035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
167246035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
167346035553Spatrickbool
167446035553Spatrickoperator==(const map<_Key, _Tp, _Compare, _Allocator>& __x,
167546035553Spatrick           const map<_Key, _Tp, _Compare, _Allocator>& __y)
167646035553Spatrick{
167746035553Spatrick    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
167846035553Spatrick}
167946035553Spatrick
168046035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
168146035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
168246035553Spatrickbool
168346035553Spatrickoperator< (const map<_Key, _Tp, _Compare, _Allocator>& __x,
168446035553Spatrick           const map<_Key, _Tp, _Compare, _Allocator>& __y)
168546035553Spatrick{
168646035553Spatrick    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
168746035553Spatrick}
168846035553Spatrick
168946035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
169046035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
169146035553Spatrickbool
169246035553Spatrickoperator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
169346035553Spatrick           const map<_Key, _Tp, _Compare, _Allocator>& __y)
169446035553Spatrick{
169546035553Spatrick    return !(__x == __y);
169646035553Spatrick}
169746035553Spatrick
169846035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
169946035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
170046035553Spatrickbool
170146035553Spatrickoperator> (const map<_Key, _Tp, _Compare, _Allocator>& __x,
170246035553Spatrick           const map<_Key, _Tp, _Compare, _Allocator>& __y)
170346035553Spatrick{
170446035553Spatrick    return __y < __x;
170546035553Spatrick}
170646035553Spatrick
170746035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
170846035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
170946035553Spatrickbool
171046035553Spatrickoperator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
171146035553Spatrick           const map<_Key, _Tp, _Compare, _Allocator>& __y)
171246035553Spatrick{
171346035553Spatrick    return !(__x < __y);
171446035553Spatrick}
171546035553Spatrick
171646035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
171746035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
171846035553Spatrickbool
171946035553Spatrickoperator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
172046035553Spatrick           const map<_Key, _Tp, _Compare, _Allocator>& __y)
172146035553Spatrick{
172246035553Spatrick    return !(__y < __x);
172346035553Spatrick}
172446035553Spatrick
172546035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
172646035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
172746035553Spatrickvoid
172846035553Spatrickswap(map<_Key, _Tp, _Compare, _Allocator>& __x,
172946035553Spatrick     map<_Key, _Tp, _Compare, _Allocator>& __y)
173046035553Spatrick    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
173146035553Spatrick{
173246035553Spatrick    __x.swap(__y);
173346035553Spatrick}
173446035553Spatrick
173546035553Spatrick#if _LIBCPP_STD_VER > 17
1736037e7968Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator,
1737037e7968Spatrick          class _Predicate>
173846035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
1739037e7968Spatrick    typename map<_Key, _Tp, _Compare, _Allocator>::size_type
1740037e7968Spatrick    erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {
174176d0caaeSpatrick  return _VSTD::__libcpp_erase_if_container(__c, __pred);
1742037e7968Spatrick}
174346035553Spatrick#endif
174446035553Spatrick
174546035553Spatrick
174646035553Spatricktemplate <class _Key, class _Tp, class _Compare = less<_Key>,
174746035553Spatrick          class _Allocator = allocator<pair<const _Key, _Tp> > >
174846035553Spatrickclass _LIBCPP_TEMPLATE_VIS multimap
174946035553Spatrick{
175046035553Spatrickpublic:
175146035553Spatrick    // types:
175246035553Spatrick    typedef _Key                                     key_type;
175346035553Spatrick    typedef _Tp                                      mapped_type;
175446035553Spatrick    typedef pair<const key_type, mapped_type>        value_type;
1755*4bdff4beSrobert    typedef __type_identity_t<_Compare>              key_compare;
1756*4bdff4beSrobert    typedef __type_identity_t<_Allocator>            allocator_type;
175746035553Spatrick    typedef value_type&                              reference;
175846035553Spatrick    typedef const value_type&                        const_reference;
175946035553Spatrick
176046035553Spatrick    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
176146035553Spatrick                  "Allocator::value_type must be same type as value_type");
176246035553Spatrick
176346035553Spatrick    class _LIBCPP_TEMPLATE_VIS value_compare
1764*4bdff4beSrobert        : public __binary_function<value_type, value_type, bool>
176546035553Spatrick    {
176646035553Spatrick        friend class multimap;
176746035553Spatrick    protected:
176846035553Spatrick        key_compare comp;
176946035553Spatrick
177046035553Spatrick        _LIBCPP_INLINE_VISIBILITY
1771*4bdff4beSrobert        value_compare(key_compare __c) : comp(__c) {}
177246035553Spatrick    public:
177346035553Spatrick        _LIBCPP_INLINE_VISIBILITY
177446035553Spatrick        bool operator()(const value_type& __x, const value_type& __y) const
177546035553Spatrick            {return comp(__x.first, __y.first);}
177646035553Spatrick    };
177746035553Spatrick
177846035553Spatrickprivate:
177946035553Spatrick
178046035553Spatrick    typedef _VSTD::__value_type<key_type, mapped_type>             __value_type;
178146035553Spatrick    typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
1782*4bdff4beSrobert    typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
178346035553Spatrick    typedef __tree<__value_type, __vc, __allocator_type>            __base;
178446035553Spatrick    typedef typename __base::__node_traits                          __node_traits;
178546035553Spatrick    typedef allocator_traits<allocator_type>                        __alloc_traits;
178646035553Spatrick
1787*4bdff4beSrobert    static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1788*4bdff4beSrobert                  "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1789*4bdff4beSrobert                  "original allocator");
1790*4bdff4beSrobert
179146035553Spatrick    __base __tree_;
179246035553Spatrick
179346035553Spatrickpublic:
179446035553Spatrick    typedef typename __alloc_traits::pointer               pointer;
179546035553Spatrick    typedef typename __alloc_traits::const_pointer         const_pointer;
179646035553Spatrick    typedef typename __alloc_traits::size_type             size_type;
179746035553Spatrick    typedef typename __alloc_traits::difference_type       difference_type;
179846035553Spatrick    typedef __map_iterator<typename __base::iterator>      iterator;
179946035553Spatrick    typedef __map_const_iterator<typename __base::const_iterator> const_iterator;
180046035553Spatrick    typedef _VSTD::reverse_iterator<iterator>               reverse_iterator;
180146035553Spatrick    typedef _VSTD::reverse_iterator<const_iterator>         const_reverse_iterator;
180246035553Spatrick
180346035553Spatrick#if _LIBCPP_STD_VER > 14
180446035553Spatrick    typedef __map_node_handle<typename __base::__node, allocator_type> node_type;
180546035553Spatrick#endif
180646035553Spatrick
180746035553Spatrick    template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
180846035553Spatrick        friend class _LIBCPP_TEMPLATE_VIS map;
180946035553Spatrick    template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
181046035553Spatrick        friend class _LIBCPP_TEMPLATE_VIS multimap;
181146035553Spatrick
181246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
181346035553Spatrick    multimap()
181446035553Spatrick        _NOEXCEPT_(
181546035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
181646035553Spatrick            is_nothrow_default_constructible<key_compare>::value &&
181746035553Spatrick            is_nothrow_copy_constructible<key_compare>::value)
181846035553Spatrick        : __tree_(__vc(key_compare())) {}
181946035553Spatrick
182046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
182146035553Spatrick    explicit multimap(const key_compare& __comp)
182246035553Spatrick        _NOEXCEPT_(
182346035553Spatrick            is_nothrow_default_constructible<allocator_type>::value &&
182446035553Spatrick            is_nothrow_copy_constructible<key_compare>::value)
182546035553Spatrick        : __tree_(__vc(__comp)) {}
182646035553Spatrick
182746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
182846035553Spatrick    explicit multimap(const key_compare& __comp, const allocator_type& __a)
182946035553Spatrick        : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
183046035553Spatrick
183146035553Spatrick    template <class _InputIterator>
183246035553Spatrick        _LIBCPP_INLINE_VISIBILITY
183346035553Spatrick        multimap(_InputIterator __f, _InputIterator __l,
183446035553Spatrick            const key_compare& __comp = key_compare())
183546035553Spatrick        : __tree_(__vc(__comp))
183646035553Spatrick        {
183746035553Spatrick            insert(__f, __l);
183846035553Spatrick        }
183946035553Spatrick
184046035553Spatrick    template <class _InputIterator>
184146035553Spatrick        _LIBCPP_INLINE_VISIBILITY
184246035553Spatrick        multimap(_InputIterator __f, _InputIterator __l,
184346035553Spatrick            const key_compare& __comp, const allocator_type& __a)
184446035553Spatrick        : __tree_(__vc(__comp), typename __base::allocator_type(__a))
184546035553Spatrick        {
184646035553Spatrick            insert(__f, __l);
184746035553Spatrick        }
184846035553Spatrick
184946035553Spatrick#if _LIBCPP_STD_VER > 11
185046035553Spatrick    template <class _InputIterator>
185146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
185246035553Spatrick    multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
185346035553Spatrick        : multimap(__f, __l, key_compare(), __a) {}
185446035553Spatrick#endif
185546035553Spatrick
185646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
185746035553Spatrick    multimap(const multimap& __m)
185846035553Spatrick        : __tree_(__m.__tree_.value_comp(),
185946035553Spatrick          __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc()))
186046035553Spatrick        {
186146035553Spatrick            insert(__m.begin(), __m.end());
186246035553Spatrick        }
186346035553Spatrick
186446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
186546035553Spatrick    multimap& operator=(const multimap& __m)
186646035553Spatrick        {
186746035553Spatrick#ifndef _LIBCPP_CXX03_LANG
186846035553Spatrick            __tree_ = __m.__tree_;
186946035553Spatrick#else
1870*4bdff4beSrobert            if (this != _VSTD::addressof(__m)) {
187146035553Spatrick                __tree_.clear();
187246035553Spatrick                __tree_.value_comp() = __m.__tree_.value_comp();
187346035553Spatrick                __tree_.__copy_assign_alloc(__m.__tree_);
187446035553Spatrick                insert(__m.begin(), __m.end());
187546035553Spatrick            }
187646035553Spatrick#endif
187746035553Spatrick            return *this;
187846035553Spatrick        }
187946035553Spatrick
188046035553Spatrick#ifndef _LIBCPP_CXX03_LANG
188146035553Spatrick
188246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
188346035553Spatrick    multimap(multimap&& __m)
188446035553Spatrick        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
188546035553Spatrick        : __tree_(_VSTD::move(__m.__tree_))
188646035553Spatrick        {
188746035553Spatrick        }
188846035553Spatrick
188946035553Spatrick    multimap(multimap&& __m, const allocator_type& __a);
189046035553Spatrick
189146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
189246035553Spatrick    multimap& operator=(multimap&& __m)
189346035553Spatrick        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
189446035553Spatrick        {
189546035553Spatrick            __tree_ = _VSTD::move(__m.__tree_);
189646035553Spatrick            return *this;
189746035553Spatrick        }
189846035553Spatrick
189946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
190046035553Spatrick    multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
190146035553Spatrick        : __tree_(__vc(__comp))
190246035553Spatrick        {
190346035553Spatrick            insert(__il.begin(), __il.end());
190446035553Spatrick        }
190546035553Spatrick
190646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
190746035553Spatrick    multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
190846035553Spatrick        : __tree_(__vc(__comp), typename __base::allocator_type(__a))
190946035553Spatrick        {
191046035553Spatrick            insert(__il.begin(), __il.end());
191146035553Spatrick        }
191246035553Spatrick
191346035553Spatrick#if _LIBCPP_STD_VER > 11
191446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
191546035553Spatrick    multimap(initializer_list<value_type> __il, const allocator_type& __a)
191646035553Spatrick        : multimap(__il, key_compare(), __a) {}
191746035553Spatrick#endif
191846035553Spatrick
191946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
192046035553Spatrick    multimap& operator=(initializer_list<value_type> __il)
192146035553Spatrick        {
192246035553Spatrick            __tree_.__assign_multi(__il.begin(), __il.end());
192346035553Spatrick            return *this;
192446035553Spatrick        }
192546035553Spatrick
192646035553Spatrick#endif // _LIBCPP_CXX03_LANG
192746035553Spatrick
192846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
192946035553Spatrick    explicit multimap(const allocator_type& __a)
193046035553Spatrick        : __tree_(typename __base::allocator_type(__a))
193146035553Spatrick        {
193246035553Spatrick        }
193346035553Spatrick
193446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
193546035553Spatrick    multimap(const multimap& __m, const allocator_type& __a)
193646035553Spatrick        : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
193746035553Spatrick        {
193846035553Spatrick            insert(__m.begin(), __m.end());
193946035553Spatrick        }
194046035553Spatrick
194146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
194246035553Spatrick    ~multimap() {
194346035553Spatrick        static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
194446035553Spatrick    }
194546035553Spatrick
194646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
194746035553Spatrick          iterator begin() _NOEXCEPT {return __tree_.begin();}
194846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
194946035553Spatrick    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
195046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
195146035553Spatrick          iterator end() _NOEXCEPT {return __tree_.end();}
195246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
195346035553Spatrick    const_iterator end() const _NOEXCEPT {return __tree_.end();}
195446035553Spatrick
195546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
195646035553Spatrick          reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
195746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
195846035553Spatrick    const_reverse_iterator rbegin() const _NOEXCEPT
195946035553Spatrick        {return const_reverse_iterator(end());}
196046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
196146035553Spatrick          reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
196246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
196346035553Spatrick    const_reverse_iterator rend() const _NOEXCEPT
196446035553Spatrick        {return const_reverse_iterator(begin());}
196546035553Spatrick
196646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
196746035553Spatrick    const_iterator cbegin()  const _NOEXCEPT {return begin();}
196846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
196946035553Spatrick    const_iterator cend() const _NOEXCEPT {return end();}
197046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
197146035553Spatrick    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
197246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
197346035553Spatrick    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
197446035553Spatrick
197546035553Spatrick    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
197646035553Spatrick    bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
197746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
197846035553Spatrick    size_type size() const _NOEXCEPT {return __tree_.size();}
197946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
198046035553Spatrick    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
198146035553Spatrick
198246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
198346035553Spatrick    allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
198446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
198546035553Spatrick    key_compare    key_comp() const {return __tree_.value_comp().key_comp();}
198646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
198746035553Spatrick    value_compare  value_comp() const
198846035553Spatrick        {return value_compare(__tree_.value_comp().key_comp());}
198946035553Spatrick
199046035553Spatrick#ifndef _LIBCPP_CXX03_LANG
199146035553Spatrick
199246035553Spatrick    template <class ..._Args>
199346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
199446035553Spatrick    iterator emplace(_Args&& ...__args) {
199546035553Spatrick        return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
199646035553Spatrick    }
199746035553Spatrick
199846035553Spatrick    template <class ..._Args>
199946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
200046035553Spatrick    iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
200146035553Spatrick        return __tree_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
200246035553Spatrick    }
200346035553Spatrick
200446035553Spatrick    template <class _Pp,
2005*4bdff4beSrobert              class = __enable_if_t<is_constructible<value_type, _Pp>::value>>
200646035553Spatrick        _LIBCPP_INLINE_VISIBILITY
200746035553Spatrick        iterator insert(_Pp&& __p)
200846035553Spatrick            {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));}
200946035553Spatrick
201046035553Spatrick    template <class _Pp,
2011*4bdff4beSrobert              class = __enable_if_t<is_constructible<value_type, _Pp>::value>>
201246035553Spatrick        _LIBCPP_INLINE_VISIBILITY
201346035553Spatrick        iterator insert(const_iterator __pos, _Pp&& __p)
201446035553Spatrick            {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));}
201546035553Spatrick
201646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
201746035553Spatrick    iterator insert(value_type&& __v)
201846035553Spatrick        {return __tree_.__insert_multi(_VSTD::move(__v));}
201946035553Spatrick
202046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
202146035553Spatrick    iterator insert(const_iterator __p, value_type&& __v)
202246035553Spatrick        {return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));}
202346035553Spatrick
202446035553Spatrick
202546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
202646035553Spatrick    void insert(initializer_list<value_type> __il)
202746035553Spatrick        {insert(__il.begin(), __il.end());}
202846035553Spatrick
202946035553Spatrick#endif // _LIBCPP_CXX03_LANG
203046035553Spatrick
203146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
203246035553Spatrick    iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);}
203346035553Spatrick
203446035553Spatrick    _LIBCPP_INLINE_VISIBILITY
203546035553Spatrick    iterator insert(const_iterator __p, const value_type& __v)
203646035553Spatrick            {return __tree_.__insert_multi(__p.__i_, __v);}
203746035553Spatrick
203846035553Spatrick    template <class _InputIterator>
203946035553Spatrick        _LIBCPP_INLINE_VISIBILITY
204046035553Spatrick        void insert(_InputIterator __f, _InputIterator __l)
204146035553Spatrick        {
204246035553Spatrick            for (const_iterator __e = cend(); __f != __l; ++__f)
204346035553Spatrick                __tree_.__insert_multi(__e.__i_, *__f);
204446035553Spatrick        }
204546035553Spatrick
204646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
204746035553Spatrick    iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
204846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
204946035553Spatrick    iterator erase(iterator __p)       {return __tree_.erase(__p.__i_);}
205046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
205146035553Spatrick    size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
205246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
205346035553Spatrick    iterator  erase(const_iterator __f, const_iterator __l)
205446035553Spatrick        {return __tree_.erase(__f.__i_, __l.__i_);}
205546035553Spatrick
205646035553Spatrick#if _LIBCPP_STD_VER > 14
205746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
205846035553Spatrick    iterator insert(node_type&& __nh)
205946035553Spatrick    {
206046035553Spatrick        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
206146035553Spatrick            "node_type with incompatible allocator passed to multimap::insert()");
206246035553Spatrick        return __tree_.template __node_handle_insert_multi<node_type>(
206346035553Spatrick            _VSTD::move(__nh));
206446035553Spatrick    }
206546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
206646035553Spatrick    iterator insert(const_iterator __hint, node_type&& __nh)
206746035553Spatrick    {
206846035553Spatrick        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
206946035553Spatrick            "node_type with incompatible allocator passed to multimap::insert()");
207046035553Spatrick        return __tree_.template __node_handle_insert_multi<node_type>(
207146035553Spatrick            __hint.__i_, _VSTD::move(__nh));
207246035553Spatrick    }
207346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
207446035553Spatrick    node_type extract(key_type const& __key)
207546035553Spatrick    {
207646035553Spatrick        return __tree_.template __node_handle_extract<node_type>(__key);
207746035553Spatrick    }
207846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
207946035553Spatrick    node_type extract(const_iterator __it)
208046035553Spatrick    {
208146035553Spatrick        return __tree_.template __node_handle_extract<node_type>(
208246035553Spatrick            __it.__i_);
208346035553Spatrick    }
208446035553Spatrick    template <class _Compare2>
208546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
208646035553Spatrick    void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source)
208746035553Spatrick    {
208846035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
208946035553Spatrick                       "merging container with incompatible allocator");
209046035553Spatrick        return __tree_.__node_handle_merge_multi(__source.__tree_);
209146035553Spatrick    }
209246035553Spatrick    template <class _Compare2>
209346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
209446035553Spatrick    void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source)
209546035553Spatrick    {
209646035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
209746035553Spatrick                       "merging container with incompatible allocator");
209846035553Spatrick        return __tree_.__node_handle_merge_multi(__source.__tree_);
209946035553Spatrick    }
210046035553Spatrick    template <class _Compare2>
210146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
210246035553Spatrick    void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source)
210346035553Spatrick    {
210446035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
210546035553Spatrick                       "merging container with incompatible allocator");
210646035553Spatrick        return __tree_.__node_handle_merge_multi(__source.__tree_);
210746035553Spatrick    }
210846035553Spatrick    template <class _Compare2>
210946035553Spatrick    _LIBCPP_INLINE_VISIBILITY
211046035553Spatrick    void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source)
211146035553Spatrick    {
211246035553Spatrick        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
211346035553Spatrick                       "merging container with incompatible allocator");
211446035553Spatrick        return __tree_.__node_handle_merge_multi(__source.__tree_);
211546035553Spatrick    }
211646035553Spatrick#endif
211746035553Spatrick
211846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
211946035553Spatrick    void clear() _NOEXCEPT {__tree_.clear();}
212046035553Spatrick
212146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
212246035553Spatrick    void swap(multimap& __m)
212346035553Spatrick        _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
212446035553Spatrick        {__tree_.swap(__m.__tree_);}
212546035553Spatrick
212646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
212746035553Spatrick    iterator find(const key_type& __k)             {return __tree_.find(__k);}
212846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
212946035553Spatrick    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
213046035553Spatrick#if _LIBCPP_STD_VER > 11
213146035553Spatrick    template <typename _K2>
213246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2133*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
213446035553Spatrick    find(const _K2& __k)                           {return __tree_.find(__k);}
213546035553Spatrick    template <typename _K2>
213646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2137*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
213846035553Spatrick    find(const _K2& __k) const                     {return __tree_.find(__k);}
213946035553Spatrick#endif
214046035553Spatrick
214146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
214246035553Spatrick    size_type      count(const key_type& __k) const
214346035553Spatrick        {return __tree_.__count_multi(__k);}
214446035553Spatrick#if _LIBCPP_STD_VER > 11
214546035553Spatrick    template <typename _K2>
214646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2147*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type>
214846035553Spatrick    count(const _K2& __k) const {return __tree_.__count_multi(__k);}
214946035553Spatrick#endif
215046035553Spatrick
215146035553Spatrick#if _LIBCPP_STD_VER > 17
215246035553Spatrick    _LIBCPP_INLINE_VISIBILITY
215346035553Spatrick    bool contains(const key_type& __k) const {return find(__k) != end();}
215476d0caaeSpatrick    template <typename _K2>
215576d0caaeSpatrick    _LIBCPP_INLINE_VISIBILITY
2156*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, bool>
215776d0caaeSpatrick    contains(const _K2& __k) const { return find(__k) != end(); }
215846035553Spatrick#endif // _LIBCPP_STD_VER > 17
215946035553Spatrick
216046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
216146035553Spatrick    iterator lower_bound(const key_type& __k)
216246035553Spatrick        {return __tree_.lower_bound(__k);}
216346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
216446035553Spatrick    const_iterator lower_bound(const key_type& __k) const
216546035553Spatrick            {return __tree_.lower_bound(__k);}
216646035553Spatrick#if _LIBCPP_STD_VER > 11
216746035553Spatrick    template <typename _K2>
216846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2169*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
217046035553Spatrick    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
217146035553Spatrick
217246035553Spatrick    template <typename _K2>
217346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2174*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
217546035553Spatrick    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
217646035553Spatrick#endif
217746035553Spatrick
217846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
217946035553Spatrick    iterator upper_bound(const key_type& __k)
218046035553Spatrick            {return __tree_.upper_bound(__k);}
218146035553Spatrick    _LIBCPP_INLINE_VISIBILITY
218246035553Spatrick    const_iterator upper_bound(const key_type& __k) const
218346035553Spatrick            {return __tree_.upper_bound(__k);}
218446035553Spatrick#if _LIBCPP_STD_VER > 11
218546035553Spatrick    template <typename _K2>
218646035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2187*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
218846035553Spatrick    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
218946035553Spatrick    template <typename _K2>
219046035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2191*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
219246035553Spatrick    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
219346035553Spatrick#endif
219446035553Spatrick
219546035553Spatrick    _LIBCPP_INLINE_VISIBILITY
219646035553Spatrick    pair<iterator,iterator>             equal_range(const key_type& __k)
219746035553Spatrick            {return __tree_.__equal_range_multi(__k);}
219846035553Spatrick    _LIBCPP_INLINE_VISIBILITY
219946035553Spatrick    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
220046035553Spatrick            {return __tree_.__equal_range_multi(__k);}
220146035553Spatrick#if _LIBCPP_STD_VER > 11
220246035553Spatrick    template <typename _K2>
220346035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2204*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>>
220546035553Spatrick    equal_range(const _K2& __k)       {return __tree_.__equal_range_multi(__k);}
220646035553Spatrick    template <typename _K2>
220746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2208*4bdff4beSrobert    __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>>
220946035553Spatrick    equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
221046035553Spatrick#endif
221146035553Spatrick
221246035553Spatrickprivate:
221346035553Spatrick    typedef typename __base::__node                    __node;
221446035553Spatrick    typedef typename __base::__node_allocator          __node_allocator;
221546035553Spatrick    typedef typename __base::__node_pointer            __node_pointer;
221646035553Spatrick
221746035553Spatrick    typedef __map_node_destructor<__node_allocator> _Dp;
221846035553Spatrick    typedef unique_ptr<__node, _Dp> __node_holder;
221946035553Spatrick};
222046035553Spatrick
2221*4bdff4beSrobert#if _LIBCPP_STD_VER >= 17
222246035553Spatricktemplate<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>,
222346035553Spatrick         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
2224*4bdff4beSrobert         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
2225*4bdff4beSrobert         class = enable_if_t<!__is_allocator<_Compare>::value, void>,
2226*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
222746035553Spatrickmultimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
222846035553Spatrick  -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
222946035553Spatrick
223046035553Spatricktemplate<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>,
223146035553Spatrick         class _Allocator = allocator<pair<const _Key, _Tp>>,
2232*4bdff4beSrobert         class = enable_if_t<!__is_allocator<_Compare>::value, void>,
2233*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
223446035553Spatrickmultimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
223546035553Spatrick  -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
223646035553Spatrick
223746035553Spatricktemplate<class _InputIterator, class _Allocator,
2238*4bdff4beSrobert         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>,
2239*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
224046035553Spatrickmultimap(_InputIterator, _InputIterator, _Allocator)
224146035553Spatrick  -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
224246035553Spatrick         less<__iter_key_type<_InputIterator>>, _Allocator>;
224346035553Spatrick
224446035553Spatricktemplate<class _Key, class _Tp, class _Allocator,
2245*4bdff4beSrobert         class = enable_if_t<__is_allocator<_Allocator>::value, void>>
224646035553Spatrickmultimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
224746035553Spatrick  -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
224846035553Spatrick#endif
224946035553Spatrick
225046035553Spatrick#ifndef _LIBCPP_CXX03_LANG
225146035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
225246035553Spatrickmultimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
225346035553Spatrick    : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
225446035553Spatrick{
225546035553Spatrick    if (__a != __m.get_allocator())
225646035553Spatrick    {
225746035553Spatrick        const_iterator __e = cend();
225846035553Spatrick        while (!__m.empty())
225946035553Spatrick            __tree_.__insert_multi(__e.__i_,
226046035553Spatrick                    _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move()));
226146035553Spatrick    }
226246035553Spatrick}
226346035553Spatrick#endif
226446035553Spatrick
226546035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
226646035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
226746035553Spatrickbool
226846035553Spatrickoperator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
226946035553Spatrick           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
227046035553Spatrick{
227146035553Spatrick    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
227246035553Spatrick}
227346035553Spatrick
227446035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
227546035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
227646035553Spatrickbool
227746035553Spatrickoperator< (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
227846035553Spatrick           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
227946035553Spatrick{
228046035553Spatrick    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
228146035553Spatrick}
228246035553Spatrick
228346035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
228446035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
228546035553Spatrickbool
228646035553Spatrickoperator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
228746035553Spatrick           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
228846035553Spatrick{
228946035553Spatrick    return !(__x == __y);
229046035553Spatrick}
229146035553Spatrick
229246035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
229346035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
229446035553Spatrickbool
229546035553Spatrickoperator> (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
229646035553Spatrick           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
229746035553Spatrick{
229846035553Spatrick    return __y < __x;
229946035553Spatrick}
230046035553Spatrick
230146035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
230246035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
230346035553Spatrickbool
230446035553Spatrickoperator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
230546035553Spatrick           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
230646035553Spatrick{
230746035553Spatrick    return !(__x < __y);
230846035553Spatrick}
230946035553Spatrick
231046035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
231146035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
231246035553Spatrickbool
231346035553Spatrickoperator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
231446035553Spatrick           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
231546035553Spatrick{
231646035553Spatrick    return !(__y < __x);
231746035553Spatrick}
231846035553Spatrick
231946035553Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator>
232046035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
232146035553Spatrickvoid
232246035553Spatrickswap(multimap<_Key, _Tp, _Compare, _Allocator>& __x,
232346035553Spatrick     multimap<_Key, _Tp, _Compare, _Allocator>& __y)
232446035553Spatrick    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
232546035553Spatrick{
232646035553Spatrick    __x.swap(__y);
232746035553Spatrick}
232846035553Spatrick
232946035553Spatrick#if _LIBCPP_STD_VER > 17
2330037e7968Spatricktemplate <class _Key, class _Tp, class _Compare, class _Allocator,
2331037e7968Spatrick          class _Predicate>
233246035553Spatrickinline _LIBCPP_INLINE_VISIBILITY
2333037e7968Spatrick    typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type
2334037e7968Spatrick    erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c,
2335037e7968Spatrick             _Predicate __pred) {
233676d0caaeSpatrick  return _VSTD::__libcpp_erase_if_container(__c, __pred);
2337037e7968Spatrick}
233846035553Spatrick#endif
233946035553Spatrick
234046035553Spatrick_LIBCPP_END_NAMESPACE_STD
234146035553Spatrick
2342*4bdff4beSrobert#if _LIBCPP_STD_VER > 14
2343*4bdff4beSrobert_LIBCPP_BEGIN_NAMESPACE_STD
2344*4bdff4beSrobertnamespace pmr {
2345*4bdff4beSroberttemplate <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>
2346*4bdff4beSrobertusing map = std::map<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2347*4bdff4beSrobert
2348*4bdff4beSroberttemplate <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>
2349*4bdff4beSrobertusing multimap = std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2350*4bdff4beSrobert} // namespace pmr
2351*4bdff4beSrobert_LIBCPP_END_NAMESPACE_STD
2352*4bdff4beSrobert#endif
2353*4bdff4beSrobert
2354*4bdff4beSrobert#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2355*4bdff4beSrobert#  include <concepts>
2356*4bdff4beSrobert#  include <functional>
2357*4bdff4beSrobert#  include <iterator>
2358*4bdff4beSrobert#  include <utility>
2359*4bdff4beSrobert#endif
2360*4bdff4beSrobert
236146035553Spatrick#endif // _LIBCPP_MAP
2362