xref: /freebsd/contrib/llvm-project/libcxx/include/map (revision fe6060f10f634930ff71b7c50291ddc610da2475)
10b57cec5SDimitry Andric// -*- C++ -*-
20b57cec5SDimitry Andric//===----------------------------- map ------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_MAP
110b57cec5SDimitry Andric#define _LIBCPP_MAP
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric
150b57cec5SDimitry Andric    map synopsis
160b57cec5SDimitry Andric
170b57cec5SDimitry Andricnamespace std
180b57cec5SDimitry Andric{
190b57cec5SDimitry Andric
200b57cec5SDimitry Andrictemplate <class Key, class T, class Compare = less<Key>,
210b57cec5SDimitry Andric          class Allocator = allocator<pair<const Key, T>>>
220b57cec5SDimitry Andricclass map
230b57cec5SDimitry Andric{
240b57cec5SDimitry Andricpublic:
250b57cec5SDimitry Andric    // types:
260b57cec5SDimitry Andric    typedef Key                                      key_type;
270b57cec5SDimitry Andric    typedef T                                        mapped_type;
280b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
290b57cec5SDimitry Andric    typedef Compare                                  key_compare;
300b57cec5SDimitry Andric    typedef Allocator                                allocator_type;
310b57cec5SDimitry Andric    typedef typename allocator_type::reference       reference;
320b57cec5SDimitry Andric    typedef typename allocator_type::const_reference const_reference;
330b57cec5SDimitry Andric    typedef typename allocator_type::pointer         pointer;
340b57cec5SDimitry Andric    typedef typename allocator_type::const_pointer   const_pointer;
350b57cec5SDimitry Andric    typedef typename allocator_type::size_type       size_type;
360b57cec5SDimitry Andric    typedef typename allocator_type::difference_type difference_type;
370b57cec5SDimitry Andric
380b57cec5SDimitry Andric    typedef implementation-defined                   iterator;
390b57cec5SDimitry Andric    typedef implementation-defined                   const_iterator;
400b57cec5SDimitry Andric    typedef std::reverse_iterator<iterator>          reverse_iterator;
410b57cec5SDimitry Andric    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
420b57cec5SDimitry Andric    typedef unspecified                              node_type;              // C++17
430b57cec5SDimitry Andric    typedef INSERT_RETURN_TYPE<iterator, node_type>  insert_return_type;     // C++17
440b57cec5SDimitry Andric
450b57cec5SDimitry Andric    class value_compare
460b57cec5SDimitry Andric    {
470b57cec5SDimitry Andric        friend class map;
480b57cec5SDimitry Andric    protected:
490b57cec5SDimitry Andric        key_compare comp;
500b57cec5SDimitry Andric
510b57cec5SDimitry Andric        value_compare(key_compare c);
520b57cec5SDimitry Andric    public:
53*fe6060f1SDimitry Andric        typedef bool result_type;  // deprecated in C++17, removed in C++20
54*fe6060f1SDimitry Andric        typedef value_type first_argument_type;  // deprecated in C++17, removed in C++20
55*fe6060f1SDimitry Andric        typedef value_type second_argument_type;  // deprecated in C++17, removed in C++20
560b57cec5SDimitry Andric        bool operator()(const value_type& x, const value_type& y) const;
570b57cec5SDimitry Andric    };
580b57cec5SDimitry Andric
590b57cec5SDimitry Andric    // construct/copy/destroy:
600b57cec5SDimitry Andric    map()
610b57cec5SDimitry Andric        noexcept(
620b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value &&
630b57cec5SDimitry Andric            is_nothrow_default_constructible<key_compare>::value &&
640b57cec5SDimitry Andric            is_nothrow_copy_constructible<key_compare>::value);
650b57cec5SDimitry Andric    explicit map(const key_compare& comp);
660b57cec5SDimitry Andric    map(const key_compare& comp, const allocator_type& a);
670b57cec5SDimitry Andric    template <class InputIterator>
680b57cec5SDimitry Andric        map(InputIterator first, InputIterator last,
690b57cec5SDimitry Andric            const key_compare& comp = key_compare());
700b57cec5SDimitry Andric    template <class InputIterator>
710b57cec5SDimitry Andric        map(InputIterator first, InputIterator last,
720b57cec5SDimitry Andric            const key_compare& comp, const allocator_type& a);
730b57cec5SDimitry Andric    map(const map& m);
740b57cec5SDimitry Andric    map(map&& m)
750b57cec5SDimitry Andric        noexcept(
760b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value &&
770b57cec5SDimitry Andric            is_nothrow_move_constructible<key_compare>::value);
780b57cec5SDimitry Andric    explicit map(const allocator_type& a);
790b57cec5SDimitry Andric    map(const map& m, const allocator_type& a);
800b57cec5SDimitry Andric    map(map&& m, const allocator_type& a);
810b57cec5SDimitry Andric    map(initializer_list<value_type> il, const key_compare& comp = key_compare());
820b57cec5SDimitry Andric    map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
830b57cec5SDimitry Andric    template <class InputIterator>
840b57cec5SDimitry Andric        map(InputIterator first, InputIterator last, const allocator_type& a)
850b57cec5SDimitry Andric            : map(first, last, Compare(), a) {}  // C++14
860b57cec5SDimitry Andric    map(initializer_list<value_type> il, const allocator_type& a)
870b57cec5SDimitry Andric        : map(il, Compare(), a) {}  // C++14
880b57cec5SDimitry Andric   ~map();
890b57cec5SDimitry Andric
900b57cec5SDimitry Andric    map& operator=(const map& m);
910b57cec5SDimitry Andric    map& operator=(map&& m)
920b57cec5SDimitry Andric        noexcept(
930b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
940b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
950b57cec5SDimitry Andric            is_nothrow_move_assignable<key_compare>::value);
960b57cec5SDimitry Andric    map& operator=(initializer_list<value_type> il);
970b57cec5SDimitry Andric
980b57cec5SDimitry Andric    // iterators:
990b57cec5SDimitry Andric          iterator begin() noexcept;
1000b57cec5SDimitry Andric    const_iterator begin() const noexcept;
1010b57cec5SDimitry Andric          iterator end() noexcept;
1020b57cec5SDimitry Andric    const_iterator end()   const noexcept;
1030b57cec5SDimitry Andric
1040b57cec5SDimitry Andric          reverse_iterator rbegin() noexcept;
1050b57cec5SDimitry Andric    const_reverse_iterator rbegin() const noexcept;
1060b57cec5SDimitry Andric          reverse_iterator rend() noexcept;
1070b57cec5SDimitry Andric    const_reverse_iterator rend()   const noexcept;
1080b57cec5SDimitry Andric
1090b57cec5SDimitry Andric    const_iterator         cbegin()  const noexcept;
1100b57cec5SDimitry Andric    const_iterator         cend()    const noexcept;
1110b57cec5SDimitry Andric    const_reverse_iterator crbegin() const noexcept;
1120b57cec5SDimitry Andric    const_reverse_iterator crend()   const noexcept;
1130b57cec5SDimitry Andric
1140b57cec5SDimitry Andric    // capacity:
1150b57cec5SDimitry Andric    bool      empty()    const noexcept;
1160b57cec5SDimitry Andric    size_type size()     const noexcept;
1170b57cec5SDimitry Andric    size_type max_size() const noexcept;
1180b57cec5SDimitry Andric
1190b57cec5SDimitry Andric    // element access:
1200b57cec5SDimitry Andric    mapped_type& operator[](const key_type& k);
1210b57cec5SDimitry Andric    mapped_type& operator[](key_type&& k);
1220b57cec5SDimitry Andric
1230b57cec5SDimitry Andric          mapped_type& at(const key_type& k);
1240b57cec5SDimitry Andric    const mapped_type& at(const key_type& k) const;
1250b57cec5SDimitry Andric
1260b57cec5SDimitry Andric    // modifiers:
1270b57cec5SDimitry Andric    template <class... Args>
1280b57cec5SDimitry Andric        pair<iterator, bool> emplace(Args&&... args);
1290b57cec5SDimitry Andric    template <class... Args>
1300b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
1310b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& v);
1320b57cec5SDimitry Andric    pair<iterator, bool> insert(      value_type&& v);                                // C++17
1330b57cec5SDimitry Andric    template <class P>
1340b57cec5SDimitry Andric        pair<iterator, bool> insert(P&& p);
1350b57cec5SDimitry Andric    iterator insert(const_iterator position, const value_type& v);
1360b57cec5SDimitry Andric    iterator insert(const_iterator position,       value_type&& v);                   // C++17
1370b57cec5SDimitry Andric    template <class P>
1380b57cec5SDimitry Andric        iterator insert(const_iterator position, P&& p);
1390b57cec5SDimitry Andric    template <class InputIterator>
1400b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
1410b57cec5SDimitry Andric    void insert(initializer_list<value_type> il);
1420b57cec5SDimitry Andric
1430b57cec5SDimitry Andric    node_type extract(const_iterator position);                                       // C++17
1440b57cec5SDimitry Andric    node_type extract(const key_type& x);                                             // C++17
1450b57cec5SDimitry Andric    insert_return_type insert(node_type&& nh);                                        // C++17
1460b57cec5SDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);                             // C++17
1470b57cec5SDimitry Andric
1480b57cec5SDimitry Andric    template <class... Args>
1490b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);          // C++17
1500b57cec5SDimitry Andric    template <class... Args>
1510b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);               // C++17
1520b57cec5SDimitry Andric    template <class... Args>
1530b57cec5SDimitry Andric        iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
1540b57cec5SDimitry Andric    template <class... Args>
1550b57cec5SDimitry Andric        iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);      // C++17
1560b57cec5SDimitry Andric    template <class M>
1570b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);            // C++17
1580b57cec5SDimitry Andric    template <class M>
1590b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);                 // C++17
1600b57cec5SDimitry Andric    template <class M>
1610b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);   // C++17
1620b57cec5SDimitry Andric    template <class M>
1630b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);        // C++17
1640b57cec5SDimitry Andric
1650b57cec5SDimitry Andric    iterator  erase(const_iterator position);
1660b57cec5SDimitry Andric    iterator  erase(iterator position); // C++14
1670b57cec5SDimitry Andric    size_type erase(const key_type& k);
1680b57cec5SDimitry Andric    iterator  erase(const_iterator first, const_iterator last);
1690b57cec5SDimitry Andric    void clear() noexcept;
1700b57cec5SDimitry Andric
1710b57cec5SDimitry Andric    template<class C2>
1720b57cec5SDimitry Andric      void merge(map<Key, T, C2, Allocator>& source);         // C++17
1730b57cec5SDimitry Andric    template<class C2>
1740b57cec5SDimitry Andric      void merge(map<Key, T, C2, Allocator>&& source);        // C++17
1750b57cec5SDimitry Andric    template<class C2>
1760b57cec5SDimitry Andric      void merge(multimap<Key, T, C2, Allocator>& source);    // C++17
1770b57cec5SDimitry Andric    template<class C2>
1780b57cec5SDimitry Andric      void merge(multimap<Key, T, C2, Allocator>&& source);   // C++17
1790b57cec5SDimitry Andric
1800b57cec5SDimitry Andric    void swap(map& m)
1810b57cec5SDimitry Andric        noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
1820b57cec5SDimitry Andric            is_nothrow_swappable<key_compare>::value); // C++17
1830b57cec5SDimitry Andric
1840b57cec5SDimitry Andric    // observers:
1850b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
1860b57cec5SDimitry Andric    key_compare    key_comp()      const;
1870b57cec5SDimitry Andric    value_compare  value_comp()    const;
1880b57cec5SDimitry Andric
1890b57cec5SDimitry Andric    // map operations:
1900b57cec5SDimitry Andric          iterator find(const key_type& k);
1910b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
1920b57cec5SDimitry Andric    template<typename K>
1930b57cec5SDimitry Andric        iterator find(const K& x);              // C++14
1940b57cec5SDimitry Andric    template<typename K>
1950b57cec5SDimitry Andric        const_iterator find(const K& x) const;  // C++14
196*fe6060f1SDimitry Andric
1970b57cec5SDimitry Andric    template<typename K>
1980b57cec5SDimitry Andric      size_type count(const K& x) const;        // C++14
1990b57cec5SDimitry Andric    size_type      count(const key_type& k) const;
200*fe6060f1SDimitry Andric
2010b57cec5SDimitry Andric    bool           contains(const key_type& x) const;  // C++20
202*fe6060f1SDimitry Andric    template<class K> bool contains(const K& x) const; // C++20
203*fe6060f1SDimitry Andric
2040b57cec5SDimitry Andric          iterator lower_bound(const key_type& k);
2050b57cec5SDimitry Andric    const_iterator lower_bound(const key_type& k) const;
2060b57cec5SDimitry Andric    template<typename K>
2070b57cec5SDimitry Andric        iterator lower_bound(const K& x);              // C++14
2080b57cec5SDimitry Andric    template<typename K>
2090b57cec5SDimitry Andric        const_iterator lower_bound(const K& x) const;  // C++14
2100b57cec5SDimitry Andric
2110b57cec5SDimitry Andric          iterator upper_bound(const key_type& k);
2120b57cec5SDimitry Andric    const_iterator upper_bound(const key_type& k) const;
2130b57cec5SDimitry Andric    template<typename K>
2140b57cec5SDimitry Andric        iterator upper_bound(const K& x);              // C++14
2150b57cec5SDimitry Andric    template<typename K>
2160b57cec5SDimitry Andric        const_iterator upper_bound(const K& x) const;  // C++14
2170b57cec5SDimitry Andric
2180b57cec5SDimitry Andric    pair<iterator,iterator>             equal_range(const key_type& k);
2190b57cec5SDimitry Andric    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
2200b57cec5SDimitry Andric    template<typename K>
2210b57cec5SDimitry Andric        pair<iterator,iterator>             equal_range(const K& x);        // C++14
2220b57cec5SDimitry Andric    template<typename K>
2230b57cec5SDimitry Andric        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
2240b57cec5SDimitry Andric};
2250b57cec5SDimitry Andric
2260b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
2270b57cec5SDimitry Andricbool
2280b57cec5SDimitry Andricoperator==(const map<Key, T, Compare, Allocator>& x,
2290b57cec5SDimitry Andric           const map<Key, T, Compare, Allocator>& y);
2300b57cec5SDimitry Andric
2310b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
2320b57cec5SDimitry Andricbool
2330b57cec5SDimitry Andricoperator< (const map<Key, T, Compare, Allocator>& x,
2340b57cec5SDimitry Andric           const map<Key, T, Compare, Allocator>& y);
2350b57cec5SDimitry Andric
2360b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
2370b57cec5SDimitry Andricbool
2380b57cec5SDimitry Andricoperator!=(const map<Key, T, Compare, Allocator>& x,
2390b57cec5SDimitry Andric           const map<Key, T, Compare, Allocator>& y);
2400b57cec5SDimitry Andric
2410b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
2420b57cec5SDimitry Andricbool
2430b57cec5SDimitry Andricoperator> (const map<Key, T, Compare, Allocator>& x,
2440b57cec5SDimitry Andric           const map<Key, T, Compare, Allocator>& y);
2450b57cec5SDimitry Andric
2460b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
2470b57cec5SDimitry Andricbool
2480b57cec5SDimitry Andricoperator>=(const map<Key, T, Compare, Allocator>& x,
2490b57cec5SDimitry Andric           const map<Key, T, Compare, Allocator>& y);
2500b57cec5SDimitry Andric
2510b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
2520b57cec5SDimitry Andricbool
2530b57cec5SDimitry Andricoperator<=(const map<Key, T, Compare, Allocator>& x,
2540b57cec5SDimitry Andric           const map<Key, T, Compare, Allocator>& y);
2550b57cec5SDimitry Andric
2560b57cec5SDimitry Andric// specialized algorithms:
2570b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
2580b57cec5SDimitry Andricvoid
2590b57cec5SDimitry Andricswap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y)
2600b57cec5SDimitry Andric    noexcept(noexcept(x.swap(y)));
2610b57cec5SDimitry Andric
2620b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator, class Predicate>
2635ffd83dbSDimitry Andrictypename map<Key, T, Compare, Allocator>::size_type
2645ffd83dbSDimitry Andricerase_if(map<Key, T, Compare, Allocator>& c, Predicate pred);  // C++20
2650b57cec5SDimitry Andric
2660b57cec5SDimitry Andric
2670b57cec5SDimitry Andrictemplate <class Key, class T, class Compare = less<Key>,
2680b57cec5SDimitry Andric          class Allocator = allocator<pair<const Key, T>>>
2690b57cec5SDimitry Andricclass multimap
2700b57cec5SDimitry Andric{
2710b57cec5SDimitry Andricpublic:
2720b57cec5SDimitry Andric    // types:
2730b57cec5SDimitry Andric    typedef Key                                      key_type;
2740b57cec5SDimitry Andric    typedef T                                        mapped_type;
2750b57cec5SDimitry Andric    typedef pair<const key_type,mapped_type>         value_type;
2760b57cec5SDimitry Andric    typedef Compare                                  key_compare;
2770b57cec5SDimitry Andric    typedef Allocator                                allocator_type;
2780b57cec5SDimitry Andric    typedef typename allocator_type::reference       reference;
2790b57cec5SDimitry Andric    typedef typename allocator_type::const_reference const_reference;
2800b57cec5SDimitry Andric    typedef typename allocator_type::size_type       size_type;
2810b57cec5SDimitry Andric    typedef typename allocator_type::difference_type difference_type;
2820b57cec5SDimitry Andric    typedef typename allocator_type::pointer         pointer;
2830b57cec5SDimitry Andric    typedef typename allocator_type::const_pointer   const_pointer;
2840b57cec5SDimitry Andric
2850b57cec5SDimitry Andric    typedef implementation-defined                   iterator;
2860b57cec5SDimitry Andric    typedef implementation-defined                   const_iterator;
2870b57cec5SDimitry Andric    typedef std::reverse_iterator<iterator>          reverse_iterator;
2880b57cec5SDimitry Andric    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
2890b57cec5SDimitry Andric    typedef unspecified                              node_type;              // C++17
2900b57cec5SDimitry Andric
2910b57cec5SDimitry Andric    class value_compare
2920b57cec5SDimitry Andric    {
2930b57cec5SDimitry Andric        friend class multimap;
2940b57cec5SDimitry Andric    protected:
2950b57cec5SDimitry Andric        key_compare comp;
2960b57cec5SDimitry Andric        value_compare(key_compare c);
2970b57cec5SDimitry Andric    public:
298*fe6060f1SDimitry Andric        typedef bool result_type;  // deprecated in C++17, removed in C++20
299*fe6060f1SDimitry Andric        typedef value_type first_argument_type;  // deprecated in C++17, removed in C++20
300*fe6060f1SDimitry Andric        typedef value_type second_argument_type;  // deprecated in C++17, removed in C++20
3010b57cec5SDimitry Andric        bool operator()(const value_type& x, const value_type& y) const;
3020b57cec5SDimitry Andric    };
3030b57cec5SDimitry Andric
3040b57cec5SDimitry Andric    // construct/copy/destroy:
3050b57cec5SDimitry Andric    multimap()
3060b57cec5SDimitry Andric        noexcept(
3070b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value &&
3080b57cec5SDimitry Andric            is_nothrow_default_constructible<key_compare>::value &&
3090b57cec5SDimitry Andric            is_nothrow_copy_constructible<key_compare>::value);
3100b57cec5SDimitry Andric    explicit multimap(const key_compare& comp);
3110b57cec5SDimitry Andric    multimap(const key_compare& comp, const allocator_type& a);
3120b57cec5SDimitry Andric    template <class InputIterator>
3130b57cec5SDimitry Andric        multimap(InputIterator first, InputIterator last, const key_compare& comp);
3140b57cec5SDimitry Andric    template <class InputIterator>
3150b57cec5SDimitry Andric        multimap(InputIterator first, InputIterator last, const key_compare& comp,
3160b57cec5SDimitry Andric                 const allocator_type& a);
3170b57cec5SDimitry Andric    multimap(const multimap& m);
3180b57cec5SDimitry Andric    multimap(multimap&& m)
3190b57cec5SDimitry Andric        noexcept(
3200b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value &&
3210b57cec5SDimitry Andric            is_nothrow_move_constructible<key_compare>::value);
3220b57cec5SDimitry Andric    explicit multimap(const allocator_type& a);
3230b57cec5SDimitry Andric    multimap(const multimap& m, const allocator_type& a);
3240b57cec5SDimitry Andric    multimap(multimap&& m, const allocator_type& a);
3250b57cec5SDimitry Andric    multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
3260b57cec5SDimitry Andric    multimap(initializer_list<value_type> il, const key_compare& comp,
3270b57cec5SDimitry Andric             const allocator_type& a);
3280b57cec5SDimitry Andric    template <class InputIterator>
3290b57cec5SDimitry Andric        multimap(InputIterator first, InputIterator last, const allocator_type& a)
3300b57cec5SDimitry Andric            : multimap(first, last, Compare(), a) {} // C++14
3310b57cec5SDimitry Andric    multimap(initializer_list<value_type> il, const allocator_type& a)
3320b57cec5SDimitry Andric        : multimap(il, Compare(), a) {} // C++14
3330b57cec5SDimitry Andric    ~multimap();
3340b57cec5SDimitry Andric
3350b57cec5SDimitry Andric    multimap& operator=(const multimap& m);
3360b57cec5SDimitry Andric    multimap& operator=(multimap&& m)
3370b57cec5SDimitry Andric        noexcept(
3380b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
3390b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
3400b57cec5SDimitry Andric            is_nothrow_move_assignable<key_compare>::value);
3410b57cec5SDimitry Andric    multimap& operator=(initializer_list<value_type> il);
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andric    // iterators:
3440b57cec5SDimitry Andric          iterator begin() noexcept;
3450b57cec5SDimitry Andric    const_iterator begin() const noexcept;
3460b57cec5SDimitry Andric          iterator end() noexcept;
3470b57cec5SDimitry Andric    const_iterator end()   const noexcept;
3480b57cec5SDimitry Andric
3490b57cec5SDimitry Andric          reverse_iterator rbegin() noexcept;
3500b57cec5SDimitry Andric    const_reverse_iterator rbegin() const noexcept;
3510b57cec5SDimitry Andric          reverse_iterator rend() noexcept;
3520b57cec5SDimitry Andric    const_reverse_iterator rend()   const noexcept;
3530b57cec5SDimitry Andric
3540b57cec5SDimitry Andric    const_iterator         cbegin()  const noexcept;
3550b57cec5SDimitry Andric    const_iterator         cend()    const noexcept;
3560b57cec5SDimitry Andric    const_reverse_iterator crbegin() const noexcept;
3570b57cec5SDimitry Andric    const_reverse_iterator crend()   const noexcept;
3580b57cec5SDimitry Andric
3590b57cec5SDimitry Andric    // capacity:
3600b57cec5SDimitry Andric    bool      empty()    const noexcept;
3610b57cec5SDimitry Andric    size_type size()     const noexcept;
3620b57cec5SDimitry Andric    size_type max_size() const noexcept;
3630b57cec5SDimitry Andric
3640b57cec5SDimitry Andric    // modifiers:
3650b57cec5SDimitry Andric    template <class... Args>
3660b57cec5SDimitry Andric        iterator emplace(Args&&... args);
3670b57cec5SDimitry Andric    template <class... Args>
3680b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
3690b57cec5SDimitry Andric    iterator insert(const value_type& v);
3700b57cec5SDimitry Andric    iterator insert(      value_type&& v);                                            // C++17
3710b57cec5SDimitry Andric    template <class P>
3720b57cec5SDimitry Andric        iterator insert(P&& p);
3730b57cec5SDimitry Andric    iterator insert(const_iterator position, const value_type& v);
3740b57cec5SDimitry Andric    iterator insert(const_iterator position,       value_type&& v);                   // C++17
3750b57cec5SDimitry Andric    template <class P>
3760b57cec5SDimitry Andric        iterator insert(const_iterator position, P&& p);
3770b57cec5SDimitry Andric    template <class InputIterator>
3780b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
3790b57cec5SDimitry Andric    void insert(initializer_list<value_type> il);
3800b57cec5SDimitry Andric
3810b57cec5SDimitry Andric    node_type extract(const_iterator position);                                       // C++17
3820b57cec5SDimitry Andric    node_type extract(const key_type& x);                                             // C++17
3830b57cec5SDimitry Andric    iterator insert(node_type&& nh);                                                  // C++17
3840b57cec5SDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);                             // C++17
3850b57cec5SDimitry Andric
3860b57cec5SDimitry Andric    iterator  erase(const_iterator position);
3870b57cec5SDimitry Andric    iterator  erase(iterator position); // C++14
3880b57cec5SDimitry Andric    size_type erase(const key_type& k);
3890b57cec5SDimitry Andric    iterator  erase(const_iterator first, const_iterator last);
3900b57cec5SDimitry Andric    void clear() noexcept;
3910b57cec5SDimitry Andric
3920b57cec5SDimitry Andric    template<class C2>
3930b57cec5SDimitry Andric      void merge(multimap<Key, T, C2, Allocator>& source);    // C++17
3940b57cec5SDimitry Andric    template<class C2>
3950b57cec5SDimitry Andric      void merge(multimap<Key, T, C2, Allocator>&& source);   // C++17
3960b57cec5SDimitry Andric    template<class C2>
3970b57cec5SDimitry Andric      void merge(map<Key, T, C2, Allocator>& source);         // C++17
3980b57cec5SDimitry Andric    template<class C2>
3990b57cec5SDimitry Andric      void merge(map<Key, T, C2, Allocator>&& source);        // C++17
4000b57cec5SDimitry Andric
4010b57cec5SDimitry Andric    void swap(multimap& m)
4020b57cec5SDimitry Andric        noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
4030b57cec5SDimitry Andric            is_nothrow_swappable<key_compare>::value); // C++17
4040b57cec5SDimitry Andric
4050b57cec5SDimitry Andric    // observers:
4060b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
4070b57cec5SDimitry Andric    key_compare    key_comp()      const;
4080b57cec5SDimitry Andric    value_compare  value_comp()    const;
4090b57cec5SDimitry Andric
4100b57cec5SDimitry Andric    // map operations:
4110b57cec5SDimitry Andric          iterator find(const key_type& k);
4120b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
4130b57cec5SDimitry Andric    template<typename K>
4140b57cec5SDimitry Andric        iterator find(const K& x);              // C++14
4150b57cec5SDimitry Andric    template<typename K>
4160b57cec5SDimitry Andric        const_iterator find(const K& x) const;  // C++14
417*fe6060f1SDimitry Andric
4180b57cec5SDimitry Andric    template<typename K>
4190b57cec5SDimitry Andric      size_type count(const K& x) const;        // C++14
4200b57cec5SDimitry Andric    size_type      count(const key_type& k) const;
421*fe6060f1SDimitry Andric
4220b57cec5SDimitry Andric    bool           contains(const key_type& x) const;  // C++20
423*fe6060f1SDimitry Andric    template<class K> bool contains(const K& x) const; // C++20
424*fe6060f1SDimitry Andric
4250b57cec5SDimitry Andric          iterator lower_bound(const key_type& k);
4260b57cec5SDimitry Andric    const_iterator lower_bound(const key_type& k) const;
4270b57cec5SDimitry Andric    template<typename K>
4280b57cec5SDimitry Andric        iterator lower_bound(const K& x);              // C++14
4290b57cec5SDimitry Andric    template<typename K>
4300b57cec5SDimitry Andric        const_iterator lower_bound(const K& x) const;  // C++14
4310b57cec5SDimitry Andric
4320b57cec5SDimitry Andric          iterator upper_bound(const key_type& k);
4330b57cec5SDimitry Andric    const_iterator upper_bound(const key_type& k) const;
4340b57cec5SDimitry Andric    template<typename K>
4350b57cec5SDimitry Andric        iterator upper_bound(const K& x);              // C++14
4360b57cec5SDimitry Andric    template<typename K>
4370b57cec5SDimitry Andric        const_iterator upper_bound(const K& x) const;  // C++14
4380b57cec5SDimitry Andric
4390b57cec5SDimitry Andric    pair<iterator,iterator>             equal_range(const key_type& k);
4400b57cec5SDimitry Andric    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
4410b57cec5SDimitry Andric    template<typename K>
4420b57cec5SDimitry Andric        pair<iterator,iterator>             equal_range(const K& x);        // C++14
4430b57cec5SDimitry Andric    template<typename K>
4440b57cec5SDimitry Andric        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
4450b57cec5SDimitry Andric};
4460b57cec5SDimitry Andric
4470b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
4480b57cec5SDimitry Andricbool
4490b57cec5SDimitry Andricoperator==(const multimap<Key, T, Compare, Allocator>& x,
4500b57cec5SDimitry Andric           const multimap<Key, T, Compare, Allocator>& y);
4510b57cec5SDimitry Andric
4520b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
4530b57cec5SDimitry Andricbool
4540b57cec5SDimitry Andricoperator< (const multimap<Key, T, Compare, Allocator>& x,
4550b57cec5SDimitry Andric           const multimap<Key, T, Compare, Allocator>& y);
4560b57cec5SDimitry Andric
4570b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
4580b57cec5SDimitry Andricbool
4590b57cec5SDimitry Andricoperator!=(const multimap<Key, T, Compare, Allocator>& x,
4600b57cec5SDimitry Andric           const multimap<Key, T, Compare, Allocator>& y);
4610b57cec5SDimitry Andric
4620b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
4630b57cec5SDimitry Andricbool
4640b57cec5SDimitry Andricoperator> (const multimap<Key, T, Compare, Allocator>& x,
4650b57cec5SDimitry Andric           const multimap<Key, T, Compare, Allocator>& y);
4660b57cec5SDimitry Andric
4670b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
4680b57cec5SDimitry Andricbool
4690b57cec5SDimitry Andricoperator>=(const multimap<Key, T, Compare, Allocator>& x,
4700b57cec5SDimitry Andric           const multimap<Key, T, Compare, Allocator>& y);
4710b57cec5SDimitry Andric
4720b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
4730b57cec5SDimitry Andricbool
4740b57cec5SDimitry Andricoperator<=(const multimap<Key, T, Compare, Allocator>& x,
4750b57cec5SDimitry Andric           const multimap<Key, T, Compare, Allocator>& y);
4760b57cec5SDimitry Andric
4770b57cec5SDimitry Andric// specialized algorithms:
4780b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator>
4790b57cec5SDimitry Andricvoid
4800b57cec5SDimitry Andricswap(multimap<Key, T, Compare, Allocator>& x,
4810b57cec5SDimitry Andric     multimap<Key, T, Compare, Allocator>& y)
4820b57cec5SDimitry Andric    noexcept(noexcept(x.swap(y)));
4830b57cec5SDimitry Andric
4840b57cec5SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator, class Predicate>
4855ffd83dbSDimitry Andrictypename multimap<Key, T, Compare, Allocator>::size_type
4865ffd83dbSDimitry Andricerase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred);  // C++20
4870b57cec5SDimitry Andric
4880b57cec5SDimitry Andric}  // std
4890b57cec5SDimitry Andric
4900b57cec5SDimitry Andric*/
4910b57cec5SDimitry Andric
4920b57cec5SDimitry Andric#include <__config>
493*fe6060f1SDimitry Andric#include <__debug>
494*fe6060f1SDimitry Andric#include <__functional/is_transparent.h>
4950b57cec5SDimitry Andric#include <__node_handle>
496*fe6060f1SDimitry Andric#include <__tree>
497*fe6060f1SDimitry Andric#include <__utility/forward.h>
498*fe6060f1SDimitry Andric#include <compare>
4990b57cec5SDimitry Andric#include <functional>
5000b57cec5SDimitry Andric#include <initializer_list>
501*fe6060f1SDimitry Andric#include <iterator> // __libcpp_erase_if_container
502*fe6060f1SDimitry Andric#include <memory>
5030b57cec5SDimitry Andric#include <type_traits>
504*fe6060f1SDimitry Andric#include <utility>
5050b57cec5SDimitry Andric#include <version>
5060b57cec5SDimitry Andric
5070b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5080b57cec5SDimitry Andric#pragma GCC system_header
5090b57cec5SDimitry Andric#endif
5100b57cec5SDimitry Andric
5110b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
5120b57cec5SDimitry Andric
5130b57cec5SDimitry Andrictemplate <class _Key, class _CP, class _Compare,
5140b57cec5SDimitry Andric          bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
5150b57cec5SDimitry Andricclass __map_value_compare
5160b57cec5SDimitry Andric    : private _Compare
5170b57cec5SDimitry Andric{
5180b57cec5SDimitry Andricpublic:
5190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5200b57cec5SDimitry Andric    __map_value_compare()
5210b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
5220b57cec5SDimitry Andric        : _Compare() {}
5230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5240b57cec5SDimitry Andric    __map_value_compare(_Compare c)
5250b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
5260b57cec5SDimitry Andric        : _Compare(c) {}
5270b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5280b57cec5SDimitry Andric    const _Compare& key_comp() const _NOEXCEPT {return *this;}
5290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5300b57cec5SDimitry Andric    bool operator()(const _CP& __x, const _CP& __y) const
5310b57cec5SDimitry Andric        {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first);}
5320b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5330b57cec5SDimitry Andric    bool operator()(const _CP& __x, const _Key& __y) const
5340b57cec5SDimitry Andric        {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);}
5350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5360b57cec5SDimitry Andric    bool operator()(const _Key& __x, const _CP& __y) const
5370b57cec5SDimitry Andric        {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);}
5380b57cec5SDimitry Andric    void swap(__map_value_compare&__y)
5390b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
5400b57cec5SDimitry Andric    {
5410b57cec5SDimitry Andric      using _VSTD::swap;
5420b57cec5SDimitry Andric      swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y));
5430b57cec5SDimitry Andric    }
5440b57cec5SDimitry Andric
5450b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
5460b57cec5SDimitry Andric    template <typename _K2>
5470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5480b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
5490b57cec5SDimitry Andric    operator () ( const _K2& __x, const _CP& __y ) const
5500b57cec5SDimitry Andric        {return static_cast<const _Compare&>(*this) (__x, __y.__get_value().first);}
5510b57cec5SDimitry Andric
5520b57cec5SDimitry Andric    template <typename _K2>
5530b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5540b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
5550b57cec5SDimitry Andric    operator () (const _CP& __x, const _K2& __y) const
5560b57cec5SDimitry Andric        {return static_cast<const _Compare&>(*this) (__x.__get_value().first, __y);}
5570b57cec5SDimitry Andric#endif
5580b57cec5SDimitry Andric};
5590b57cec5SDimitry Andric
5600b57cec5SDimitry Andrictemplate <class _Key, class _CP, class _Compare>
5610b57cec5SDimitry Andricclass __map_value_compare<_Key, _CP, _Compare, false>
5620b57cec5SDimitry Andric{
5630b57cec5SDimitry Andric    _Compare comp;
5640b57cec5SDimitry Andric
5650b57cec5SDimitry Andricpublic:
5660b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5670b57cec5SDimitry Andric    __map_value_compare()
5680b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
5690b57cec5SDimitry Andric        : comp() {}
5700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5710b57cec5SDimitry Andric    __map_value_compare(_Compare c)
5720b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
5730b57cec5SDimitry Andric        : comp(c) {}
5740b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5750b57cec5SDimitry Andric    const _Compare& key_comp() const _NOEXCEPT {return comp;}
5760b57cec5SDimitry Andric
5770b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5780b57cec5SDimitry Andric    bool operator()(const _CP& __x, const _CP& __y) const
5790b57cec5SDimitry Andric        {return comp(__x.__get_value().first, __y.__get_value().first);}
5800b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5810b57cec5SDimitry Andric    bool operator()(const _CP& __x, const _Key& __y) const
5820b57cec5SDimitry Andric        {return comp(__x.__get_value().first, __y);}
5830b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5840b57cec5SDimitry Andric    bool operator()(const _Key& __x, const _CP& __y) const
5850b57cec5SDimitry Andric        {return comp(__x, __y.__get_value().first);}
5860b57cec5SDimitry Andric    void swap(__map_value_compare&__y)
5870b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
5880b57cec5SDimitry Andric    {
5890b57cec5SDimitry Andric        using _VSTD::swap;
5900b57cec5SDimitry Andric        swap(comp, __y.comp);
5910b57cec5SDimitry Andric    }
5920b57cec5SDimitry Andric
5930b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
5940b57cec5SDimitry Andric    template <typename _K2>
5950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5960b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
5970b57cec5SDimitry Andric    operator () ( const _K2& __x, const _CP& __y ) const
5980b57cec5SDimitry Andric        {return comp (__x, __y.__get_value().first);}
5990b57cec5SDimitry Andric
6000b57cec5SDimitry Andric    template <typename _K2>
6010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6020b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
6030b57cec5SDimitry Andric    operator () (const _CP& __x, const _K2& __y) const
6040b57cec5SDimitry Andric        {return comp (__x.__get_value().first, __y);}
6050b57cec5SDimitry Andric#endif
6060b57cec5SDimitry Andric};
6070b57cec5SDimitry Andric
6080b57cec5SDimitry Andrictemplate <class _Key, class _CP, class _Compare, bool __b>
6090b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
6100b57cec5SDimitry Andricvoid
6110b57cec5SDimitry Andricswap(__map_value_compare<_Key, _CP, _Compare, __b>& __x,
6120b57cec5SDimitry Andric     __map_value_compare<_Key, _CP, _Compare, __b>& __y)
6130b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
6140b57cec5SDimitry Andric{
6150b57cec5SDimitry Andric    __x.swap(__y);
6160b57cec5SDimitry Andric}
6170b57cec5SDimitry Andric
6180b57cec5SDimitry Andrictemplate <class _Allocator>
6190b57cec5SDimitry Andricclass __map_node_destructor
6200b57cec5SDimitry Andric{
6210b57cec5SDimitry Andric    typedef _Allocator                          allocator_type;
6220b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>    __alloc_traits;
6230b57cec5SDimitry Andric
6240b57cec5SDimitry Andricpublic:
6250b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer    pointer;
6260b57cec5SDimitry Andric
6270b57cec5SDimitry Andricprivate:
6280b57cec5SDimitry Andric    allocator_type& __na_;
6290b57cec5SDimitry Andric
6300b57cec5SDimitry Andric    __map_node_destructor& operator=(const __map_node_destructor&);
6310b57cec5SDimitry Andric
6320b57cec5SDimitry Andricpublic:
6330b57cec5SDimitry Andric    bool __first_constructed;
6340b57cec5SDimitry Andric    bool __second_constructed;
6350b57cec5SDimitry Andric
6360b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6370b57cec5SDimitry Andric    explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT
6380b57cec5SDimitry Andric        : __na_(__na),
6390b57cec5SDimitry Andric          __first_constructed(false),
6400b57cec5SDimitry Andric          __second_constructed(false)
6410b57cec5SDimitry Andric        {}
6420b57cec5SDimitry Andric
6430b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6450b57cec5SDimitry Andric    __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT
6460b57cec5SDimitry Andric        : __na_(__x.__na_),
6470b57cec5SDimitry Andric          __first_constructed(__x.__value_constructed),
6480b57cec5SDimitry Andric          __second_constructed(__x.__value_constructed)
6490b57cec5SDimitry Andric        {
6500b57cec5SDimitry Andric            __x.__value_constructed = false;
6510b57cec5SDimitry Andric        }
6520b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
6530b57cec5SDimitry Andric
6540b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6550b57cec5SDimitry Andric    void operator()(pointer __p) _NOEXCEPT
6560b57cec5SDimitry Andric    {
6570b57cec5SDimitry Andric        if (__second_constructed)
6580b57cec5SDimitry Andric            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
6590b57cec5SDimitry Andric        if (__first_constructed)
6600b57cec5SDimitry Andric            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
6610b57cec5SDimitry Andric        if (__p)
6620b57cec5SDimitry Andric            __alloc_traits::deallocate(__na_, __p, 1);
6630b57cec5SDimitry Andric    }
6640b57cec5SDimitry Andric};
6650b57cec5SDimitry Andric
6660b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
6670b57cec5SDimitry Andric    class map;
6680b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
6690b57cec5SDimitry Andric    class multimap;
6700b57cec5SDimitry Andrictemplate <class _TreeIterator> class __map_const_iterator;
6710b57cec5SDimitry Andric
6720b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6730b57cec5SDimitry Andric
6740b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
675*fe6060f1SDimitry Andricstruct _LIBCPP_STANDALONE_DEBUG __value_type
6760b57cec5SDimitry Andric{
6770b57cec5SDimitry Andric    typedef _Key                                     key_type;
6780b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
6790b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
6800b57cec5SDimitry Andric    typedef pair<key_type&, mapped_type&>            __nc_ref_pair_type;
6810b57cec5SDimitry Andric    typedef pair<key_type&&, mapped_type&&>          __nc_rref_pair_type;
6820b57cec5SDimitry Andric
6830b57cec5SDimitry Andricprivate:
6840b57cec5SDimitry Andric    value_type __cc;
6850b57cec5SDimitry Andric
6860b57cec5SDimitry Andricpublic:
6870b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6880b57cec5SDimitry Andric    value_type& __get_value()
6890b57cec5SDimitry Andric    {
6900b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
6910b57cec5SDimitry Andric        return *_VSTD::launder(_VSTD::addressof(__cc));
6920b57cec5SDimitry Andric#else
6930b57cec5SDimitry Andric        return __cc;
6940b57cec5SDimitry Andric#endif
6950b57cec5SDimitry Andric    }
6960b57cec5SDimitry Andric
6970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6980b57cec5SDimitry Andric    const value_type& __get_value() const
6990b57cec5SDimitry Andric    {
7000b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
7010b57cec5SDimitry Andric        return *_VSTD::launder(_VSTD::addressof(__cc));
7020b57cec5SDimitry Andric#else
7030b57cec5SDimitry Andric        return __cc;
7040b57cec5SDimitry Andric#endif
7050b57cec5SDimitry Andric    }
7060b57cec5SDimitry Andric
7070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7080b57cec5SDimitry Andric    __nc_ref_pair_type __ref()
7090b57cec5SDimitry Andric    {
7100b57cec5SDimitry Andric        value_type& __v = __get_value();
7110b57cec5SDimitry Andric        return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
7120b57cec5SDimitry Andric    }
7130b57cec5SDimitry Andric
7140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7150b57cec5SDimitry Andric    __nc_rref_pair_type __move()
7160b57cec5SDimitry Andric    {
7170b57cec5SDimitry Andric        value_type& __v = __get_value();
7180b57cec5SDimitry Andric        return __nc_rref_pair_type(
7190b57cec5SDimitry Andric            _VSTD::move(const_cast<key_type&>(__v.first)),
7200b57cec5SDimitry Andric            _VSTD::move(__v.second));
7210b57cec5SDimitry Andric    }
7220b57cec5SDimitry Andric
7230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7240b57cec5SDimitry Andric    __value_type& operator=(const __value_type& __v)
7250b57cec5SDimitry Andric    {
7260b57cec5SDimitry Andric        __ref() = __v.__get_value();
7270b57cec5SDimitry Andric        return *this;
7280b57cec5SDimitry Andric    }
7290b57cec5SDimitry Andric
7300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7310b57cec5SDimitry Andric    __value_type& operator=(__value_type&& __v)
7320b57cec5SDimitry Andric    {
7330b57cec5SDimitry Andric        __ref() = __v.__move();
7340b57cec5SDimitry Andric        return *this;
7350b57cec5SDimitry Andric    }
7360b57cec5SDimitry Andric
7370b57cec5SDimitry Andric    template <class _ValueTp,
7380b57cec5SDimitry Andric              class = typename enable_if<
7390b57cec5SDimitry Andric                    __is_same_uncvref<_ValueTp, value_type>::value
7400b57cec5SDimitry Andric                 >::type
7410b57cec5SDimitry Andric             >
7420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7430b57cec5SDimitry Andric    __value_type& operator=(_ValueTp&& __v)
7440b57cec5SDimitry Andric    {
7450b57cec5SDimitry Andric        __ref() = _VSTD::forward<_ValueTp>(__v);
7460b57cec5SDimitry Andric        return *this;
7470b57cec5SDimitry Andric    }
7480b57cec5SDimitry Andric
7490b57cec5SDimitry Andricprivate:
7500b57cec5SDimitry Andric    __value_type() _LIBCPP_EQUAL_DELETE;
7510b57cec5SDimitry Andric    ~__value_type() _LIBCPP_EQUAL_DELETE;
7520b57cec5SDimitry Andric    __value_type(const __value_type& __v) _LIBCPP_EQUAL_DELETE;
7530b57cec5SDimitry Andric    __value_type(__value_type&& __v) _LIBCPP_EQUAL_DELETE;
7540b57cec5SDimitry Andric};
7550b57cec5SDimitry Andric
7560b57cec5SDimitry Andric#else
7570b57cec5SDimitry Andric
7580b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
7590b57cec5SDimitry Andricstruct __value_type
7600b57cec5SDimitry Andric{
7610b57cec5SDimitry Andric    typedef _Key                                     key_type;
7620b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
7630b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
7640b57cec5SDimitry Andric
7650b57cec5SDimitry Andricprivate:
7660b57cec5SDimitry Andric    value_type __cc;
7670b57cec5SDimitry Andric
7680b57cec5SDimitry Andricpublic:
7690b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7700b57cec5SDimitry Andric    value_type& __get_value() { return __cc; }
7710b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7720b57cec5SDimitry Andric    const value_type& __get_value() const { return __cc; }
7730b57cec5SDimitry Andric
7740b57cec5SDimitry Andricprivate:
7750b57cec5SDimitry Andric   __value_type();
7760b57cec5SDimitry Andric   __value_type(__value_type const&);
7770b57cec5SDimitry Andric   __value_type& operator=(__value_type const&);
7780b57cec5SDimitry Andric   ~__value_type();
7790b57cec5SDimitry Andric};
7800b57cec5SDimitry Andric
7810b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
7820b57cec5SDimitry Andric
7830b57cec5SDimitry Andrictemplate <class _Tp>
7840b57cec5SDimitry Andricstruct __extract_key_value_types;
7850b57cec5SDimitry Andric
7860b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
7870b57cec5SDimitry Andricstruct __extract_key_value_types<__value_type<_Key, _Tp> >
7880b57cec5SDimitry Andric{
7890b57cec5SDimitry Andric  typedef _Key const __key_type;
7900b57cec5SDimitry Andric  typedef _Tp        __mapped_type;
7910b57cec5SDimitry Andric};
7920b57cec5SDimitry Andric
7930b57cec5SDimitry Andrictemplate <class _TreeIterator>
7940b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS __map_iterator
7950b57cec5SDimitry Andric{
7960b57cec5SDimitry Andric    typedef typename _TreeIterator::_NodeTypes                   _NodeTypes;
7970b57cec5SDimitry Andric    typedef typename _TreeIterator::__pointer_traits             __pointer_traits;
7980b57cec5SDimitry Andric
7990b57cec5SDimitry Andric    _TreeIterator __i_;
8000b57cec5SDimitry Andric
8010b57cec5SDimitry Andricpublic:
8020b57cec5SDimitry Andric    typedef bidirectional_iterator_tag                           iterator_category;
8030b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type                value_type;
8040b57cec5SDimitry Andric    typedef typename _TreeIterator::difference_type              difference_type;
8050b57cec5SDimitry Andric    typedef value_type&                                          reference;
8060b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type_pointer        pointer;
8070b57cec5SDimitry Andric
8080b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8090b57cec5SDimitry Andric    __map_iterator() _NOEXCEPT {}
8100b57cec5SDimitry Andric
8110b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8120b57cec5SDimitry Andric    __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
8130b57cec5SDimitry Andric
8140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8150b57cec5SDimitry Andric    reference operator*() const {return __i_->__get_value();}
8160b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8170b57cec5SDimitry Andric    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
8180b57cec5SDimitry Andric
8190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8200b57cec5SDimitry Andric    __map_iterator& operator++() {++__i_; return *this;}
8210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8220b57cec5SDimitry Andric    __map_iterator operator++(int)
8230b57cec5SDimitry Andric    {
8240b57cec5SDimitry Andric        __map_iterator __t(*this);
8250b57cec5SDimitry Andric        ++(*this);
8260b57cec5SDimitry Andric        return __t;
8270b57cec5SDimitry Andric    }
8280b57cec5SDimitry Andric
8290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8300b57cec5SDimitry Andric    __map_iterator& operator--() {--__i_; return *this;}
8310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8320b57cec5SDimitry Andric    __map_iterator operator--(int)
8330b57cec5SDimitry Andric    {
8340b57cec5SDimitry Andric        __map_iterator __t(*this);
8350b57cec5SDimitry Andric        --(*this);
8360b57cec5SDimitry Andric        return __t;
8370b57cec5SDimitry Andric    }
8380b57cec5SDimitry Andric
8390b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
8400b57cec5SDimitry Andric    bool operator==(const __map_iterator& __x, const __map_iterator& __y)
8410b57cec5SDimitry Andric        {return __x.__i_ == __y.__i_;}
8420b57cec5SDimitry Andric    friend
8430b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8440b57cec5SDimitry Andric    bool operator!=(const __map_iterator& __x, const __map_iterator& __y)
8450b57cec5SDimitry Andric        {return __x.__i_ != __y.__i_;}
8460b57cec5SDimitry Andric
8470b57cec5SDimitry Andric    template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
8480b57cec5SDimitry Andric    template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
8490b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
8500b57cec5SDimitry Andric};
8510b57cec5SDimitry Andric
8520b57cec5SDimitry Andrictemplate <class _TreeIterator>
8530b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS __map_const_iterator
8540b57cec5SDimitry Andric{
8550b57cec5SDimitry Andric    typedef typename _TreeIterator::_NodeTypes                   _NodeTypes;
8560b57cec5SDimitry Andric    typedef typename _TreeIterator::__pointer_traits             __pointer_traits;
8570b57cec5SDimitry Andric
8580b57cec5SDimitry Andric    _TreeIterator __i_;
8590b57cec5SDimitry Andric
8600b57cec5SDimitry Andricpublic:
8610b57cec5SDimitry Andric    typedef bidirectional_iterator_tag                           iterator_category;
8620b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type                value_type;
8630b57cec5SDimitry Andric    typedef typename _TreeIterator::difference_type              difference_type;
8640b57cec5SDimitry Andric    typedef const value_type&                                    reference;
8650b57cec5SDimitry Andric    typedef typename _NodeTypes::__const_map_value_type_pointer  pointer;
8660b57cec5SDimitry Andric
8670b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8680b57cec5SDimitry Andric    __map_const_iterator() _NOEXCEPT {}
8690b57cec5SDimitry Andric
8700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8710b57cec5SDimitry Andric    __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
8720b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8730b57cec5SDimitry Andric    __map_const_iterator(__map_iterator<
8740b57cec5SDimitry Andric        typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT
8750b57cec5SDimitry Andric        : __i_(__i.__i_) {}
8760b57cec5SDimitry Andric
8770b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8780b57cec5SDimitry Andric    reference operator*() const {return __i_->__get_value();}
8790b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8800b57cec5SDimitry Andric    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
8810b57cec5SDimitry Andric
8820b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8830b57cec5SDimitry Andric    __map_const_iterator& operator++() {++__i_; return *this;}
8840b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8850b57cec5SDimitry Andric    __map_const_iterator operator++(int)
8860b57cec5SDimitry Andric    {
8870b57cec5SDimitry Andric        __map_const_iterator __t(*this);
8880b57cec5SDimitry Andric        ++(*this);
8890b57cec5SDimitry Andric        return __t;
8900b57cec5SDimitry Andric    }
8910b57cec5SDimitry Andric
8920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8930b57cec5SDimitry Andric    __map_const_iterator& operator--() {--__i_; return *this;}
8940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8950b57cec5SDimitry Andric    __map_const_iterator operator--(int)
8960b57cec5SDimitry Andric    {
8970b57cec5SDimitry Andric        __map_const_iterator __t(*this);
8980b57cec5SDimitry Andric        --(*this);
8990b57cec5SDimitry Andric        return __t;
9000b57cec5SDimitry Andric    }
9010b57cec5SDimitry Andric
9020b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
9030b57cec5SDimitry Andric    bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y)
9040b57cec5SDimitry Andric        {return __x.__i_ == __y.__i_;}
9050b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
9060b57cec5SDimitry Andric    bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y)
9070b57cec5SDimitry Andric        {return __x.__i_ != __y.__i_;}
9080b57cec5SDimitry Andric
9090b57cec5SDimitry Andric    template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
9100b57cec5SDimitry Andric    template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
9110b57cec5SDimitry Andric    template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;
9120b57cec5SDimitry Andric};
9130b57cec5SDimitry Andric
9140b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare = less<_Key>,
9150b57cec5SDimitry Andric          class _Allocator = allocator<pair<const _Key, _Tp> > >
9160b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS map
9170b57cec5SDimitry Andric{
9180b57cec5SDimitry Andricpublic:
9190b57cec5SDimitry Andric    // types:
9200b57cec5SDimitry Andric    typedef _Key                                     key_type;
9210b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
9220b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
923*fe6060f1SDimitry Andric    typedef __identity_t<_Compare>                   key_compare;
924*fe6060f1SDimitry Andric    typedef __identity_t<_Allocator>                 allocator_type;
9250b57cec5SDimitry Andric    typedef value_type&                              reference;
9260b57cec5SDimitry Andric    typedef const value_type&                        const_reference;
9270b57cec5SDimitry Andric
9280b57cec5SDimitry Andric    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
9290b57cec5SDimitry Andric                  "Allocator::value_type must be same type as value_type");
9300b57cec5SDimitry Andric
931*fe6060f1SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
9320b57cec5SDimitry Andric    class _LIBCPP_TEMPLATE_VIS value_compare
933*fe6060f1SDimitry Andric#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
9340b57cec5SDimitry Andric        : public binary_function<value_type, value_type, bool>
935*fe6060f1SDimitry Andric#endif
9360b57cec5SDimitry Andric    {
937*fe6060f1SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
9380b57cec5SDimitry Andric        friend class map;
9390b57cec5SDimitry Andric    protected:
9400b57cec5SDimitry Andric        key_compare comp;
9410b57cec5SDimitry Andric
9420b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {}
9430b57cec5SDimitry Andric    public:
944*fe6060f1SDimitry Andric#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
945*fe6060f1SDimitry Andric        _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
946*fe6060f1SDimitry Andric        _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
947*fe6060f1SDimitry Andric        _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
948*fe6060f1SDimitry Andric#endif
9490b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
9500b57cec5SDimitry Andric        bool operator()(const value_type& __x, const value_type& __y) const
9510b57cec5SDimitry Andric            {return comp(__x.first, __y.first);}
9520b57cec5SDimitry Andric    };
9530b57cec5SDimitry Andric
9540b57cec5SDimitry Andricprivate:
9550b57cec5SDimitry Andric
9560b57cec5SDimitry Andric    typedef _VSTD::__value_type<key_type, mapped_type>             __value_type;
9570b57cec5SDimitry Andric    typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
9580b57cec5SDimitry Andric    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
9590b57cec5SDimitry Andric                                                 __value_type>::type __allocator_type;
9600b57cec5SDimitry Andric    typedef __tree<__value_type, __vc, __allocator_type>   __base;
9610b57cec5SDimitry Andric    typedef typename __base::__node_traits                 __node_traits;
9620b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>               __alloc_traits;
9630b57cec5SDimitry Andric
9640b57cec5SDimitry Andric    __base __tree_;
9650b57cec5SDimitry Andric
9660b57cec5SDimitry Andricpublic:
9670b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer               pointer;
9680b57cec5SDimitry Andric    typedef typename __alloc_traits::const_pointer         const_pointer;
9690b57cec5SDimitry Andric    typedef typename __alloc_traits::size_type             size_type;
9700b57cec5SDimitry Andric    typedef typename __alloc_traits::difference_type       difference_type;
9710b57cec5SDimitry Andric    typedef __map_iterator<typename __base::iterator>             iterator;
9720b57cec5SDimitry Andric    typedef __map_const_iterator<typename __base::const_iterator> const_iterator;
9730b57cec5SDimitry Andric    typedef _VSTD::reverse_iterator<iterator>               reverse_iterator;
9740b57cec5SDimitry Andric    typedef _VSTD::reverse_iterator<const_iterator>         const_reverse_iterator;
9750b57cec5SDimitry Andric
9760b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
9770b57cec5SDimitry Andric    typedef __map_node_handle<typename __base::__node, allocator_type> node_type;
9780b57cec5SDimitry Andric    typedef __insert_return_type<iterator, node_type> insert_return_type;
9790b57cec5SDimitry Andric#endif
9800b57cec5SDimitry Andric
9810b57cec5SDimitry Andric    template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
9820b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS map;
9830b57cec5SDimitry Andric    template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
9840b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS multimap;
9850b57cec5SDimitry Andric
9860b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9870b57cec5SDimitry Andric    map()
9880b57cec5SDimitry Andric        _NOEXCEPT_(
9890b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value &&
9900b57cec5SDimitry Andric            is_nothrow_default_constructible<key_compare>::value &&
9910b57cec5SDimitry Andric            is_nothrow_copy_constructible<key_compare>::value)
9920b57cec5SDimitry Andric        : __tree_(__vc(key_compare())) {}
9930b57cec5SDimitry Andric
9940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9950b57cec5SDimitry Andric    explicit map(const key_compare& __comp)
9960b57cec5SDimitry Andric        _NOEXCEPT_(
9970b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value &&
9980b57cec5SDimitry Andric            is_nothrow_copy_constructible<key_compare>::value)
9990b57cec5SDimitry Andric        : __tree_(__vc(__comp)) {}
10000b57cec5SDimitry Andric
10010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10020b57cec5SDimitry Andric    explicit map(const key_compare& __comp, const allocator_type& __a)
10030b57cec5SDimitry Andric        : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
10040b57cec5SDimitry Andric
10050b57cec5SDimitry Andric    template <class _InputIterator>
10060b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10070b57cec5SDimitry Andric        map(_InputIterator __f, _InputIterator __l,
10080b57cec5SDimitry Andric            const key_compare& __comp = key_compare())
10090b57cec5SDimitry Andric        : __tree_(__vc(__comp))
10100b57cec5SDimitry Andric        {
10110b57cec5SDimitry Andric            insert(__f, __l);
10120b57cec5SDimitry Andric        }
10130b57cec5SDimitry Andric
10140b57cec5SDimitry Andric    template <class _InputIterator>
10150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10160b57cec5SDimitry Andric        map(_InputIterator __f, _InputIterator __l,
10170b57cec5SDimitry Andric            const key_compare& __comp, const allocator_type& __a)
10180b57cec5SDimitry Andric        : __tree_(__vc(__comp), typename __base::allocator_type(__a))
10190b57cec5SDimitry Andric        {
10200b57cec5SDimitry Andric            insert(__f, __l);
10210b57cec5SDimitry Andric        }
10220b57cec5SDimitry Andric
10230b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
10240b57cec5SDimitry Andric    template <class _InputIterator>
10250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10260b57cec5SDimitry Andric    map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
10270b57cec5SDimitry Andric        : map(__f, __l, key_compare(), __a) {}
10280b57cec5SDimitry Andric#endif
10290b57cec5SDimitry Andric
10300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10310b57cec5SDimitry Andric    map(const map& __m)
10320b57cec5SDimitry Andric        : __tree_(__m.__tree_)
10330b57cec5SDimitry Andric        {
10340b57cec5SDimitry Andric            insert(__m.begin(), __m.end());
10350b57cec5SDimitry Andric        }
10360b57cec5SDimitry Andric
10370b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10380b57cec5SDimitry Andric    map& operator=(const map& __m)
10390b57cec5SDimitry Andric        {
10400b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
10410b57cec5SDimitry Andric            __tree_ = __m.__tree_;
10420b57cec5SDimitry Andric#else
10430b57cec5SDimitry Andric            if (this != &__m) {
10440b57cec5SDimitry Andric                __tree_.clear();
10450b57cec5SDimitry Andric                __tree_.value_comp() = __m.__tree_.value_comp();
10460b57cec5SDimitry Andric                __tree_.__copy_assign_alloc(__m.__tree_);
10470b57cec5SDimitry Andric                insert(__m.begin(), __m.end());
10480b57cec5SDimitry Andric            }
10490b57cec5SDimitry Andric#endif
10500b57cec5SDimitry Andric            return *this;
10510b57cec5SDimitry Andric        }
10520b57cec5SDimitry Andric
10530b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
10540b57cec5SDimitry Andric
10550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10560b57cec5SDimitry Andric    map(map&& __m)
10570b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
10580b57cec5SDimitry Andric        : __tree_(_VSTD::move(__m.__tree_))
10590b57cec5SDimitry Andric        {
10600b57cec5SDimitry Andric        }
10610b57cec5SDimitry Andric
10620b57cec5SDimitry Andric    map(map&& __m, const allocator_type& __a);
10630b57cec5SDimitry Andric
10640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10650b57cec5SDimitry Andric    map& operator=(map&& __m)
10660b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
10670b57cec5SDimitry Andric        {
10680b57cec5SDimitry Andric            __tree_ = _VSTD::move(__m.__tree_);
10690b57cec5SDimitry Andric            return *this;
10700b57cec5SDimitry Andric        }
10710b57cec5SDimitry Andric
10720b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10730b57cec5SDimitry Andric    map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
10740b57cec5SDimitry Andric        : __tree_(__vc(__comp))
10750b57cec5SDimitry Andric        {
10760b57cec5SDimitry Andric            insert(__il.begin(), __il.end());
10770b57cec5SDimitry Andric        }
10780b57cec5SDimitry Andric
10790b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10800b57cec5SDimitry Andric    map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
10810b57cec5SDimitry Andric        : __tree_(__vc(__comp), typename __base::allocator_type(__a))
10820b57cec5SDimitry Andric        {
10830b57cec5SDimitry Andric            insert(__il.begin(), __il.end());
10840b57cec5SDimitry Andric        }
10850b57cec5SDimitry Andric
10860b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
10870b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10880b57cec5SDimitry Andric    map(initializer_list<value_type> __il, const allocator_type& __a)
10890b57cec5SDimitry Andric        : map(__il, key_compare(), __a) {}
10900b57cec5SDimitry Andric#endif
10910b57cec5SDimitry Andric
10920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10930b57cec5SDimitry Andric    map& operator=(initializer_list<value_type> __il)
10940b57cec5SDimitry Andric        {
10950b57cec5SDimitry Andric            __tree_.__assign_unique(__il.begin(), __il.end());
10960b57cec5SDimitry Andric            return *this;
10970b57cec5SDimitry Andric        }
10980b57cec5SDimitry Andric
10990b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
11000b57cec5SDimitry Andric
11010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11020b57cec5SDimitry Andric    explicit map(const allocator_type& __a)
11030b57cec5SDimitry Andric        : __tree_(typename __base::allocator_type(__a))
11040b57cec5SDimitry Andric        {
11050b57cec5SDimitry Andric        }
11060b57cec5SDimitry Andric
11070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11080b57cec5SDimitry Andric    map(const map& __m, const allocator_type& __a)
11090b57cec5SDimitry Andric        : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
11100b57cec5SDimitry Andric        {
11110b57cec5SDimitry Andric            insert(__m.begin(), __m.end());
11120b57cec5SDimitry Andric        }
11130b57cec5SDimitry Andric
11140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11150b57cec5SDimitry Andric    ~map() {
11160b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
11170b57cec5SDimitry Andric    }
11180b57cec5SDimitry Andric
11190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11200b57cec5SDimitry Andric          iterator begin() _NOEXCEPT {return __tree_.begin();}
11210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11220b57cec5SDimitry Andric    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
11230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11240b57cec5SDimitry Andric          iterator end() _NOEXCEPT {return __tree_.end();}
11250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11260b57cec5SDimitry Andric    const_iterator end() const _NOEXCEPT {return __tree_.end();}
11270b57cec5SDimitry Andric
11280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11290b57cec5SDimitry Andric          reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
11300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11310b57cec5SDimitry Andric    const_reverse_iterator rbegin() const _NOEXCEPT
11320b57cec5SDimitry Andric        {return const_reverse_iterator(end());}
11330b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11340b57cec5SDimitry Andric          reverse_iterator rend() _NOEXCEPT
11350b57cec5SDimitry Andric            {return       reverse_iterator(begin());}
11360b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11370b57cec5SDimitry Andric    const_reverse_iterator rend() const _NOEXCEPT
11380b57cec5SDimitry Andric        {return const_reverse_iterator(begin());}
11390b57cec5SDimitry Andric
11400b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11410b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return begin();}
11420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11430b57cec5SDimitry Andric    const_iterator cend() const _NOEXCEPT {return end();}
11440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11450b57cec5SDimitry Andric    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
11460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11470b57cec5SDimitry Andric    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
11480b57cec5SDimitry Andric
11490b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
11500b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __tree_.size() == 0;}
11510b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11520b57cec5SDimitry Andric    size_type size() const _NOEXCEPT {return __tree_.size();}
11530b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11540b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
11550b57cec5SDimitry Andric
11560b57cec5SDimitry Andric    mapped_type& operator[](const key_type& __k);
11570b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
11580b57cec5SDimitry Andric    mapped_type& operator[](key_type&& __k);
11590b57cec5SDimitry Andric#endif
11600b57cec5SDimitry Andric
11610b57cec5SDimitry Andric          mapped_type& at(const key_type& __k);
11620b57cec5SDimitry Andric    const mapped_type& at(const key_type& __k) const;
11630b57cec5SDimitry Andric
11640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11650b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
11660b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11670b57cec5SDimitry Andric    key_compare    key_comp()      const {return __tree_.value_comp().key_comp();}
11680b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11690b57cec5SDimitry Andric    value_compare  value_comp()    const {return value_compare(__tree_.value_comp().key_comp());}
11700b57cec5SDimitry Andric
11710b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
11720b57cec5SDimitry Andric    template <class ..._Args>
11730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11740b57cec5SDimitry Andric    pair<iterator, bool> emplace(_Args&& ...__args) {
11750b57cec5SDimitry Andric        return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
11760b57cec5SDimitry Andric    }
11770b57cec5SDimitry Andric
11780b57cec5SDimitry Andric    template <class ..._Args>
11790b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11800b57cec5SDimitry Andric    iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
11810b57cec5SDimitry Andric        return __tree_.__emplace_hint_unique(__p.__i_, _VSTD::forward<_Args>(__args)...);
11820b57cec5SDimitry Andric    }
11830b57cec5SDimitry Andric
11840b57cec5SDimitry Andric    template <class _Pp,
11850b57cec5SDimitry Andric              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
11860b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
11870b57cec5SDimitry Andric        pair<iterator, bool> insert(_Pp&& __p)
11880b57cec5SDimitry Andric            {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));}
11890b57cec5SDimitry Andric
11900b57cec5SDimitry Andric    template <class _Pp,
11910b57cec5SDimitry Andric              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
11920b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
11930b57cec5SDimitry Andric        iterator insert(const_iterator __pos, _Pp&& __p)
11940b57cec5SDimitry Andric            {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
11950b57cec5SDimitry Andric
11960b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
11970b57cec5SDimitry Andric
11980b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11990b57cec5SDimitry Andric    pair<iterator, bool>
12000b57cec5SDimitry Andric        insert(const value_type& __v) {return __tree_.__insert_unique(__v);}
12010b57cec5SDimitry Andric
12020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12030b57cec5SDimitry Andric    iterator
12040b57cec5SDimitry Andric        insert(const_iterator __p, const value_type& __v)
12050b57cec5SDimitry Andric            {return __tree_.__insert_unique(__p.__i_, __v);}
12060b57cec5SDimitry Andric
12070b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
12080b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12090b57cec5SDimitry Andric    pair<iterator, bool>
12100b57cec5SDimitry Andric    insert(value_type&& __v) {return __tree_.__insert_unique(_VSTD::move(__v));}
12110b57cec5SDimitry Andric
12120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12130b57cec5SDimitry Andric    iterator insert(const_iterator __p,  value_type&& __v)
12140b57cec5SDimitry Andric    {return __tree_.__insert_unique(__p.__i_, _VSTD::move(__v));}
12150b57cec5SDimitry Andric
12160b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12170b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
12180b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
12190b57cec5SDimitry Andric#endif
12200b57cec5SDimitry Andric
12210b57cec5SDimitry Andric    template <class _InputIterator>
12220b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12230b57cec5SDimitry Andric        void insert(_InputIterator __f, _InputIterator __l)
12240b57cec5SDimitry Andric        {
12250b57cec5SDimitry Andric            for (const_iterator __e = cend(); __f != __l; ++__f)
12260b57cec5SDimitry Andric                insert(__e.__i_, *__f);
12270b57cec5SDimitry Andric        }
12280b57cec5SDimitry Andric
12290b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
12300b57cec5SDimitry Andric
12310b57cec5SDimitry Andric    template <class... _Args>
12320b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12330b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
12340b57cec5SDimitry Andric    {
12350b57cec5SDimitry Andric        return __tree_.__emplace_unique_key_args(__k,
12360b57cec5SDimitry Andric            _VSTD::piecewise_construct,
12370b57cec5SDimitry Andric            _VSTD::forward_as_tuple(__k),
12380b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
12390b57cec5SDimitry Andric    }
12400b57cec5SDimitry Andric
12410b57cec5SDimitry Andric    template <class... _Args>
12420b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12430b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
12440b57cec5SDimitry Andric    {
12450b57cec5SDimitry Andric        return __tree_.__emplace_unique_key_args(__k,
12460b57cec5SDimitry Andric            _VSTD::piecewise_construct,
12470b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::move(__k)),
12480b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
12490b57cec5SDimitry Andric    }
12500b57cec5SDimitry Andric
12510b57cec5SDimitry Andric    template <class... _Args>
12520b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12530b57cec5SDimitry Andric        iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
12540b57cec5SDimitry Andric    {
12550b57cec5SDimitry Andric        return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
12560b57cec5SDimitry Andric            _VSTD::piecewise_construct,
12570b57cec5SDimitry Andric            _VSTD::forward_as_tuple(__k),
1258e8d8bef9SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
12590b57cec5SDimitry Andric    }
12600b57cec5SDimitry Andric
12610b57cec5SDimitry Andric    template <class... _Args>
12620b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12630b57cec5SDimitry Andric        iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
12640b57cec5SDimitry Andric    {
12650b57cec5SDimitry Andric        return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
12660b57cec5SDimitry Andric            _VSTD::piecewise_construct,
12670b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::move(__k)),
1268e8d8bef9SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first;
12690b57cec5SDimitry Andric    }
12700b57cec5SDimitry Andric
12710b57cec5SDimitry Andric    template <class _Vp>
12720b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12730b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
12740b57cec5SDimitry Andric    {
12750b57cec5SDimitry Andric        iterator __p = lower_bound(__k);
12760b57cec5SDimitry Andric        if ( __p != end() && !key_comp()(__k, __p->first))
12770b57cec5SDimitry Andric        {
12780b57cec5SDimitry Andric            __p->second = _VSTD::forward<_Vp>(__v);
12790b57cec5SDimitry Andric            return _VSTD::make_pair(__p, false);
12800b57cec5SDimitry Andric        }
12810b57cec5SDimitry Andric        return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
12820b57cec5SDimitry Andric    }
12830b57cec5SDimitry Andric
12840b57cec5SDimitry Andric    template <class _Vp>
12850b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12860b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
12870b57cec5SDimitry Andric    {
12880b57cec5SDimitry Andric        iterator __p = lower_bound(__k);
12890b57cec5SDimitry Andric        if ( __p != end() && !key_comp()(__k, __p->first))
12900b57cec5SDimitry Andric        {
12910b57cec5SDimitry Andric            __p->second = _VSTD::forward<_Vp>(__v);
12920b57cec5SDimitry Andric            return _VSTD::make_pair(__p, false);
12930b57cec5SDimitry Andric        }
12940b57cec5SDimitry Andric        return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true);
12950b57cec5SDimitry Andric    }
12960b57cec5SDimitry Andric
12970b57cec5SDimitry Andric    template <class _Vp>
1298e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
1299e8d8bef9SDimitry Andric                                                        const key_type& __k,
1300e8d8bef9SDimitry Andric                                                        _Vp&& __v) {
1301e8d8bef9SDimitry Andric      auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
1302e8d8bef9SDimitry Andric          __h.__i_, __k, __k, _VSTD::forward<_Vp>(__v));
1303e8d8bef9SDimitry Andric
1304e8d8bef9SDimitry Andric      if (!__inserted)
1305e8d8bef9SDimitry Andric        __r->__get_value().second = _VSTD::forward<_Vp>(__v);
1306e8d8bef9SDimitry Andric
1307e8d8bef9SDimitry Andric      return __r;
13080b57cec5SDimitry Andric    }
13090b57cec5SDimitry Andric
13100b57cec5SDimitry Andric    template <class _Vp>
1311e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
1312e8d8bef9SDimitry Andric                                                        key_type&& __k,
1313e8d8bef9SDimitry Andric                                                        _Vp&& __v) {
1314e8d8bef9SDimitry Andric      auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(
1315e8d8bef9SDimitry Andric          __h.__i_, __k, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
1316e8d8bef9SDimitry Andric
1317e8d8bef9SDimitry Andric      if (!__inserted)
1318e8d8bef9SDimitry Andric        __r->__get_value().second = _VSTD::forward<_Vp>(__v);
1319e8d8bef9SDimitry Andric
1320e8d8bef9SDimitry Andric      return __r;
13210b57cec5SDimitry Andric    }
13220b57cec5SDimitry Andric
13230b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 14
13240b57cec5SDimitry Andric
13250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13260b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
13270b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13280b57cec5SDimitry Andric    iterator erase(iterator __p)       {return __tree_.erase(__p.__i_);}
13290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13300b57cec5SDimitry Andric    size_type erase(const key_type& __k)
13310b57cec5SDimitry Andric        {return __tree_.__erase_unique(__k);}
13320b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13330b57cec5SDimitry Andric    iterator  erase(const_iterator __f, const_iterator __l)
13340b57cec5SDimitry Andric        {return __tree_.erase(__f.__i_, __l.__i_);}
13350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13360b57cec5SDimitry Andric    void clear() _NOEXCEPT {__tree_.clear();}
13370b57cec5SDimitry Andric
13380b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
13390b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13400b57cec5SDimitry Andric    insert_return_type insert(node_type&& __nh)
13410b57cec5SDimitry Andric    {
13420b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
13430b57cec5SDimitry Andric            "node_type with incompatible allocator passed to map::insert()");
13440b57cec5SDimitry Andric        return __tree_.template __node_handle_insert_unique<
13450b57cec5SDimitry Andric            node_type, insert_return_type>(_VSTD::move(__nh));
13460b57cec5SDimitry Andric    }
13470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13480b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
13490b57cec5SDimitry Andric    {
13500b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
13510b57cec5SDimitry Andric            "node_type with incompatible allocator passed to map::insert()");
13520b57cec5SDimitry Andric        return __tree_.template __node_handle_insert_unique<node_type>(
13530b57cec5SDimitry Andric            __hint.__i_, _VSTD::move(__nh));
13540b57cec5SDimitry Andric    }
13550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13560b57cec5SDimitry Andric    node_type extract(key_type const& __key)
13570b57cec5SDimitry Andric    {
13580b57cec5SDimitry Andric        return __tree_.template __node_handle_extract<node_type>(__key);
13590b57cec5SDimitry Andric    }
13600b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13610b57cec5SDimitry Andric    node_type extract(const_iterator __it)
13620b57cec5SDimitry Andric    {
13630b57cec5SDimitry Andric        return __tree_.template __node_handle_extract<node_type>(__it.__i_);
13640b57cec5SDimitry Andric    }
13650b57cec5SDimitry Andric    template <class _Compare2>
13660b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13670b57cec5SDimitry Andric    void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source)
13680b57cec5SDimitry Andric    {
13690b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
13700b57cec5SDimitry Andric                       "merging container with incompatible allocator");
13710b57cec5SDimitry Andric        __tree_.__node_handle_merge_unique(__source.__tree_);
13720b57cec5SDimitry Andric    }
13730b57cec5SDimitry Andric    template <class _Compare2>
13740b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13750b57cec5SDimitry Andric    void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source)
13760b57cec5SDimitry Andric    {
13770b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
13780b57cec5SDimitry Andric                       "merging container with incompatible allocator");
13790b57cec5SDimitry Andric        __tree_.__node_handle_merge_unique(__source.__tree_);
13800b57cec5SDimitry Andric    }
13810b57cec5SDimitry Andric    template <class _Compare2>
13820b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13830b57cec5SDimitry Andric    void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source)
13840b57cec5SDimitry Andric    {
13850b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
13860b57cec5SDimitry Andric                       "merging container with incompatible allocator");
13870b57cec5SDimitry Andric        __tree_.__node_handle_merge_unique(__source.__tree_);
13880b57cec5SDimitry Andric    }
13890b57cec5SDimitry Andric    template <class _Compare2>
13900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13910b57cec5SDimitry Andric    void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source)
13920b57cec5SDimitry Andric    {
13930b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
13940b57cec5SDimitry Andric                       "merging container with incompatible allocator");
13950b57cec5SDimitry Andric        __tree_.__node_handle_merge_unique(__source.__tree_);
13960b57cec5SDimitry Andric    }
13970b57cec5SDimitry Andric#endif
13980b57cec5SDimitry Andric
13990b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14000b57cec5SDimitry Andric    void swap(map& __m)
14010b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
14020b57cec5SDimitry Andric        {__tree_.swap(__m.__tree_);}
14030b57cec5SDimitry Andric
14040b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14050b57cec5SDimitry Andric    iterator find(const key_type& __k)             {return __tree_.find(__k);}
14060b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14070b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
14080b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
14090b57cec5SDimitry Andric    template <typename _K2>
14100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14110b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
14120b57cec5SDimitry Andric    find(const _K2& __k)                           {return __tree_.find(__k);}
14130b57cec5SDimitry Andric    template <typename _K2>
14140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14150b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
14160b57cec5SDimitry Andric    find(const _K2& __k) const                     {return __tree_.find(__k);}
14170b57cec5SDimitry Andric#endif
14180b57cec5SDimitry Andric
14190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14200b57cec5SDimitry Andric    size_type      count(const key_type& __k) const
14210b57cec5SDimitry Andric        {return __tree_.__count_unique(__k);}
14220b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
14230b57cec5SDimitry Andric    template <typename _K2>
14240b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14250b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
14260b57cec5SDimitry Andric    count(const _K2& __k) const {return __tree_.__count_multi(__k);}
14270b57cec5SDimitry Andric#endif
14280b57cec5SDimitry Andric
14290b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
14300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14310b57cec5SDimitry Andric    bool contains(const key_type& __k) const {return find(__k) != end();}
1432*fe6060f1SDimitry Andric    template <typename _K2>
1433*fe6060f1SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1434*fe6060f1SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
1435*fe6060f1SDimitry Andric    contains(const _K2& __k) const { return find(__k) != end(); }
14360b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 17
14370b57cec5SDimitry Andric
14380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14390b57cec5SDimitry Andric    iterator lower_bound(const key_type& __k)
14400b57cec5SDimitry Andric        {return __tree_.lower_bound(__k);}
14410b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14420b57cec5SDimitry Andric    const_iterator lower_bound(const key_type& __k) const
14430b57cec5SDimitry Andric        {return __tree_.lower_bound(__k);}
14440b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
14450b57cec5SDimitry Andric    template <typename _K2>
14460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14470b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
14480b57cec5SDimitry Andric    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
14490b57cec5SDimitry Andric
14500b57cec5SDimitry Andric    template <typename _K2>
14510b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14520b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
14530b57cec5SDimitry Andric    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
14540b57cec5SDimitry Andric#endif
14550b57cec5SDimitry Andric
14560b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14570b57cec5SDimitry Andric    iterator upper_bound(const key_type& __k)
14580b57cec5SDimitry Andric        {return __tree_.upper_bound(__k);}
14590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14600b57cec5SDimitry Andric    const_iterator upper_bound(const key_type& __k) const
14610b57cec5SDimitry Andric        {return __tree_.upper_bound(__k);}
14620b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
14630b57cec5SDimitry Andric    template <typename _K2>
14640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14650b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
14660b57cec5SDimitry Andric    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
14670b57cec5SDimitry Andric    template <typename _K2>
14680b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14690b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
14700b57cec5SDimitry Andric    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
14710b57cec5SDimitry Andric#endif
14720b57cec5SDimitry Andric
14730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14740b57cec5SDimitry Andric    pair<iterator,iterator> equal_range(const key_type& __k)
14750b57cec5SDimitry Andric        {return __tree_.__equal_range_unique(__k);}
14760b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14770b57cec5SDimitry Andric    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
14780b57cec5SDimitry Andric        {return __tree_.__equal_range_unique(__k);}
14790b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
14800b57cec5SDimitry Andric    template <typename _K2>
14810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14820b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
14830b57cec5SDimitry Andric    equal_range(const _K2& __k)       {return __tree_.__equal_range_multi(__k);}
14840b57cec5SDimitry Andric    template <typename _K2>
14850b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14860b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
14870b57cec5SDimitry Andric    equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
14880b57cec5SDimitry Andric#endif
14890b57cec5SDimitry Andric
14900b57cec5SDimitry Andricprivate:
14910b57cec5SDimitry Andric    typedef typename __base::__node                    __node;
14920b57cec5SDimitry Andric    typedef typename __base::__node_allocator          __node_allocator;
14930b57cec5SDimitry Andric    typedef typename __base::__node_pointer            __node_pointer;
14940b57cec5SDimitry Andric    typedef typename __base::__node_base_pointer       __node_base_pointer;
14950b57cec5SDimitry Andric    typedef typename __base::__parent_pointer          __parent_pointer;
14960b57cec5SDimitry Andric
14970b57cec5SDimitry Andric    typedef __map_node_destructor<__node_allocator> _Dp;
14980b57cec5SDimitry Andric    typedef unique_ptr<__node, _Dp> __node_holder;
14990b57cec5SDimitry Andric
15000b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG
15010b57cec5SDimitry Andric    __node_holder __construct_node_with_key(const key_type& __k);
15020b57cec5SDimitry Andric#endif
15030b57cec5SDimitry Andric};
15040b57cec5SDimitry Andric
15050b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
15060b57cec5SDimitry Andrictemplate<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>,
15070b57cec5SDimitry Andric         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
1508e40139ffSDimitry Andric         class = _EnableIf<!__is_allocator<_Compare>::value, void>,
1509e40139ffSDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value, void>>
15100b57cec5SDimitry Andricmap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
15110b57cec5SDimitry Andric  -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
15120b57cec5SDimitry Andric
15130b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>,
15140b57cec5SDimitry Andric         class _Allocator = allocator<pair<const _Key, _Tp>>,
1515e40139ffSDimitry Andric         class = _EnableIf<!__is_allocator<_Compare>::value, void>,
1516e40139ffSDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value, void>>
15170b57cec5SDimitry Andricmap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
15180b57cec5SDimitry Andric  -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
15190b57cec5SDimitry Andric
15200b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
1521e40139ffSDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value, void>>
15220b57cec5SDimitry Andricmap(_InputIterator, _InputIterator, _Allocator)
15230b57cec5SDimitry Andric  -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
15240b57cec5SDimitry Andric         less<__iter_key_type<_InputIterator>>, _Allocator>;
15250b57cec5SDimitry Andric
15260b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
1527e40139ffSDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value, void>>
15280b57cec5SDimitry Andricmap(initializer_list<pair<_Key, _Tp>>, _Allocator)
15290b57cec5SDimitry Andric  -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
15300b57cec5SDimitry Andric#endif
15310b57cec5SDimitry Andric
15320b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
15330b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
15340b57cec5SDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
15350b57cec5SDimitry Andric    : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
15360b57cec5SDimitry Andric{
15370b57cec5SDimitry Andric    if (__a != __m.get_allocator())
15380b57cec5SDimitry Andric    {
15390b57cec5SDimitry Andric        const_iterator __e = cend();
15400b57cec5SDimitry Andric        while (!__m.empty())
15410b57cec5SDimitry Andric            __tree_.__insert_unique(__e.__i_,
15420b57cec5SDimitry Andric                    __m.__tree_.remove(__m.begin().__i_)->__value_.__move());
15430b57cec5SDimitry Andric    }
15440b57cec5SDimitry Andric}
15450b57cec5SDimitry Andric
15460b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
15470b57cec5SDimitry Andric_Tp&
15480b57cec5SDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
15490b57cec5SDimitry Andric{
15500b57cec5SDimitry Andric    return __tree_.__emplace_unique_key_args(__k,
15510b57cec5SDimitry Andric        _VSTD::piecewise_construct,
15520b57cec5SDimitry Andric        _VSTD::forward_as_tuple(__k),
15530b57cec5SDimitry Andric        _VSTD::forward_as_tuple()).first->__get_value().second;
15540b57cec5SDimitry Andric}
15550b57cec5SDimitry Andric
15560b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
15570b57cec5SDimitry Andric_Tp&
15580b57cec5SDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k)
15590b57cec5SDimitry Andric{
15600b57cec5SDimitry Andric    return __tree_.__emplace_unique_key_args(__k,
15610b57cec5SDimitry Andric        _VSTD::piecewise_construct,
15620b57cec5SDimitry Andric        _VSTD::forward_as_tuple(_VSTD::move(__k)),
15630b57cec5SDimitry Andric        _VSTD::forward_as_tuple()).first->__get_value().second;
15640b57cec5SDimitry Andric}
15650b57cec5SDimitry Andric
15660b57cec5SDimitry Andric#else // _LIBCPP_CXX03_LANG
15670b57cec5SDimitry Andric
15680b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
15690b57cec5SDimitry Andrictypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
15700b57cec5SDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k)
15710b57cec5SDimitry Andric{
15720b57cec5SDimitry Andric    __node_allocator& __na = __tree_.__node_alloc();
15730b57cec5SDimitry Andric    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
15740b57cec5SDimitry Andric    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k);
15750b57cec5SDimitry Andric    __h.get_deleter().__first_constructed = true;
15760b57cec5SDimitry Andric    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
15770b57cec5SDimitry Andric    __h.get_deleter().__second_constructed = true;
1578e8d8bef9SDimitry Andric    return __h;
15790b57cec5SDimitry Andric}
15800b57cec5SDimitry Andric
15810b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
15820b57cec5SDimitry Andric_Tp&
15830b57cec5SDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
15840b57cec5SDimitry Andric{
15850b57cec5SDimitry Andric    __parent_pointer __parent;
15860b57cec5SDimitry Andric    __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
15870b57cec5SDimitry Andric    __node_pointer __r = static_cast<__node_pointer>(__child);
15880b57cec5SDimitry Andric    if (__child == nullptr)
15890b57cec5SDimitry Andric    {
15900b57cec5SDimitry Andric        __node_holder __h = __construct_node_with_key(__k);
15910b57cec5SDimitry Andric        __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
15920b57cec5SDimitry Andric        __r = __h.release();
15930b57cec5SDimitry Andric    }
15940b57cec5SDimitry Andric    return __r->__value_.__get_value().second;
15950b57cec5SDimitry Andric}
15960b57cec5SDimitry Andric
15970b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
15980b57cec5SDimitry Andric
15990b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
16000b57cec5SDimitry Andric_Tp&
16010b57cec5SDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
16020b57cec5SDimitry Andric{
16030b57cec5SDimitry Andric    __parent_pointer __parent;
16040b57cec5SDimitry Andric    __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
16050b57cec5SDimitry Andric    if (__child == nullptr)
16060b57cec5SDimitry Andric        __throw_out_of_range("map::at:  key not found");
16070b57cec5SDimitry Andric    return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
16080b57cec5SDimitry Andric}
16090b57cec5SDimitry Andric
16100b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
16110b57cec5SDimitry Andricconst _Tp&
16120b57cec5SDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
16130b57cec5SDimitry Andric{
16140b57cec5SDimitry Andric    __parent_pointer __parent;
16150b57cec5SDimitry Andric    __node_base_pointer __child = __tree_.__find_equal(__parent, __k);
16160b57cec5SDimitry Andric    if (__child == nullptr)
16170b57cec5SDimitry Andric        __throw_out_of_range("map::at:  key not found");
16180b57cec5SDimitry Andric    return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
16190b57cec5SDimitry Andric}
16200b57cec5SDimitry Andric
16210b57cec5SDimitry Andric
16220b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
16230b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16240b57cec5SDimitry Andricbool
16250b57cec5SDimitry Andricoperator==(const map<_Key, _Tp, _Compare, _Allocator>& __x,
16260b57cec5SDimitry Andric           const map<_Key, _Tp, _Compare, _Allocator>& __y)
16270b57cec5SDimitry Andric{
16280b57cec5SDimitry Andric    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
16290b57cec5SDimitry Andric}
16300b57cec5SDimitry Andric
16310b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
16320b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16330b57cec5SDimitry Andricbool
16340b57cec5SDimitry Andricoperator< (const map<_Key, _Tp, _Compare, _Allocator>& __x,
16350b57cec5SDimitry Andric           const map<_Key, _Tp, _Compare, _Allocator>& __y)
16360b57cec5SDimitry Andric{
16370b57cec5SDimitry Andric    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
16380b57cec5SDimitry Andric}
16390b57cec5SDimitry Andric
16400b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
16410b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16420b57cec5SDimitry Andricbool
16430b57cec5SDimitry Andricoperator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
16440b57cec5SDimitry Andric           const map<_Key, _Tp, _Compare, _Allocator>& __y)
16450b57cec5SDimitry Andric{
16460b57cec5SDimitry Andric    return !(__x == __y);
16470b57cec5SDimitry Andric}
16480b57cec5SDimitry Andric
16490b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
16500b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16510b57cec5SDimitry Andricbool
16520b57cec5SDimitry Andricoperator> (const map<_Key, _Tp, _Compare, _Allocator>& __x,
16530b57cec5SDimitry Andric           const map<_Key, _Tp, _Compare, _Allocator>& __y)
16540b57cec5SDimitry Andric{
16550b57cec5SDimitry Andric    return __y < __x;
16560b57cec5SDimitry Andric}
16570b57cec5SDimitry Andric
16580b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
16590b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16600b57cec5SDimitry Andricbool
16610b57cec5SDimitry Andricoperator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
16620b57cec5SDimitry Andric           const map<_Key, _Tp, _Compare, _Allocator>& __y)
16630b57cec5SDimitry Andric{
16640b57cec5SDimitry Andric    return !(__x < __y);
16650b57cec5SDimitry Andric}
16660b57cec5SDimitry Andric
16670b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
16680b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16690b57cec5SDimitry Andricbool
16700b57cec5SDimitry Andricoperator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
16710b57cec5SDimitry Andric           const map<_Key, _Tp, _Compare, _Allocator>& __y)
16720b57cec5SDimitry Andric{
16730b57cec5SDimitry Andric    return !(__y < __x);
16740b57cec5SDimitry Andric}
16750b57cec5SDimitry Andric
16760b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
16770b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16780b57cec5SDimitry Andricvoid
16790b57cec5SDimitry Andricswap(map<_Key, _Tp, _Compare, _Allocator>& __x,
16800b57cec5SDimitry Andric     map<_Key, _Tp, _Compare, _Allocator>& __y)
16810b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
16820b57cec5SDimitry Andric{
16830b57cec5SDimitry Andric    __x.swap(__y);
16840b57cec5SDimitry Andric}
16850b57cec5SDimitry Andric
16860b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
16875ffd83dbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator,
16885ffd83dbSDimitry Andric          class _Predicate>
16890b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16905ffd83dbSDimitry Andric    typename map<_Key, _Tp, _Compare, _Allocator>::size_type
16915ffd83dbSDimitry Andric    erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {
1692*fe6060f1SDimitry Andric  return _VSTD::__libcpp_erase_if_container(__c, __pred);
16935ffd83dbSDimitry Andric}
16940b57cec5SDimitry Andric#endif
16950b57cec5SDimitry Andric
16960b57cec5SDimitry Andric
16970b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare = less<_Key>,
16980b57cec5SDimitry Andric          class _Allocator = allocator<pair<const _Key, _Tp> > >
16990b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS multimap
17000b57cec5SDimitry Andric{
17010b57cec5SDimitry Andricpublic:
17020b57cec5SDimitry Andric    // types:
17030b57cec5SDimitry Andric    typedef _Key                                     key_type;
17040b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
17050b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
1706*fe6060f1SDimitry Andric    typedef __identity_t<_Compare>                   key_compare;
1707*fe6060f1SDimitry Andric    typedef __identity_t<_Allocator>                 allocator_type;
17080b57cec5SDimitry Andric    typedef value_type&                              reference;
17090b57cec5SDimitry Andric    typedef const value_type&                        const_reference;
17100b57cec5SDimitry Andric
17110b57cec5SDimitry Andric    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
17120b57cec5SDimitry Andric                  "Allocator::value_type must be same type as value_type");
17130b57cec5SDimitry Andric
1714*fe6060f1SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
17150b57cec5SDimitry Andric    class _LIBCPP_TEMPLATE_VIS value_compare
1716*fe6060f1SDimitry Andric#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
17170b57cec5SDimitry Andric        : public binary_function<value_type, value_type, bool>
1718*fe6060f1SDimitry Andric#endif
17190b57cec5SDimitry Andric    {
1720*fe6060f1SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
17210b57cec5SDimitry Andric        friend class multimap;
17220b57cec5SDimitry Andric    protected:
17230b57cec5SDimitry Andric        key_compare comp;
17240b57cec5SDimitry Andric
17250b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
17260b57cec5SDimitry Andric        value_compare(key_compare c) : comp(c) {}
17270b57cec5SDimitry Andric    public:
1728*fe6060f1SDimitry Andric#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
1729*fe6060f1SDimitry Andric        _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
1730*fe6060f1SDimitry Andric        _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
1731*fe6060f1SDimitry Andric        _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
1732*fe6060f1SDimitry Andric#endif
17330b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
17340b57cec5SDimitry Andric        bool operator()(const value_type& __x, const value_type& __y) const
17350b57cec5SDimitry Andric            {return comp(__x.first, __y.first);}
17360b57cec5SDimitry Andric    };
17370b57cec5SDimitry Andric
17380b57cec5SDimitry Andricprivate:
17390b57cec5SDimitry Andric
17400b57cec5SDimitry Andric    typedef _VSTD::__value_type<key_type, mapped_type>             __value_type;
17410b57cec5SDimitry Andric    typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
17420b57cec5SDimitry Andric    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
17430b57cec5SDimitry Andric                                                 __value_type>::type __allocator_type;
17440b57cec5SDimitry Andric    typedef __tree<__value_type, __vc, __allocator_type>            __base;
17450b57cec5SDimitry Andric    typedef typename __base::__node_traits                          __node_traits;
17460b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>                        __alloc_traits;
17470b57cec5SDimitry Andric
17480b57cec5SDimitry Andric    __base __tree_;
17490b57cec5SDimitry Andric
17500b57cec5SDimitry Andricpublic:
17510b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer               pointer;
17520b57cec5SDimitry Andric    typedef typename __alloc_traits::const_pointer         const_pointer;
17530b57cec5SDimitry Andric    typedef typename __alloc_traits::size_type             size_type;
17540b57cec5SDimitry Andric    typedef typename __alloc_traits::difference_type       difference_type;
17550b57cec5SDimitry Andric    typedef __map_iterator<typename __base::iterator>      iterator;
17560b57cec5SDimitry Andric    typedef __map_const_iterator<typename __base::const_iterator> const_iterator;
17570b57cec5SDimitry Andric    typedef _VSTD::reverse_iterator<iterator>               reverse_iterator;
17580b57cec5SDimitry Andric    typedef _VSTD::reverse_iterator<const_iterator>         const_reverse_iterator;
17590b57cec5SDimitry Andric
17600b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
17610b57cec5SDimitry Andric    typedef __map_node_handle<typename __base::__node, allocator_type> node_type;
17620b57cec5SDimitry Andric#endif
17630b57cec5SDimitry Andric
17640b57cec5SDimitry Andric    template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
17650b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS map;
17660b57cec5SDimitry Andric    template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
17670b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS multimap;
17680b57cec5SDimitry Andric
17690b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
17700b57cec5SDimitry Andric    multimap()
17710b57cec5SDimitry Andric        _NOEXCEPT_(
17720b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value &&
17730b57cec5SDimitry Andric            is_nothrow_default_constructible<key_compare>::value &&
17740b57cec5SDimitry Andric            is_nothrow_copy_constructible<key_compare>::value)
17750b57cec5SDimitry Andric        : __tree_(__vc(key_compare())) {}
17760b57cec5SDimitry Andric
17770b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
17780b57cec5SDimitry Andric    explicit multimap(const key_compare& __comp)
17790b57cec5SDimitry Andric        _NOEXCEPT_(
17800b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value &&
17810b57cec5SDimitry Andric            is_nothrow_copy_constructible<key_compare>::value)
17820b57cec5SDimitry Andric        : __tree_(__vc(__comp)) {}
17830b57cec5SDimitry Andric
17840b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
17850b57cec5SDimitry Andric    explicit multimap(const key_compare& __comp, const allocator_type& __a)
17860b57cec5SDimitry Andric        : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
17870b57cec5SDimitry Andric
17880b57cec5SDimitry Andric    template <class _InputIterator>
17890b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
17900b57cec5SDimitry Andric        multimap(_InputIterator __f, _InputIterator __l,
17910b57cec5SDimitry Andric            const key_compare& __comp = key_compare())
17920b57cec5SDimitry Andric        : __tree_(__vc(__comp))
17930b57cec5SDimitry Andric        {
17940b57cec5SDimitry Andric            insert(__f, __l);
17950b57cec5SDimitry Andric        }
17960b57cec5SDimitry Andric
17970b57cec5SDimitry Andric    template <class _InputIterator>
17980b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
17990b57cec5SDimitry Andric        multimap(_InputIterator __f, _InputIterator __l,
18000b57cec5SDimitry Andric            const key_compare& __comp, const allocator_type& __a)
18010b57cec5SDimitry Andric        : __tree_(__vc(__comp), typename __base::allocator_type(__a))
18020b57cec5SDimitry Andric        {
18030b57cec5SDimitry Andric            insert(__f, __l);
18040b57cec5SDimitry Andric        }
18050b57cec5SDimitry Andric
18060b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
18070b57cec5SDimitry Andric    template <class _InputIterator>
18080b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18090b57cec5SDimitry Andric    multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
18100b57cec5SDimitry Andric        : multimap(__f, __l, key_compare(), __a) {}
18110b57cec5SDimitry Andric#endif
18120b57cec5SDimitry Andric
18130b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18140b57cec5SDimitry Andric    multimap(const multimap& __m)
18150b57cec5SDimitry Andric        : __tree_(__m.__tree_.value_comp(),
18160b57cec5SDimitry Andric          __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc()))
18170b57cec5SDimitry Andric        {
18180b57cec5SDimitry Andric            insert(__m.begin(), __m.end());
18190b57cec5SDimitry Andric        }
18200b57cec5SDimitry Andric
18210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18220b57cec5SDimitry Andric    multimap& operator=(const multimap& __m)
18230b57cec5SDimitry Andric        {
18240b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
18250b57cec5SDimitry Andric            __tree_ = __m.__tree_;
18260b57cec5SDimitry Andric#else
18270b57cec5SDimitry Andric            if (this != &__m) {
18280b57cec5SDimitry Andric                __tree_.clear();
18290b57cec5SDimitry Andric                __tree_.value_comp() = __m.__tree_.value_comp();
18300b57cec5SDimitry Andric                __tree_.__copy_assign_alloc(__m.__tree_);
18310b57cec5SDimitry Andric                insert(__m.begin(), __m.end());
18320b57cec5SDimitry Andric            }
18330b57cec5SDimitry Andric#endif
18340b57cec5SDimitry Andric            return *this;
18350b57cec5SDimitry Andric        }
18360b57cec5SDimitry Andric
18370b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
18380b57cec5SDimitry Andric
18390b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18400b57cec5SDimitry Andric    multimap(multimap&& __m)
18410b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
18420b57cec5SDimitry Andric        : __tree_(_VSTD::move(__m.__tree_))
18430b57cec5SDimitry Andric        {
18440b57cec5SDimitry Andric        }
18450b57cec5SDimitry Andric
18460b57cec5SDimitry Andric    multimap(multimap&& __m, const allocator_type& __a);
18470b57cec5SDimitry Andric
18480b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18490b57cec5SDimitry Andric    multimap& operator=(multimap&& __m)
18500b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
18510b57cec5SDimitry Andric        {
18520b57cec5SDimitry Andric            __tree_ = _VSTD::move(__m.__tree_);
18530b57cec5SDimitry Andric            return *this;
18540b57cec5SDimitry Andric        }
18550b57cec5SDimitry Andric
18560b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18570b57cec5SDimitry Andric    multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
18580b57cec5SDimitry Andric        : __tree_(__vc(__comp))
18590b57cec5SDimitry Andric        {
18600b57cec5SDimitry Andric            insert(__il.begin(), __il.end());
18610b57cec5SDimitry Andric        }
18620b57cec5SDimitry Andric
18630b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18640b57cec5SDimitry Andric    multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
18650b57cec5SDimitry Andric        : __tree_(__vc(__comp), typename __base::allocator_type(__a))
18660b57cec5SDimitry Andric        {
18670b57cec5SDimitry Andric            insert(__il.begin(), __il.end());
18680b57cec5SDimitry Andric        }
18690b57cec5SDimitry Andric
18700b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
18710b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18720b57cec5SDimitry Andric    multimap(initializer_list<value_type> __il, const allocator_type& __a)
18730b57cec5SDimitry Andric        : multimap(__il, key_compare(), __a) {}
18740b57cec5SDimitry Andric#endif
18750b57cec5SDimitry Andric
18760b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18770b57cec5SDimitry Andric    multimap& operator=(initializer_list<value_type> __il)
18780b57cec5SDimitry Andric        {
18790b57cec5SDimitry Andric            __tree_.__assign_multi(__il.begin(), __il.end());
18800b57cec5SDimitry Andric            return *this;
18810b57cec5SDimitry Andric        }
18820b57cec5SDimitry Andric
18830b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
18840b57cec5SDimitry Andric
18850b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18860b57cec5SDimitry Andric    explicit multimap(const allocator_type& __a)
18870b57cec5SDimitry Andric        : __tree_(typename __base::allocator_type(__a))
18880b57cec5SDimitry Andric        {
18890b57cec5SDimitry Andric        }
18900b57cec5SDimitry Andric
18910b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18920b57cec5SDimitry Andric    multimap(const multimap& __m, const allocator_type& __a)
18930b57cec5SDimitry Andric        : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
18940b57cec5SDimitry Andric        {
18950b57cec5SDimitry Andric            insert(__m.begin(), __m.end());
18960b57cec5SDimitry Andric        }
18970b57cec5SDimitry Andric
18980b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
18990b57cec5SDimitry Andric    ~multimap() {
19000b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
19010b57cec5SDimitry Andric    }
19020b57cec5SDimitry Andric
19030b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19040b57cec5SDimitry Andric          iterator begin() _NOEXCEPT {return __tree_.begin();}
19050b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19060b57cec5SDimitry Andric    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
19070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19080b57cec5SDimitry Andric          iterator end() _NOEXCEPT {return __tree_.end();}
19090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19100b57cec5SDimitry Andric    const_iterator end() const _NOEXCEPT {return __tree_.end();}
19110b57cec5SDimitry Andric
19120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19130b57cec5SDimitry Andric          reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
19140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19150b57cec5SDimitry Andric    const_reverse_iterator rbegin() const _NOEXCEPT
19160b57cec5SDimitry Andric        {return const_reverse_iterator(end());}
19170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19180b57cec5SDimitry Andric          reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
19190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19200b57cec5SDimitry Andric    const_reverse_iterator rend() const _NOEXCEPT
19210b57cec5SDimitry Andric        {return const_reverse_iterator(begin());}
19220b57cec5SDimitry Andric
19230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19240b57cec5SDimitry Andric    const_iterator cbegin()  const _NOEXCEPT {return begin();}
19250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19260b57cec5SDimitry Andric    const_iterator cend() const _NOEXCEPT {return end();}
19270b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19280b57cec5SDimitry Andric    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
19290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19300b57cec5SDimitry Andric    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
19310b57cec5SDimitry Andric
19320b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
19330b57cec5SDimitry Andric    bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
19340b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19350b57cec5SDimitry Andric    size_type size() const _NOEXCEPT {return __tree_.size();}
19360b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19370b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
19380b57cec5SDimitry Andric
19390b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19400b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
19410b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19420b57cec5SDimitry Andric    key_compare    key_comp() const {return __tree_.value_comp().key_comp();}
19430b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19440b57cec5SDimitry Andric    value_compare  value_comp() const
19450b57cec5SDimitry Andric        {return value_compare(__tree_.value_comp().key_comp());}
19460b57cec5SDimitry Andric
19470b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
19480b57cec5SDimitry Andric
19490b57cec5SDimitry Andric    template <class ..._Args>
19500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19510b57cec5SDimitry Andric    iterator emplace(_Args&& ...__args) {
19520b57cec5SDimitry Andric        return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
19530b57cec5SDimitry Andric    }
19540b57cec5SDimitry Andric
19550b57cec5SDimitry Andric    template <class ..._Args>
19560b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19570b57cec5SDimitry Andric    iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
19580b57cec5SDimitry Andric        return __tree_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
19590b57cec5SDimitry Andric    }
19600b57cec5SDimitry Andric
19610b57cec5SDimitry Andric    template <class _Pp,
19620b57cec5SDimitry Andric              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
19630b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
19640b57cec5SDimitry Andric        iterator insert(_Pp&& __p)
19650b57cec5SDimitry Andric            {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));}
19660b57cec5SDimitry Andric
19670b57cec5SDimitry Andric    template <class _Pp,
19680b57cec5SDimitry Andric              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
19690b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
19700b57cec5SDimitry Andric        iterator insert(const_iterator __pos, _Pp&& __p)
19710b57cec5SDimitry Andric            {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));}
19720b57cec5SDimitry Andric
19730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19740b57cec5SDimitry Andric    iterator insert(value_type&& __v)
19750b57cec5SDimitry Andric        {return __tree_.__insert_multi(_VSTD::move(__v));}
19760b57cec5SDimitry Andric
19770b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19780b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __v)
19790b57cec5SDimitry Andric        {return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));}
19800b57cec5SDimitry Andric
19810b57cec5SDimitry Andric
19820b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19830b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
19840b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
19850b57cec5SDimitry Andric
19860b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
19870b57cec5SDimitry Andric
19880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19890b57cec5SDimitry Andric    iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);}
19900b57cec5SDimitry Andric
19910b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19920b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __v)
19930b57cec5SDimitry Andric            {return __tree_.__insert_multi(__p.__i_, __v);}
19940b57cec5SDimitry Andric
19950b57cec5SDimitry Andric    template <class _InputIterator>
19960b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
19970b57cec5SDimitry Andric        void insert(_InputIterator __f, _InputIterator __l)
19980b57cec5SDimitry Andric        {
19990b57cec5SDimitry Andric            for (const_iterator __e = cend(); __f != __l; ++__f)
20000b57cec5SDimitry Andric                __tree_.__insert_multi(__e.__i_, *__f);
20010b57cec5SDimitry Andric        }
20020b57cec5SDimitry Andric
20030b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20040b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
20050b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20060b57cec5SDimitry Andric    iterator erase(iterator __p)       {return __tree_.erase(__p.__i_);}
20070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20080b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
20090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20100b57cec5SDimitry Andric    iterator  erase(const_iterator __f, const_iterator __l)
20110b57cec5SDimitry Andric        {return __tree_.erase(__f.__i_, __l.__i_);}
20120b57cec5SDimitry Andric
20130b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
20140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20150b57cec5SDimitry Andric    iterator insert(node_type&& __nh)
20160b57cec5SDimitry Andric    {
20170b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
20180b57cec5SDimitry Andric            "node_type with incompatible allocator passed to multimap::insert()");
20190b57cec5SDimitry Andric        return __tree_.template __node_handle_insert_multi<node_type>(
20200b57cec5SDimitry Andric            _VSTD::move(__nh));
20210b57cec5SDimitry Andric    }
20220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20230b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
20240b57cec5SDimitry Andric    {
20250b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
20260b57cec5SDimitry Andric            "node_type with incompatible allocator passed to multimap::insert()");
20270b57cec5SDimitry Andric        return __tree_.template __node_handle_insert_multi<node_type>(
20280b57cec5SDimitry Andric            __hint.__i_, _VSTD::move(__nh));
20290b57cec5SDimitry Andric    }
20300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20310b57cec5SDimitry Andric    node_type extract(key_type const& __key)
20320b57cec5SDimitry Andric    {
20330b57cec5SDimitry Andric        return __tree_.template __node_handle_extract<node_type>(__key);
20340b57cec5SDimitry Andric    }
20350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20360b57cec5SDimitry Andric    node_type extract(const_iterator __it)
20370b57cec5SDimitry Andric    {
20380b57cec5SDimitry Andric        return __tree_.template __node_handle_extract<node_type>(
20390b57cec5SDimitry Andric            __it.__i_);
20400b57cec5SDimitry Andric    }
20410b57cec5SDimitry Andric    template <class _Compare2>
20420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20430b57cec5SDimitry Andric    void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source)
20440b57cec5SDimitry Andric    {
20450b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
20460b57cec5SDimitry Andric                       "merging container with incompatible allocator");
20470b57cec5SDimitry Andric        return __tree_.__node_handle_merge_multi(__source.__tree_);
20480b57cec5SDimitry Andric    }
20490b57cec5SDimitry Andric    template <class _Compare2>
20500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20510b57cec5SDimitry Andric    void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source)
20520b57cec5SDimitry Andric    {
20530b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
20540b57cec5SDimitry Andric                       "merging container with incompatible allocator");
20550b57cec5SDimitry Andric        return __tree_.__node_handle_merge_multi(__source.__tree_);
20560b57cec5SDimitry Andric    }
20570b57cec5SDimitry Andric    template <class _Compare2>
20580b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20590b57cec5SDimitry Andric    void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source)
20600b57cec5SDimitry Andric    {
20610b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
20620b57cec5SDimitry Andric                       "merging container with incompatible allocator");
20630b57cec5SDimitry Andric        return __tree_.__node_handle_merge_multi(__source.__tree_);
20640b57cec5SDimitry Andric    }
20650b57cec5SDimitry Andric    template <class _Compare2>
20660b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20670b57cec5SDimitry Andric    void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source)
20680b57cec5SDimitry Andric    {
20690b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
20700b57cec5SDimitry Andric                       "merging container with incompatible allocator");
20710b57cec5SDimitry Andric        return __tree_.__node_handle_merge_multi(__source.__tree_);
20720b57cec5SDimitry Andric    }
20730b57cec5SDimitry Andric#endif
20740b57cec5SDimitry Andric
20750b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20760b57cec5SDimitry Andric    void clear() _NOEXCEPT {__tree_.clear();}
20770b57cec5SDimitry Andric
20780b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20790b57cec5SDimitry Andric    void swap(multimap& __m)
20800b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
20810b57cec5SDimitry Andric        {__tree_.swap(__m.__tree_);}
20820b57cec5SDimitry Andric
20830b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20840b57cec5SDimitry Andric    iterator find(const key_type& __k)             {return __tree_.find(__k);}
20850b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20860b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
20870b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
20880b57cec5SDimitry Andric    template <typename _K2>
20890b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20900b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
20910b57cec5SDimitry Andric    find(const _K2& __k)                           {return __tree_.find(__k);}
20920b57cec5SDimitry Andric    template <typename _K2>
20930b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20940b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
20950b57cec5SDimitry Andric    find(const _K2& __k) const                     {return __tree_.find(__k);}
20960b57cec5SDimitry Andric#endif
20970b57cec5SDimitry Andric
20980b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20990b57cec5SDimitry Andric    size_type      count(const key_type& __k) const
21000b57cec5SDimitry Andric        {return __tree_.__count_multi(__k);}
21010b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
21020b57cec5SDimitry Andric    template <typename _K2>
21030b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21040b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
21050b57cec5SDimitry Andric    count(const _K2& __k) const {return __tree_.__count_multi(__k);}
21060b57cec5SDimitry Andric#endif
21070b57cec5SDimitry Andric
21080b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
21090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21100b57cec5SDimitry Andric    bool contains(const key_type& __k) const {return find(__k) != end();}
2111*fe6060f1SDimitry Andric    template <typename _K2>
2112*fe6060f1SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2113*fe6060f1SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
2114*fe6060f1SDimitry Andric    contains(const _K2& __k) const { return find(__k) != end(); }
21150b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 17
21160b57cec5SDimitry Andric
21170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21180b57cec5SDimitry Andric    iterator lower_bound(const key_type& __k)
21190b57cec5SDimitry Andric        {return __tree_.lower_bound(__k);}
21200b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21210b57cec5SDimitry Andric    const_iterator lower_bound(const key_type& __k) const
21220b57cec5SDimitry Andric            {return __tree_.lower_bound(__k);}
21230b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
21240b57cec5SDimitry Andric    template <typename _K2>
21250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21260b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
21270b57cec5SDimitry Andric    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
21280b57cec5SDimitry Andric
21290b57cec5SDimitry Andric    template <typename _K2>
21300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21310b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
21320b57cec5SDimitry Andric    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
21330b57cec5SDimitry Andric#endif
21340b57cec5SDimitry Andric
21350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21360b57cec5SDimitry Andric    iterator upper_bound(const key_type& __k)
21370b57cec5SDimitry Andric            {return __tree_.upper_bound(__k);}
21380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21390b57cec5SDimitry Andric    const_iterator upper_bound(const key_type& __k) const
21400b57cec5SDimitry Andric            {return __tree_.upper_bound(__k);}
21410b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
21420b57cec5SDimitry Andric    template <typename _K2>
21430b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21440b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
21450b57cec5SDimitry Andric    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
21460b57cec5SDimitry Andric    template <typename _K2>
21470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21480b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
21490b57cec5SDimitry Andric    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
21500b57cec5SDimitry Andric#endif
21510b57cec5SDimitry Andric
21520b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21530b57cec5SDimitry Andric    pair<iterator,iterator>             equal_range(const key_type& __k)
21540b57cec5SDimitry Andric            {return __tree_.__equal_range_multi(__k);}
21550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21560b57cec5SDimitry Andric    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
21570b57cec5SDimitry Andric            {return __tree_.__equal_range_multi(__k);}
21580b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
21590b57cec5SDimitry Andric    template <typename _K2>
21600b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21610b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
21620b57cec5SDimitry Andric    equal_range(const _K2& __k)       {return __tree_.__equal_range_multi(__k);}
21630b57cec5SDimitry Andric    template <typename _K2>
21640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21650b57cec5SDimitry Andric    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
21660b57cec5SDimitry Andric    equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
21670b57cec5SDimitry Andric#endif
21680b57cec5SDimitry Andric
21690b57cec5SDimitry Andricprivate:
21700b57cec5SDimitry Andric    typedef typename __base::__node                    __node;
21710b57cec5SDimitry Andric    typedef typename __base::__node_allocator          __node_allocator;
21720b57cec5SDimitry Andric    typedef typename __base::__node_pointer            __node_pointer;
21730b57cec5SDimitry Andric
21740b57cec5SDimitry Andric    typedef __map_node_destructor<__node_allocator> _Dp;
21750b57cec5SDimitry Andric    typedef unique_ptr<__node, _Dp> __node_holder;
21760b57cec5SDimitry Andric};
21770b57cec5SDimitry Andric
21780b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
21790b57cec5SDimitry Andrictemplate<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>,
21800b57cec5SDimitry Andric         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
2181e40139ffSDimitry Andric         class = _EnableIf<!__is_allocator<_Compare>::value, void>,
2182e40139ffSDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value, void>>
21830b57cec5SDimitry Andricmultimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
21840b57cec5SDimitry Andric  -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
21850b57cec5SDimitry Andric
21860b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>,
21870b57cec5SDimitry Andric         class _Allocator = allocator<pair<const _Key, _Tp>>,
2188e40139ffSDimitry Andric         class = _EnableIf<!__is_allocator<_Compare>::value, void>,
2189e40139ffSDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value, void>>
21900b57cec5SDimitry Andricmultimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
21910b57cec5SDimitry Andric  -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
21920b57cec5SDimitry Andric
21930b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
2194e40139ffSDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value, void>>
21950b57cec5SDimitry Andricmultimap(_InputIterator, _InputIterator, _Allocator)
21960b57cec5SDimitry Andric  -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
21970b57cec5SDimitry Andric         less<__iter_key_type<_InputIterator>>, _Allocator>;
21980b57cec5SDimitry Andric
21990b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
2200e40139ffSDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value, void>>
22010b57cec5SDimitry Andricmultimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
22020b57cec5SDimitry Andric  -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
22030b57cec5SDimitry Andric#endif
22040b57cec5SDimitry Andric
22050b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
22060b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
22070b57cec5SDimitry Andricmultimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
22080b57cec5SDimitry Andric    : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
22090b57cec5SDimitry Andric{
22100b57cec5SDimitry Andric    if (__a != __m.get_allocator())
22110b57cec5SDimitry Andric    {
22120b57cec5SDimitry Andric        const_iterator __e = cend();
22130b57cec5SDimitry Andric        while (!__m.empty())
22140b57cec5SDimitry Andric            __tree_.__insert_multi(__e.__i_,
22150b57cec5SDimitry Andric                    _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move()));
22160b57cec5SDimitry Andric    }
22170b57cec5SDimitry Andric}
22180b57cec5SDimitry Andric#endif
22190b57cec5SDimitry Andric
22200b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
22210b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
22220b57cec5SDimitry Andricbool
22230b57cec5SDimitry Andricoperator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
22240b57cec5SDimitry Andric           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
22250b57cec5SDimitry Andric{
22260b57cec5SDimitry Andric    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
22270b57cec5SDimitry Andric}
22280b57cec5SDimitry Andric
22290b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
22300b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
22310b57cec5SDimitry Andricbool
22320b57cec5SDimitry Andricoperator< (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
22330b57cec5SDimitry Andric           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
22340b57cec5SDimitry Andric{
22350b57cec5SDimitry Andric    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
22360b57cec5SDimitry Andric}
22370b57cec5SDimitry Andric
22380b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
22390b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
22400b57cec5SDimitry Andricbool
22410b57cec5SDimitry Andricoperator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
22420b57cec5SDimitry Andric           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
22430b57cec5SDimitry Andric{
22440b57cec5SDimitry Andric    return !(__x == __y);
22450b57cec5SDimitry Andric}
22460b57cec5SDimitry Andric
22470b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
22480b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
22490b57cec5SDimitry Andricbool
22500b57cec5SDimitry Andricoperator> (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
22510b57cec5SDimitry Andric           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
22520b57cec5SDimitry Andric{
22530b57cec5SDimitry Andric    return __y < __x;
22540b57cec5SDimitry Andric}
22550b57cec5SDimitry Andric
22560b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
22570b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
22580b57cec5SDimitry Andricbool
22590b57cec5SDimitry Andricoperator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
22600b57cec5SDimitry Andric           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
22610b57cec5SDimitry Andric{
22620b57cec5SDimitry Andric    return !(__x < __y);
22630b57cec5SDimitry Andric}
22640b57cec5SDimitry Andric
22650b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
22660b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
22670b57cec5SDimitry Andricbool
22680b57cec5SDimitry Andricoperator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
22690b57cec5SDimitry Andric           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
22700b57cec5SDimitry Andric{
22710b57cec5SDimitry Andric    return !(__y < __x);
22720b57cec5SDimitry Andric}
22730b57cec5SDimitry Andric
22740b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator>
22750b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
22760b57cec5SDimitry Andricvoid
22770b57cec5SDimitry Andricswap(multimap<_Key, _Tp, _Compare, _Allocator>& __x,
22780b57cec5SDimitry Andric     multimap<_Key, _Tp, _Compare, _Allocator>& __y)
22790b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
22800b57cec5SDimitry Andric{
22810b57cec5SDimitry Andric    __x.swap(__y);
22820b57cec5SDimitry Andric}
22830b57cec5SDimitry Andric
22840b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
22855ffd83dbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator,
22865ffd83dbSDimitry Andric          class _Predicate>
22870b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
22885ffd83dbSDimitry Andric    typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type
22895ffd83dbSDimitry Andric    erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c,
22905ffd83dbSDimitry Andric             _Predicate __pred) {
2291*fe6060f1SDimitry Andric  return _VSTD::__libcpp_erase_if_container(__c, __pred);
22925ffd83dbSDimitry Andric}
22930b57cec5SDimitry Andric#endif
22940b57cec5SDimitry Andric
22950b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
22960b57cec5SDimitry Andric
22970b57cec5SDimitry Andric#endif // _LIBCPP_MAP
2298