14684ddb6SLionel Sambuc// -*- C++ -*- 24684ddb6SLionel Sambuc//===----------------------------- map ------------------------------------===// 34684ddb6SLionel Sambuc// 44684ddb6SLionel Sambuc// The LLVM Compiler Infrastructure 54684ddb6SLionel Sambuc// 64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open 74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details. 84684ddb6SLionel Sambuc// 94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===// 104684ddb6SLionel Sambuc 114684ddb6SLionel Sambuc#ifndef _LIBCPP_MAP 124684ddb6SLionel Sambuc#define _LIBCPP_MAP 134684ddb6SLionel Sambuc 144684ddb6SLionel Sambuc/* 154684ddb6SLionel Sambuc 164684ddb6SLionel Sambuc map synopsis 174684ddb6SLionel Sambuc 184684ddb6SLionel Sambucnamespace std 194684ddb6SLionel Sambuc{ 204684ddb6SLionel Sambuc 214684ddb6SLionel Sambuctemplate <class Key, class T, class Compare = less<Key>, 224684ddb6SLionel Sambuc class Allocator = allocator<pair<const Key, T>>> 234684ddb6SLionel Sambucclass map 244684ddb6SLionel Sambuc{ 254684ddb6SLionel Sambucpublic: 264684ddb6SLionel Sambuc // types: 274684ddb6SLionel Sambuc typedef Key key_type; 284684ddb6SLionel Sambuc typedef T mapped_type; 294684ddb6SLionel Sambuc typedef pair<const key_type, mapped_type> value_type; 304684ddb6SLionel Sambuc typedef Compare key_compare; 314684ddb6SLionel Sambuc typedef Allocator allocator_type; 324684ddb6SLionel Sambuc typedef typename allocator_type::reference reference; 334684ddb6SLionel Sambuc typedef typename allocator_type::const_reference const_reference; 344684ddb6SLionel Sambuc typedef typename allocator_type::pointer pointer; 354684ddb6SLionel Sambuc typedef typename allocator_type::const_pointer const_pointer; 364684ddb6SLionel Sambuc typedef typename allocator_type::size_type size_type; 374684ddb6SLionel Sambuc typedef typename allocator_type::difference_type difference_type; 384684ddb6SLionel Sambuc 394684ddb6SLionel Sambuc typedef implementation-defined iterator; 404684ddb6SLionel Sambuc typedef implementation-defined const_iterator; 414684ddb6SLionel Sambuc typedef std::reverse_iterator<iterator> reverse_iterator; 424684ddb6SLionel Sambuc typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 434684ddb6SLionel Sambuc 444684ddb6SLionel Sambuc class value_compare 454684ddb6SLionel Sambuc : public binary_function<value_type, value_type, bool> 464684ddb6SLionel Sambuc { 474684ddb6SLionel Sambuc friend class map; 484684ddb6SLionel Sambuc protected: 494684ddb6SLionel Sambuc key_compare comp; 504684ddb6SLionel Sambuc 514684ddb6SLionel Sambuc value_compare(key_compare c); 524684ddb6SLionel Sambuc public: 534684ddb6SLionel Sambuc bool operator()(const value_type& x, const value_type& y) const; 544684ddb6SLionel Sambuc }; 554684ddb6SLionel Sambuc 564684ddb6SLionel Sambuc // construct/copy/destroy: 574684ddb6SLionel Sambuc map() 584684ddb6SLionel Sambuc noexcept( 594684ddb6SLionel Sambuc is_nothrow_default_constructible<allocator_type>::value && 604684ddb6SLionel Sambuc is_nothrow_default_constructible<key_compare>::value && 614684ddb6SLionel Sambuc is_nothrow_copy_constructible<key_compare>::value); 624684ddb6SLionel Sambuc explicit map(const key_compare& comp); 634684ddb6SLionel Sambuc map(const key_compare& comp, const allocator_type& a); 644684ddb6SLionel Sambuc template <class InputIterator> 654684ddb6SLionel Sambuc map(InputIterator first, InputIterator last, 664684ddb6SLionel Sambuc const key_compare& comp = key_compare()); 674684ddb6SLionel Sambuc template <class InputIterator> 684684ddb6SLionel Sambuc map(InputIterator first, InputIterator last, 694684ddb6SLionel Sambuc const key_compare& comp, const allocator_type& a); 704684ddb6SLionel Sambuc map(const map& m); 714684ddb6SLionel Sambuc map(map&& m) 724684ddb6SLionel Sambuc noexcept( 734684ddb6SLionel Sambuc is_nothrow_move_constructible<allocator_type>::value && 744684ddb6SLionel Sambuc is_nothrow_move_constructible<key_compare>::value); 754684ddb6SLionel Sambuc explicit map(const allocator_type& a); 764684ddb6SLionel Sambuc map(const map& m, const allocator_type& a); 774684ddb6SLionel Sambuc map(map&& m, const allocator_type& a); 784684ddb6SLionel Sambuc map(initializer_list<value_type> il, const key_compare& comp = key_compare()); 794684ddb6SLionel Sambuc map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); 804684ddb6SLionel Sambuc template <class InputIterator> 814684ddb6SLionel Sambuc map(InputIterator first, InputIterator last, const allocator_type& a) 824684ddb6SLionel Sambuc : map(first, last, Compare(), a) {} // C++14 834684ddb6SLionel Sambuc map(initializer_list<value_type> il, const allocator_type& a) 844684ddb6SLionel Sambuc : map(il, Compare(), a) {} // C++14 854684ddb6SLionel Sambuc ~map(); 864684ddb6SLionel Sambuc 874684ddb6SLionel Sambuc map& operator=(const map& m); 884684ddb6SLionel Sambuc map& operator=(map&& m) 894684ddb6SLionel Sambuc noexcept( 904684ddb6SLionel Sambuc allocator_type::propagate_on_container_move_assignment::value && 914684ddb6SLionel Sambuc is_nothrow_move_assignable<allocator_type>::value && 924684ddb6SLionel Sambuc is_nothrow_move_assignable<key_compare>::value); 934684ddb6SLionel Sambuc map& operator=(initializer_list<value_type> il); 944684ddb6SLionel Sambuc 954684ddb6SLionel Sambuc // iterators: 964684ddb6SLionel Sambuc iterator begin() noexcept; 974684ddb6SLionel Sambuc const_iterator begin() const noexcept; 984684ddb6SLionel Sambuc iterator end() noexcept; 994684ddb6SLionel Sambuc const_iterator end() const noexcept; 1004684ddb6SLionel Sambuc 1014684ddb6SLionel Sambuc reverse_iterator rbegin() noexcept; 1024684ddb6SLionel Sambuc const_reverse_iterator rbegin() const noexcept; 1034684ddb6SLionel Sambuc reverse_iterator rend() noexcept; 1044684ddb6SLionel Sambuc const_reverse_iterator rend() const noexcept; 1054684ddb6SLionel Sambuc 1064684ddb6SLionel Sambuc const_iterator cbegin() const noexcept; 1074684ddb6SLionel Sambuc const_iterator cend() const noexcept; 1084684ddb6SLionel Sambuc const_reverse_iterator crbegin() const noexcept; 1094684ddb6SLionel Sambuc const_reverse_iterator crend() const noexcept; 1104684ddb6SLionel Sambuc 1114684ddb6SLionel Sambuc // capacity: 1124684ddb6SLionel Sambuc bool empty() const noexcept; 1134684ddb6SLionel Sambuc size_type size() const noexcept; 1144684ddb6SLionel Sambuc size_type max_size() const noexcept; 1154684ddb6SLionel Sambuc 1164684ddb6SLionel Sambuc // element access: 1174684ddb6SLionel Sambuc mapped_type& operator[](const key_type& k); 1184684ddb6SLionel Sambuc mapped_type& operator[](key_type&& k); 1194684ddb6SLionel Sambuc 1204684ddb6SLionel Sambuc mapped_type& at(const key_type& k); 1214684ddb6SLionel Sambuc const mapped_type& at(const key_type& k) const; 1224684ddb6SLionel Sambuc 1234684ddb6SLionel Sambuc // modifiers: 1244684ddb6SLionel Sambuc template <class... Args> 1254684ddb6SLionel Sambuc pair<iterator, bool> emplace(Args&&... args); 1264684ddb6SLionel Sambuc template <class... Args> 1274684ddb6SLionel Sambuc iterator emplace_hint(const_iterator position, Args&&... args); 1284684ddb6SLionel Sambuc pair<iterator, bool> insert(const value_type& v); 1294684ddb6SLionel Sambuc template <class P> 1304684ddb6SLionel Sambuc pair<iterator, bool> insert(P&& p); 1314684ddb6SLionel Sambuc iterator insert(const_iterator position, const value_type& v); 1324684ddb6SLionel Sambuc template <class P> 1334684ddb6SLionel Sambuc iterator insert(const_iterator position, P&& p); 1344684ddb6SLionel Sambuc template <class InputIterator> 1354684ddb6SLionel Sambuc void insert(InputIterator first, InputIterator last); 1364684ddb6SLionel Sambuc void insert(initializer_list<value_type> il); 1374684ddb6SLionel Sambuc 138*0a6a1f1dSLionel Sambuc template <class... Args> 139*0a6a1f1dSLionel Sambuc pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17 140*0a6a1f1dSLionel Sambuc template <class... Args> 141*0a6a1f1dSLionel Sambuc pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17 142*0a6a1f1dSLionel Sambuc template <class... Args> 143*0a6a1f1dSLionel Sambuc iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 144*0a6a1f1dSLionel Sambuc template <class... Args> 145*0a6a1f1dSLionel Sambuc iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 146*0a6a1f1dSLionel Sambuc template <class M> 147*0a6a1f1dSLionel Sambuc pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17 148*0a6a1f1dSLionel Sambuc template <class M> 149*0a6a1f1dSLionel Sambuc pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17 150*0a6a1f1dSLionel Sambuc template <class M> 151*0a6a1f1dSLionel Sambuc iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 152*0a6a1f1dSLionel Sambuc template <class M> 153*0a6a1f1dSLionel Sambuc iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 154*0a6a1f1dSLionel Sambuc 1554684ddb6SLionel Sambuc iterator erase(const_iterator position); 156*0a6a1f1dSLionel Sambuc iterator erase(iterator position); // C++14 1574684ddb6SLionel Sambuc size_type erase(const key_type& k); 1584684ddb6SLionel Sambuc iterator erase(const_iterator first, const_iterator last); 1594684ddb6SLionel Sambuc void clear() noexcept; 1604684ddb6SLionel Sambuc 1614684ddb6SLionel Sambuc void swap(map& m) 162*0a6a1f1dSLionel Sambuc noexcept(allocator_traits<allocator_type>::is_always_equal::value && 163*0a6a1f1dSLionel Sambuc __is_nothrow_swappable<key_compare>::value); // C++17 1644684ddb6SLionel Sambuc 1654684ddb6SLionel Sambuc // observers: 1664684ddb6SLionel Sambuc allocator_type get_allocator() const noexcept; 1674684ddb6SLionel Sambuc key_compare key_comp() const; 1684684ddb6SLionel Sambuc value_compare value_comp() const; 1694684ddb6SLionel Sambuc 1704684ddb6SLionel Sambuc // map operations: 1714684ddb6SLionel Sambuc iterator find(const key_type& k); 1724684ddb6SLionel Sambuc const_iterator find(const key_type& k) const; 1734684ddb6SLionel Sambuc template<typename K> 1744684ddb6SLionel Sambuc iterator find(const K& x); // C++14 1754684ddb6SLionel Sambuc template<typename K> 1764684ddb6SLionel Sambuc const_iterator find(const K& x) const; // C++14 1774684ddb6SLionel Sambuc template<typename K> 178*0a6a1f1dSLionel Sambuc size_type count(const K& x) const; // C++14 1794684ddb6SLionel Sambuc 1804684ddb6SLionel Sambuc size_type count(const key_type& k) const; 1814684ddb6SLionel Sambuc iterator lower_bound(const key_type& k); 1824684ddb6SLionel Sambuc const_iterator lower_bound(const key_type& k) const; 1834684ddb6SLionel Sambuc template<typename K> 1844684ddb6SLionel Sambuc iterator lower_bound(const K& x); // C++14 1854684ddb6SLionel Sambuc template<typename K> 1864684ddb6SLionel Sambuc const_iterator lower_bound(const K& x) const; // C++14 1874684ddb6SLionel Sambuc 1884684ddb6SLionel Sambuc iterator upper_bound(const key_type& k); 1894684ddb6SLionel Sambuc const_iterator upper_bound(const key_type& k) const; 1904684ddb6SLionel Sambuc template<typename K> 1914684ddb6SLionel Sambuc iterator upper_bound(const K& x); // C++14 1924684ddb6SLionel Sambuc template<typename K> 1934684ddb6SLionel Sambuc const_iterator upper_bound(const K& x) const; // C++14 1944684ddb6SLionel Sambuc 1954684ddb6SLionel Sambuc pair<iterator,iterator> equal_range(const key_type& k); 1964684ddb6SLionel Sambuc pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 1974684ddb6SLionel Sambuc template<typename K> 1984684ddb6SLionel Sambuc pair<iterator,iterator> equal_range(const K& x); // C++14 1994684ddb6SLionel Sambuc template<typename K> 2004684ddb6SLionel Sambuc pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 2014684ddb6SLionel Sambuc}; 2024684ddb6SLionel Sambuc 2034684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 2044684ddb6SLionel Sambucbool 2054684ddb6SLionel Sambucoperator==(const map<Key, T, Compare, Allocator>& x, 2064684ddb6SLionel Sambuc const map<Key, T, Compare, Allocator>& y); 2074684ddb6SLionel Sambuc 2084684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 2094684ddb6SLionel Sambucbool 2104684ddb6SLionel Sambucoperator< (const map<Key, T, Compare, Allocator>& x, 2114684ddb6SLionel Sambuc const map<Key, T, Compare, Allocator>& y); 2124684ddb6SLionel Sambuc 2134684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 2144684ddb6SLionel Sambucbool 2154684ddb6SLionel Sambucoperator!=(const map<Key, T, Compare, Allocator>& x, 2164684ddb6SLionel Sambuc const map<Key, T, Compare, Allocator>& y); 2174684ddb6SLionel Sambuc 2184684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 2194684ddb6SLionel Sambucbool 2204684ddb6SLionel Sambucoperator> (const map<Key, T, Compare, Allocator>& x, 2214684ddb6SLionel Sambuc const map<Key, T, Compare, Allocator>& y); 2224684ddb6SLionel Sambuc 2234684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 2244684ddb6SLionel Sambucbool 2254684ddb6SLionel Sambucoperator>=(const map<Key, T, Compare, Allocator>& x, 2264684ddb6SLionel Sambuc const map<Key, T, Compare, Allocator>& y); 2274684ddb6SLionel Sambuc 2284684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 2294684ddb6SLionel Sambucbool 2304684ddb6SLionel Sambucoperator<=(const map<Key, T, Compare, Allocator>& x, 2314684ddb6SLionel Sambuc const map<Key, T, Compare, Allocator>& y); 2324684ddb6SLionel Sambuc 2334684ddb6SLionel Sambuc// specialized algorithms: 2344684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 2354684ddb6SLionel Sambucvoid 2364684ddb6SLionel Sambucswap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y) 2374684ddb6SLionel Sambuc noexcept(noexcept(x.swap(y))); 2384684ddb6SLionel Sambuc 2394684ddb6SLionel Sambuctemplate <class Key, class T, class Compare = less<Key>, 2404684ddb6SLionel Sambuc class Allocator = allocator<pair<const Key, T>>> 2414684ddb6SLionel Sambucclass multimap 2424684ddb6SLionel Sambuc{ 2434684ddb6SLionel Sambucpublic: 2444684ddb6SLionel Sambuc // types: 2454684ddb6SLionel Sambuc typedef Key key_type; 2464684ddb6SLionel Sambuc typedef T mapped_type; 2474684ddb6SLionel Sambuc typedef pair<const key_type,mapped_type> value_type; 2484684ddb6SLionel Sambuc typedef Compare key_compare; 2494684ddb6SLionel Sambuc typedef Allocator allocator_type; 2504684ddb6SLionel Sambuc typedef typename allocator_type::reference reference; 2514684ddb6SLionel Sambuc typedef typename allocator_type::const_reference const_reference; 2524684ddb6SLionel Sambuc typedef typename allocator_type::size_type size_type; 2534684ddb6SLionel Sambuc typedef typename allocator_type::difference_type difference_type; 2544684ddb6SLionel Sambuc typedef typename allocator_type::pointer pointer; 2554684ddb6SLionel Sambuc typedef typename allocator_type::const_pointer const_pointer; 2564684ddb6SLionel Sambuc 2574684ddb6SLionel Sambuc typedef implementation-defined iterator; 2584684ddb6SLionel Sambuc typedef implementation-defined const_iterator; 2594684ddb6SLionel Sambuc typedef std::reverse_iterator<iterator> reverse_iterator; 2604684ddb6SLionel Sambuc typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 2614684ddb6SLionel Sambuc 2624684ddb6SLionel Sambuc class value_compare 2634684ddb6SLionel Sambuc : public binary_function<value_type,value_type,bool> 2644684ddb6SLionel Sambuc { 2654684ddb6SLionel Sambuc friend class multimap; 2664684ddb6SLionel Sambuc protected: 2674684ddb6SLionel Sambuc key_compare comp; 2684684ddb6SLionel Sambuc value_compare(key_compare c); 2694684ddb6SLionel Sambuc public: 2704684ddb6SLionel Sambuc bool operator()(const value_type& x, const value_type& y) const; 2714684ddb6SLionel Sambuc }; 2724684ddb6SLionel Sambuc 2734684ddb6SLionel Sambuc // construct/copy/destroy: 2744684ddb6SLionel Sambuc multimap() 2754684ddb6SLionel Sambuc noexcept( 2764684ddb6SLionel Sambuc is_nothrow_default_constructible<allocator_type>::value && 2774684ddb6SLionel Sambuc is_nothrow_default_constructible<key_compare>::value && 2784684ddb6SLionel Sambuc is_nothrow_copy_constructible<key_compare>::value); 2794684ddb6SLionel Sambuc explicit multimap(const key_compare& comp); 2804684ddb6SLionel Sambuc multimap(const key_compare& comp, const allocator_type& a); 2814684ddb6SLionel Sambuc template <class InputIterator> 2824684ddb6SLionel Sambuc multimap(InputIterator first, InputIterator last, const key_compare& comp); 2834684ddb6SLionel Sambuc template <class InputIterator> 2844684ddb6SLionel Sambuc multimap(InputIterator first, InputIterator last, const key_compare& comp, 2854684ddb6SLionel Sambuc const allocator_type& a); 2864684ddb6SLionel Sambuc multimap(const multimap& m); 2874684ddb6SLionel Sambuc multimap(multimap&& m) 2884684ddb6SLionel Sambuc noexcept( 2894684ddb6SLionel Sambuc is_nothrow_move_constructible<allocator_type>::value && 2904684ddb6SLionel Sambuc is_nothrow_move_constructible<key_compare>::value); 2914684ddb6SLionel Sambuc explicit multimap(const allocator_type& a); 2924684ddb6SLionel Sambuc multimap(const multimap& m, const allocator_type& a); 2934684ddb6SLionel Sambuc multimap(multimap&& m, const allocator_type& a); 2944684ddb6SLionel Sambuc multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); 2954684ddb6SLionel Sambuc multimap(initializer_list<value_type> il, const key_compare& comp, 2964684ddb6SLionel Sambuc const allocator_type& a); 2974684ddb6SLionel Sambuc template <class InputIterator> 2984684ddb6SLionel Sambuc multimap(InputIterator first, InputIterator last, const allocator_type& a) 2994684ddb6SLionel Sambuc : multimap(first, last, Compare(), a) {} // C++14 3004684ddb6SLionel Sambuc multimap(initializer_list<value_type> il, const allocator_type& a) 3014684ddb6SLionel Sambuc : multimap(il, Compare(), a) {} // C++14 3024684ddb6SLionel Sambuc ~multimap(); 3034684ddb6SLionel Sambuc 3044684ddb6SLionel Sambuc multimap& operator=(const multimap& m); 3054684ddb6SLionel Sambuc multimap& operator=(multimap&& m) 3064684ddb6SLionel Sambuc noexcept( 3074684ddb6SLionel Sambuc allocator_type::propagate_on_container_move_assignment::value && 3084684ddb6SLionel Sambuc is_nothrow_move_assignable<allocator_type>::value && 3094684ddb6SLionel Sambuc is_nothrow_move_assignable<key_compare>::value); 3104684ddb6SLionel Sambuc multimap& operator=(initializer_list<value_type> il); 3114684ddb6SLionel Sambuc 3124684ddb6SLionel Sambuc // iterators: 3134684ddb6SLionel Sambuc iterator begin() noexcept; 3144684ddb6SLionel Sambuc const_iterator begin() const noexcept; 3154684ddb6SLionel Sambuc iterator end() noexcept; 3164684ddb6SLionel Sambuc const_iterator end() const noexcept; 3174684ddb6SLionel Sambuc 3184684ddb6SLionel Sambuc reverse_iterator rbegin() noexcept; 3194684ddb6SLionel Sambuc const_reverse_iterator rbegin() const noexcept; 3204684ddb6SLionel Sambuc reverse_iterator rend() noexcept; 3214684ddb6SLionel Sambuc const_reverse_iterator rend() const noexcept; 3224684ddb6SLionel Sambuc 3234684ddb6SLionel Sambuc const_iterator cbegin() const noexcept; 3244684ddb6SLionel Sambuc const_iterator cend() const noexcept; 3254684ddb6SLionel Sambuc const_reverse_iterator crbegin() const noexcept; 3264684ddb6SLionel Sambuc const_reverse_iterator crend() const noexcept; 3274684ddb6SLionel Sambuc 3284684ddb6SLionel Sambuc // capacity: 3294684ddb6SLionel Sambuc bool empty() const noexcept; 3304684ddb6SLionel Sambuc size_type size() const noexcept; 3314684ddb6SLionel Sambuc size_type max_size() const noexcept; 3324684ddb6SLionel Sambuc 3334684ddb6SLionel Sambuc // modifiers: 3344684ddb6SLionel Sambuc template <class... Args> 3354684ddb6SLionel Sambuc iterator emplace(Args&&... args); 3364684ddb6SLionel Sambuc template <class... Args> 3374684ddb6SLionel Sambuc iterator emplace_hint(const_iterator position, Args&&... args); 3384684ddb6SLionel Sambuc iterator insert(const value_type& v); 3394684ddb6SLionel Sambuc template <class P> 3404684ddb6SLionel Sambuc iterator insert(P&& p); 3414684ddb6SLionel Sambuc iterator insert(const_iterator position, const value_type& v); 3424684ddb6SLionel Sambuc template <class P> 3434684ddb6SLionel Sambuc iterator insert(const_iterator position, P&& p); 3444684ddb6SLionel Sambuc template <class InputIterator> 3454684ddb6SLionel Sambuc void insert(InputIterator first, InputIterator last); 3464684ddb6SLionel Sambuc void insert(initializer_list<value_type> il); 3474684ddb6SLionel Sambuc 3484684ddb6SLionel Sambuc iterator erase(const_iterator position); 349*0a6a1f1dSLionel Sambuc iterator erase(iterator position); // C++14 3504684ddb6SLionel Sambuc size_type erase(const key_type& k); 3514684ddb6SLionel Sambuc iterator erase(const_iterator first, const_iterator last); 3524684ddb6SLionel Sambuc void clear() noexcept; 3534684ddb6SLionel Sambuc 3544684ddb6SLionel Sambuc void swap(multimap& m) 355*0a6a1f1dSLionel Sambuc noexcept(allocator_traits<allocator_type>::is_always_equal::value && 356*0a6a1f1dSLionel Sambuc __is_nothrow_swappable<key_compare>::value); // C++17 3574684ddb6SLionel Sambuc 3584684ddb6SLionel Sambuc // observers: 3594684ddb6SLionel Sambuc allocator_type get_allocator() const noexcept; 3604684ddb6SLionel Sambuc key_compare key_comp() const; 3614684ddb6SLionel Sambuc value_compare value_comp() const; 3624684ddb6SLionel Sambuc 3634684ddb6SLionel Sambuc // map operations: 3644684ddb6SLionel Sambuc iterator find(const key_type& k); 3654684ddb6SLionel Sambuc const_iterator find(const key_type& k) const; 3664684ddb6SLionel Sambuc template<typename K> 3674684ddb6SLionel Sambuc iterator find(const K& x); // C++14 3684684ddb6SLionel Sambuc template<typename K> 3694684ddb6SLionel Sambuc const_iterator find(const K& x) const; // C++14 3704684ddb6SLionel Sambuc template<typename K> 371*0a6a1f1dSLionel Sambuc size_type count(const K& x) const; // C++14 3724684ddb6SLionel Sambuc 3734684ddb6SLionel Sambuc size_type count(const key_type& k) const; 3744684ddb6SLionel Sambuc iterator lower_bound(const key_type& k); 3754684ddb6SLionel Sambuc const_iterator lower_bound(const key_type& k) const; 3764684ddb6SLionel Sambuc template<typename K> 3774684ddb6SLionel Sambuc iterator lower_bound(const K& x); // C++14 3784684ddb6SLionel Sambuc template<typename K> 3794684ddb6SLionel Sambuc const_iterator lower_bound(const K& x) const; // C++14 3804684ddb6SLionel Sambuc 3814684ddb6SLionel Sambuc iterator upper_bound(const key_type& k); 3824684ddb6SLionel Sambuc const_iterator upper_bound(const key_type& k) const; 3834684ddb6SLionel Sambuc template<typename K> 3844684ddb6SLionel Sambuc iterator upper_bound(const K& x); // C++14 3854684ddb6SLionel Sambuc template<typename K> 3864684ddb6SLionel Sambuc const_iterator upper_bound(const K& x) const; // C++14 3874684ddb6SLionel Sambuc 3884684ddb6SLionel Sambuc pair<iterator,iterator> equal_range(const key_type& k); 3894684ddb6SLionel Sambuc pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 3904684ddb6SLionel Sambuc template<typename K> 3914684ddb6SLionel Sambuc pair<iterator,iterator> equal_range(const K& x); // C++14 3924684ddb6SLionel Sambuc template<typename K> 3934684ddb6SLionel Sambuc pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 3944684ddb6SLionel Sambuc}; 3954684ddb6SLionel Sambuc 3964684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 3974684ddb6SLionel Sambucbool 3984684ddb6SLionel Sambucoperator==(const multimap<Key, T, Compare, Allocator>& x, 3994684ddb6SLionel Sambuc const multimap<Key, T, Compare, Allocator>& y); 4004684ddb6SLionel Sambuc 4014684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 4024684ddb6SLionel Sambucbool 4034684ddb6SLionel Sambucoperator< (const multimap<Key, T, Compare, Allocator>& x, 4044684ddb6SLionel Sambuc const multimap<Key, T, Compare, Allocator>& y); 4054684ddb6SLionel Sambuc 4064684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 4074684ddb6SLionel Sambucbool 4084684ddb6SLionel Sambucoperator!=(const multimap<Key, T, Compare, Allocator>& x, 4094684ddb6SLionel Sambuc const multimap<Key, T, Compare, Allocator>& y); 4104684ddb6SLionel Sambuc 4114684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 4124684ddb6SLionel Sambucbool 4134684ddb6SLionel Sambucoperator> (const multimap<Key, T, Compare, Allocator>& x, 4144684ddb6SLionel Sambuc const multimap<Key, T, Compare, Allocator>& y); 4154684ddb6SLionel Sambuc 4164684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 4174684ddb6SLionel Sambucbool 4184684ddb6SLionel Sambucoperator>=(const multimap<Key, T, Compare, Allocator>& x, 4194684ddb6SLionel Sambuc const multimap<Key, T, Compare, Allocator>& y); 4204684ddb6SLionel Sambuc 4214684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 4224684ddb6SLionel Sambucbool 4234684ddb6SLionel Sambucoperator<=(const multimap<Key, T, Compare, Allocator>& x, 4244684ddb6SLionel Sambuc const multimap<Key, T, Compare, Allocator>& y); 4254684ddb6SLionel Sambuc 4264684ddb6SLionel Sambuc// specialized algorithms: 4274684ddb6SLionel Sambuctemplate <class Key, class T, class Compare, class Allocator> 4284684ddb6SLionel Sambucvoid 4294684ddb6SLionel Sambucswap(multimap<Key, T, Compare, Allocator>& x, 4304684ddb6SLionel Sambuc multimap<Key, T, Compare, Allocator>& y) 4314684ddb6SLionel Sambuc noexcept(noexcept(x.swap(y))); 4324684ddb6SLionel Sambuc 4334684ddb6SLionel Sambuc} // std 4344684ddb6SLionel Sambuc 4354684ddb6SLionel Sambuc*/ 4364684ddb6SLionel Sambuc 4374684ddb6SLionel Sambuc#include <__config> 4384684ddb6SLionel Sambuc#include <__tree> 4394684ddb6SLionel Sambuc#include <iterator> 4404684ddb6SLionel Sambuc#include <memory> 4414684ddb6SLionel Sambuc#include <utility> 4424684ddb6SLionel Sambuc#include <functional> 4434684ddb6SLionel Sambuc#include <initializer_list> 444*0a6a1f1dSLionel Sambuc#include <type_traits> 4454684ddb6SLionel Sambuc 4464684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 4474684ddb6SLionel Sambuc#pragma GCC system_header 4484684ddb6SLionel Sambuc#endif 4494684ddb6SLionel Sambuc 4504684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD 4514684ddb6SLionel Sambuc 452*0a6a1f1dSLionel Sambuctemplate <class _Key, class _CP, class _Compare, 453*0a6a1f1dSLionel Sambuc bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value 4544684ddb6SLionel Sambuc > 4554684ddb6SLionel Sambucclass __map_value_compare 4564684ddb6SLionel Sambuc : private _Compare 4574684ddb6SLionel Sambuc{ 4584684ddb6SLionel Sambucpublic: 4594684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4604684ddb6SLionel Sambuc __map_value_compare() 4614684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) 4624684ddb6SLionel Sambuc : _Compare() {} 4634684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4644684ddb6SLionel Sambuc __map_value_compare(_Compare c) 4654684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) 4664684ddb6SLionel Sambuc : _Compare(c) {} 4674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4684684ddb6SLionel Sambuc const _Compare& key_comp() const _NOEXCEPT {return *this;} 4694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4704684ddb6SLionel Sambuc bool operator()(const _CP& __x, const _CP& __y) const 4714684ddb6SLionel Sambuc {return static_cast<const _Compare&>(*this)(__x.__cc.first, __y.__cc.first);} 4724684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4734684ddb6SLionel Sambuc bool operator()(const _CP& __x, const _Key& __y) const 4744684ddb6SLionel Sambuc {return static_cast<const _Compare&>(*this)(__x.__cc.first, __y);} 4754684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4764684ddb6SLionel Sambuc bool operator()(const _Key& __x, const _CP& __y) const 4774684ddb6SLionel Sambuc {return static_cast<const _Compare&>(*this)(__x, __y.__cc.first);} 478*0a6a1f1dSLionel Sambuc void swap(__map_value_compare&__y) 479*0a6a1f1dSLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) 480*0a6a1f1dSLionel Sambuc { 481*0a6a1f1dSLionel Sambuc using _VSTD::swap; 482*0a6a1f1dSLionel Sambuc swap(static_cast<const _Compare&>(*this), static_cast<const _Compare&>(__y)); 483*0a6a1f1dSLionel Sambuc } 4844684ddb6SLionel Sambuc 4854684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 4864684ddb6SLionel Sambuc template <typename _K2> 4874684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4884684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type 4894684ddb6SLionel Sambuc operator () ( const _K2& __x, const _CP& __y ) const 4904684ddb6SLionel Sambuc {return static_cast<const _Compare&>(*this) (__x, __y.__cc.first);} 4914684ddb6SLionel Sambuc 4924684ddb6SLionel Sambuc template <typename _K2> 4934684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4944684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type 4954684ddb6SLionel Sambuc operator () (const _CP& __x, const _K2& __y) const 4964684ddb6SLionel Sambuc {return static_cast<const _Compare&>(*this) (__x.__cc.first, __y);} 4974684ddb6SLionel Sambuc#endif 4984684ddb6SLionel Sambuc}; 4994684ddb6SLionel Sambuc 5004684ddb6SLionel Sambuctemplate <class _Key, class _CP, class _Compare> 5014684ddb6SLionel Sambucclass __map_value_compare<_Key, _CP, _Compare, false> 5024684ddb6SLionel Sambuc{ 5034684ddb6SLionel Sambuc _Compare comp; 5044684ddb6SLionel Sambuc 5054684ddb6SLionel Sambucpublic: 5064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5074684ddb6SLionel Sambuc __map_value_compare() 5084684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) 5094684ddb6SLionel Sambuc : comp() {} 5104684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5114684ddb6SLionel Sambuc __map_value_compare(_Compare c) 5124684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) 5134684ddb6SLionel Sambuc : comp(c) {} 5144684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5154684ddb6SLionel Sambuc const _Compare& key_comp() const _NOEXCEPT {return comp;} 5164684ddb6SLionel Sambuc 5174684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5184684ddb6SLionel Sambuc bool operator()(const _CP& __x, const _CP& __y) const 5194684ddb6SLionel Sambuc {return comp(__x.__cc.first, __y.__cc.first);} 5204684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5214684ddb6SLionel Sambuc bool operator()(const _CP& __x, const _Key& __y) const 5224684ddb6SLionel Sambuc {return comp(__x.__cc.first, __y);} 5234684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5244684ddb6SLionel Sambuc bool operator()(const _Key& __x, const _CP& __y) const 5254684ddb6SLionel Sambuc {return comp(__x, __y.__cc.first);} 526*0a6a1f1dSLionel Sambuc void swap(__map_value_compare&__y) 527*0a6a1f1dSLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) 528*0a6a1f1dSLionel Sambuc { 529*0a6a1f1dSLionel Sambuc using _VSTD::swap; 530*0a6a1f1dSLionel Sambuc swap(comp, __y.comp); 531*0a6a1f1dSLionel Sambuc } 5324684ddb6SLionel Sambuc 5334684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 5344684ddb6SLionel Sambuc template <typename _K2> 5354684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5364684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type 5374684ddb6SLionel Sambuc operator () ( const _K2& __x, const _CP& __y ) const 5384684ddb6SLionel Sambuc {return comp (__x, __y.__cc.first);} 5394684ddb6SLionel Sambuc 5404684ddb6SLionel Sambuc template <typename _K2> 5414684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5424684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type 5434684ddb6SLionel Sambuc operator () (const _CP& __x, const _K2& __y) const 5444684ddb6SLionel Sambuc {return comp (__x.__cc.first, __y);} 5454684ddb6SLionel Sambuc#endif 5464684ddb6SLionel Sambuc}; 5474684ddb6SLionel Sambuc 548*0a6a1f1dSLionel Sambuctemplate <class _Key, class _CP, class _Compare, bool __b> 549*0a6a1f1dSLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 550*0a6a1f1dSLionel Sambucvoid 551*0a6a1f1dSLionel Sambucswap(__map_value_compare<_Key, _CP, _Compare, __b>& __x, 552*0a6a1f1dSLionel Sambuc __map_value_compare<_Key, _CP, _Compare, __b>& __y) 553*0a6a1f1dSLionel Sambuc _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 554*0a6a1f1dSLionel Sambuc{ 555*0a6a1f1dSLionel Sambuc __x.swap(__y); 556*0a6a1f1dSLionel Sambuc} 557*0a6a1f1dSLionel Sambuc 5584684ddb6SLionel Sambuctemplate <class _Allocator> 5594684ddb6SLionel Sambucclass __map_node_destructor 5604684ddb6SLionel Sambuc{ 5614684ddb6SLionel Sambuc typedef _Allocator allocator_type; 5624684ddb6SLionel Sambuc typedef allocator_traits<allocator_type> __alloc_traits; 5634684ddb6SLionel Sambuc typedef typename __alloc_traits::value_type::value_type value_type; 5644684ddb6SLionel Sambucpublic: 5654684ddb6SLionel Sambuc typedef typename __alloc_traits::pointer pointer; 5664684ddb6SLionel Sambucprivate: 5674684ddb6SLionel Sambuc typedef typename value_type::value_type::first_type first_type; 5684684ddb6SLionel Sambuc typedef typename value_type::value_type::second_type second_type; 5694684ddb6SLionel Sambuc 5704684ddb6SLionel Sambuc allocator_type& __na_; 5714684ddb6SLionel Sambuc 5724684ddb6SLionel Sambuc __map_node_destructor& operator=(const __map_node_destructor&); 5734684ddb6SLionel Sambuc 5744684ddb6SLionel Sambucpublic: 5754684ddb6SLionel Sambuc bool __first_constructed; 5764684ddb6SLionel Sambuc bool __second_constructed; 5774684ddb6SLionel Sambuc 5784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5794684ddb6SLionel Sambuc explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT 5804684ddb6SLionel Sambuc : __na_(__na), 5814684ddb6SLionel Sambuc __first_constructed(false), 5824684ddb6SLionel Sambuc __second_constructed(false) 5834684ddb6SLionel Sambuc {} 5844684ddb6SLionel Sambuc 5854684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5874684ddb6SLionel Sambuc __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT 5884684ddb6SLionel Sambuc : __na_(__x.__na_), 5894684ddb6SLionel Sambuc __first_constructed(__x.__value_constructed), 5904684ddb6SLionel Sambuc __second_constructed(__x.__value_constructed) 5914684ddb6SLionel Sambuc { 5924684ddb6SLionel Sambuc __x.__value_constructed = false; 5934684ddb6SLionel Sambuc } 5944684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5954684ddb6SLionel Sambuc 5964684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 5974684ddb6SLionel Sambuc void operator()(pointer __p) _NOEXCEPT 5984684ddb6SLionel Sambuc { 5994684ddb6SLionel Sambuc if (__second_constructed) 6004684ddb6SLionel Sambuc __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second)); 6014684ddb6SLionel Sambuc if (__first_constructed) 6024684ddb6SLionel Sambuc __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first)); 6034684ddb6SLionel Sambuc if (__p) 6044684ddb6SLionel Sambuc __alloc_traits::deallocate(__na_, __p, 1); 6054684ddb6SLionel Sambuc } 6064684ddb6SLionel Sambuc}; 6074684ddb6SLionel Sambuc 6084684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 6094684ddb6SLionel Sambuc class map; 6104684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 6114684ddb6SLionel Sambuc class multimap; 6124684ddb6SLionel Sambuctemplate <class _TreeIterator> class __map_const_iterator; 6134684ddb6SLionel Sambuc 6144684ddb6SLionel Sambuc#if __cplusplus >= 201103L 6154684ddb6SLionel Sambuc 6164684ddb6SLionel Sambuctemplate <class _Key, class _Tp> 6174684ddb6SLionel Sambucunion __value_type 6184684ddb6SLionel Sambuc{ 6194684ddb6SLionel Sambuc typedef _Key key_type; 6204684ddb6SLionel Sambuc typedef _Tp mapped_type; 6214684ddb6SLionel Sambuc typedef pair<const key_type, mapped_type> value_type; 6224684ddb6SLionel Sambuc typedef pair<key_type, mapped_type> __nc_value_type; 6234684ddb6SLionel Sambuc 6244684ddb6SLionel Sambuc value_type __cc; 6254684ddb6SLionel Sambuc __nc_value_type __nc; 6264684ddb6SLionel Sambuc 6274684ddb6SLionel Sambuc template <class ..._Args> 6284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6294684ddb6SLionel Sambuc __value_type(_Args&& ...__args) 6304684ddb6SLionel Sambuc : __cc(std::forward<_Args>(__args)...) {} 6314684ddb6SLionel Sambuc 6324684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6334684ddb6SLionel Sambuc __value_type(const __value_type& __v) 6344684ddb6SLionel Sambuc : __cc(__v.__cc) {} 6354684ddb6SLionel Sambuc 6364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6374684ddb6SLionel Sambuc __value_type(__value_type& __v) 6384684ddb6SLionel Sambuc : __cc(__v.__cc) {} 6394684ddb6SLionel Sambuc 6404684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6414684ddb6SLionel Sambuc __value_type(__value_type&& __v) 6424684ddb6SLionel Sambuc : __nc(std::move(__v.__nc)) {} 6434684ddb6SLionel Sambuc 6444684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6454684ddb6SLionel Sambuc __value_type& operator=(const __value_type& __v) 6464684ddb6SLionel Sambuc {__nc = __v.__cc; return *this;} 6474684ddb6SLionel Sambuc 6484684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6494684ddb6SLionel Sambuc __value_type& operator=(__value_type&& __v) 6504684ddb6SLionel Sambuc {__nc = std::move(__v.__nc); return *this;} 6514684ddb6SLionel Sambuc 6524684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6534684ddb6SLionel Sambuc ~__value_type() {__cc.~value_type();} 6544684ddb6SLionel Sambuc}; 6554684ddb6SLionel Sambuc 6564684ddb6SLionel Sambuc#else 6574684ddb6SLionel Sambuc 6584684ddb6SLionel Sambuctemplate <class _Key, class _Tp> 6594684ddb6SLionel Sambucstruct __value_type 6604684ddb6SLionel Sambuc{ 6614684ddb6SLionel Sambuc typedef _Key key_type; 6624684ddb6SLionel Sambuc typedef _Tp mapped_type; 6634684ddb6SLionel Sambuc typedef pair<const key_type, mapped_type> value_type; 6644684ddb6SLionel Sambuc 6654684ddb6SLionel Sambuc value_type __cc; 6664684ddb6SLionel Sambuc 6674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6684684ddb6SLionel Sambuc __value_type() {} 6694684ddb6SLionel Sambuc 6704684ddb6SLionel Sambuc template <class _A0> 6714684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6724684ddb6SLionel Sambuc __value_type(const _A0& __a0) 6734684ddb6SLionel Sambuc : __cc(__a0) {} 6744684ddb6SLionel Sambuc 6754684ddb6SLionel Sambuc template <class _A0, class _A1> 6764684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6774684ddb6SLionel Sambuc __value_type(const _A0& __a0, const _A1& __a1) 6784684ddb6SLionel Sambuc : __cc(__a0, __a1) {} 6794684ddb6SLionel Sambuc}; 6804684ddb6SLionel Sambuc 6814684ddb6SLionel Sambuc#endif 6824684ddb6SLionel Sambuc 683*0a6a1f1dSLionel Sambuctemplate <class _Tp> 684*0a6a1f1dSLionel Sambucstruct __extract_key_value_types; 685*0a6a1f1dSLionel Sambuc 686*0a6a1f1dSLionel Sambuctemplate <class _Key, class _Tp> 687*0a6a1f1dSLionel Sambucstruct __extract_key_value_types<__value_type<_Key, _Tp> > 688*0a6a1f1dSLionel Sambuc{ 689*0a6a1f1dSLionel Sambuc typedef _Key const __key_type; 690*0a6a1f1dSLionel Sambuc typedef _Tp __mapped_type; 691*0a6a1f1dSLionel Sambuc}; 692*0a6a1f1dSLionel Sambuc 6934684ddb6SLionel Sambuctemplate <class _TreeIterator> 6944684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY __map_iterator 6954684ddb6SLionel Sambuc{ 6964684ddb6SLionel Sambuc _TreeIterator __i_; 6974684ddb6SLionel Sambuc 6984684ddb6SLionel Sambuc typedef typename _TreeIterator::__pointer_traits __pointer_traits; 699*0a6a1f1dSLionel Sambuc typedef typename _TreeIterator::value_type __value_type; 700*0a6a1f1dSLionel Sambuc typedef typename __extract_key_value_types<__value_type>::__key_type __key_type; 701*0a6a1f1dSLionel Sambuc typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type; 7024684ddb6SLionel Sambucpublic: 7034684ddb6SLionel Sambuc typedef bidirectional_iterator_tag iterator_category; 7044684ddb6SLionel Sambuc typedef pair<__key_type, __mapped_type> value_type; 7054684ddb6SLionel Sambuc typedef typename _TreeIterator::difference_type difference_type; 7064684ddb6SLionel Sambuc typedef value_type& reference; 7074684ddb6SLionel Sambuc typedef typename __pointer_traits::template 7084684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 7094684ddb6SLionel Sambuc rebind<value_type> 7104684ddb6SLionel Sambuc#else 7114684ddb6SLionel Sambuc rebind<value_type>::other 7124684ddb6SLionel Sambuc#endif 7134684ddb6SLionel Sambuc pointer; 7144684ddb6SLionel Sambuc 7154684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7164684ddb6SLionel Sambuc __map_iterator() _NOEXCEPT {} 7174684ddb6SLionel Sambuc 7184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7194684ddb6SLionel Sambuc __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} 7204684ddb6SLionel Sambuc 7214684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7224684ddb6SLionel Sambuc reference operator*() const {return __i_->__cc;} 7234684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7244684ddb6SLionel Sambuc pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);} 7254684ddb6SLionel Sambuc 7264684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7274684ddb6SLionel Sambuc __map_iterator& operator++() {++__i_; return *this;} 7284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7294684ddb6SLionel Sambuc __map_iterator operator++(int) 7304684ddb6SLionel Sambuc { 7314684ddb6SLionel Sambuc __map_iterator __t(*this); 7324684ddb6SLionel Sambuc ++(*this); 7334684ddb6SLionel Sambuc return __t; 7344684ddb6SLionel Sambuc } 7354684ddb6SLionel Sambuc 7364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7374684ddb6SLionel Sambuc __map_iterator& operator--() {--__i_; return *this;} 7384684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7394684ddb6SLionel Sambuc __map_iterator operator--(int) 7404684ddb6SLionel Sambuc { 7414684ddb6SLionel Sambuc __map_iterator __t(*this); 7424684ddb6SLionel Sambuc --(*this); 7434684ddb6SLionel Sambuc return __t; 7444684ddb6SLionel Sambuc } 7454684ddb6SLionel Sambuc 7464684ddb6SLionel Sambuc friend _LIBCPP_INLINE_VISIBILITY 7474684ddb6SLionel Sambuc bool operator==(const __map_iterator& __x, const __map_iterator& __y) 7484684ddb6SLionel Sambuc {return __x.__i_ == __y.__i_;} 7494684ddb6SLionel Sambuc friend 7504684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7514684ddb6SLionel Sambuc bool operator!=(const __map_iterator& __x, const __map_iterator& __y) 7524684ddb6SLionel Sambuc {return __x.__i_ != __y.__i_;} 7534684ddb6SLionel Sambuc 7544684ddb6SLionel Sambuc template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; 7554684ddb6SLionel Sambuc template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; 7564684ddb6SLionel Sambuc template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; 7574684ddb6SLionel Sambuc}; 7584684ddb6SLionel Sambuc 7594684ddb6SLionel Sambuctemplate <class _TreeIterator> 7604684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY __map_const_iterator 7614684ddb6SLionel Sambuc{ 7624684ddb6SLionel Sambuc _TreeIterator __i_; 7634684ddb6SLionel Sambuc 7644684ddb6SLionel Sambuc typedef typename _TreeIterator::__pointer_traits __pointer_traits; 765*0a6a1f1dSLionel Sambuc typedef typename _TreeIterator::value_type __value_type; 766*0a6a1f1dSLionel Sambuc typedef typename __extract_key_value_types<__value_type>::__key_type __key_type; 767*0a6a1f1dSLionel Sambuc typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type; 7684684ddb6SLionel Sambucpublic: 7694684ddb6SLionel Sambuc typedef bidirectional_iterator_tag iterator_category; 7704684ddb6SLionel Sambuc typedef pair<__key_type, __mapped_type> value_type; 7714684ddb6SLionel Sambuc typedef typename _TreeIterator::difference_type difference_type; 7724684ddb6SLionel Sambuc typedef const value_type& reference; 7734684ddb6SLionel Sambuc typedef typename __pointer_traits::template 7744684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 7754684ddb6SLionel Sambuc rebind<const value_type> 7764684ddb6SLionel Sambuc#else 7774684ddb6SLionel Sambuc rebind<const value_type>::other 7784684ddb6SLionel Sambuc#endif 7794684ddb6SLionel Sambuc pointer; 7804684ddb6SLionel Sambuc 7814684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7824684ddb6SLionel Sambuc __map_const_iterator() _NOEXCEPT {} 7834684ddb6SLionel Sambuc 7844684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7854684ddb6SLionel Sambuc __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} 7864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 787*0a6a1f1dSLionel Sambuc __map_const_iterator(__map_iterator< 788*0a6a1f1dSLionel Sambuc typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT 7894684ddb6SLionel Sambuc : __i_(__i.__i_) {} 7904684ddb6SLionel Sambuc 7914684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7924684ddb6SLionel Sambuc reference operator*() const {return __i_->__cc;} 7934684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7944684ddb6SLionel Sambuc pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);} 7954684ddb6SLionel Sambuc 7964684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7974684ddb6SLionel Sambuc __map_const_iterator& operator++() {++__i_; return *this;} 7984684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7994684ddb6SLionel Sambuc __map_const_iterator operator++(int) 8004684ddb6SLionel Sambuc { 8014684ddb6SLionel Sambuc __map_const_iterator __t(*this); 8024684ddb6SLionel Sambuc ++(*this); 8034684ddb6SLionel Sambuc return __t; 8044684ddb6SLionel Sambuc } 8054684ddb6SLionel Sambuc 8064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8074684ddb6SLionel Sambuc __map_const_iterator& operator--() {--__i_; return *this;} 8084684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8094684ddb6SLionel Sambuc __map_const_iterator operator--(int) 8104684ddb6SLionel Sambuc { 8114684ddb6SLionel Sambuc __map_const_iterator __t(*this); 8124684ddb6SLionel Sambuc --(*this); 8134684ddb6SLionel Sambuc return __t; 8144684ddb6SLionel Sambuc } 8154684ddb6SLionel Sambuc 8164684ddb6SLionel Sambuc friend _LIBCPP_INLINE_VISIBILITY 8174684ddb6SLionel Sambuc bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) 8184684ddb6SLionel Sambuc {return __x.__i_ == __y.__i_;} 8194684ddb6SLionel Sambuc friend _LIBCPP_INLINE_VISIBILITY 8204684ddb6SLionel Sambuc bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) 8214684ddb6SLionel Sambuc {return __x.__i_ != __y.__i_;} 8224684ddb6SLionel Sambuc 8234684ddb6SLionel Sambuc template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; 8244684ddb6SLionel Sambuc template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; 8254684ddb6SLionel Sambuc template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; 8264684ddb6SLionel Sambuc}; 8274684ddb6SLionel Sambuc 8284684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare = less<_Key>, 8294684ddb6SLionel Sambuc class _Allocator = allocator<pair<const _Key, _Tp> > > 8304684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY map 8314684ddb6SLionel Sambuc{ 8324684ddb6SLionel Sambucpublic: 8334684ddb6SLionel Sambuc // types: 8344684ddb6SLionel Sambuc typedef _Key key_type; 8354684ddb6SLionel Sambuc typedef _Tp mapped_type; 8364684ddb6SLionel Sambuc typedef pair<const key_type, mapped_type> value_type; 8374684ddb6SLionel Sambuc typedef pair<key_type, mapped_type> __nc_value_type; 8384684ddb6SLionel Sambuc typedef _Compare key_compare; 8394684ddb6SLionel Sambuc typedef _Allocator allocator_type; 8404684ddb6SLionel Sambuc typedef value_type& reference; 8414684ddb6SLionel Sambuc typedef const value_type& const_reference; 8424684ddb6SLionel Sambuc 8434684ddb6SLionel Sambuc class _LIBCPP_TYPE_VIS_ONLY value_compare 8444684ddb6SLionel Sambuc : public binary_function<value_type, value_type, bool> 8454684ddb6SLionel Sambuc { 8464684ddb6SLionel Sambuc friend class map; 8474684ddb6SLionel Sambuc protected: 8484684ddb6SLionel Sambuc key_compare comp; 8494684ddb6SLionel Sambuc 8504684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {} 8514684ddb6SLionel Sambuc public: 8524684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8534684ddb6SLionel Sambuc bool operator()(const value_type& __x, const value_type& __y) const 8544684ddb6SLionel Sambuc {return comp(__x.first, __y.first);} 8554684ddb6SLionel Sambuc }; 8564684ddb6SLionel Sambuc 8574684ddb6SLionel Sambucprivate: 8584684ddb6SLionel Sambuc 8594684ddb6SLionel Sambuc typedef _VSTD::__value_type<key_type, mapped_type> __value_type; 8604684ddb6SLionel Sambuc typedef __map_value_compare<key_type, __value_type, key_compare> __vc; 861*0a6a1f1dSLionel Sambuc typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, 862*0a6a1f1dSLionel Sambuc __value_type>::type __allocator_type; 8634684ddb6SLionel Sambuc typedef __tree<__value_type, __vc, __allocator_type> __base; 8644684ddb6SLionel Sambuc typedef typename __base::__node_traits __node_traits; 8654684ddb6SLionel Sambuc typedef allocator_traits<allocator_type> __alloc_traits; 8664684ddb6SLionel Sambuc 8674684ddb6SLionel Sambuc __base __tree_; 8684684ddb6SLionel Sambuc 8694684ddb6SLionel Sambucpublic: 8704684ddb6SLionel Sambuc typedef typename __alloc_traits::pointer pointer; 8714684ddb6SLionel Sambuc typedef typename __alloc_traits::const_pointer const_pointer; 8724684ddb6SLionel Sambuc typedef typename __alloc_traits::size_type size_type; 8734684ddb6SLionel Sambuc typedef typename __alloc_traits::difference_type difference_type; 8744684ddb6SLionel Sambuc typedef __map_iterator<typename __base::iterator> iterator; 8754684ddb6SLionel Sambuc typedef __map_const_iterator<typename __base::const_iterator> const_iterator; 8764684ddb6SLionel Sambuc typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 8774684ddb6SLionel Sambuc typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 8784684ddb6SLionel Sambuc 8794684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 880*0a6a1f1dSLionel Sambuc map() 8814684ddb6SLionel Sambuc _NOEXCEPT_( 8824684ddb6SLionel Sambuc is_nothrow_default_constructible<allocator_type>::value && 8834684ddb6SLionel Sambuc is_nothrow_default_constructible<key_compare>::value && 8844684ddb6SLionel Sambuc is_nothrow_copy_constructible<key_compare>::value) 885*0a6a1f1dSLionel Sambuc : __tree_(__vc(key_compare())) {} 886*0a6a1f1dSLionel Sambuc 887*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 888*0a6a1f1dSLionel Sambuc explicit map(const key_compare& __comp) 889*0a6a1f1dSLionel Sambuc _NOEXCEPT_( 890*0a6a1f1dSLionel Sambuc is_nothrow_default_constructible<allocator_type>::value && 891*0a6a1f1dSLionel Sambuc is_nothrow_copy_constructible<key_compare>::value) 8924684ddb6SLionel Sambuc : __tree_(__vc(__comp)) {} 8934684ddb6SLionel Sambuc 8944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 8954684ddb6SLionel Sambuc explicit map(const key_compare& __comp, const allocator_type& __a) 8964684ddb6SLionel Sambuc : __tree_(__vc(__comp), __a) {} 8974684ddb6SLionel Sambuc 8984684ddb6SLionel Sambuc template <class _InputIterator> 8994684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9004684ddb6SLionel Sambuc map(_InputIterator __f, _InputIterator __l, 9014684ddb6SLionel Sambuc const key_compare& __comp = key_compare()) 9024684ddb6SLionel Sambuc : __tree_(__vc(__comp)) 9034684ddb6SLionel Sambuc { 9044684ddb6SLionel Sambuc insert(__f, __l); 9054684ddb6SLionel Sambuc } 9064684ddb6SLionel Sambuc 9074684ddb6SLionel Sambuc template <class _InputIterator> 9084684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9094684ddb6SLionel Sambuc map(_InputIterator __f, _InputIterator __l, 9104684ddb6SLionel Sambuc const key_compare& __comp, const allocator_type& __a) 9114684ddb6SLionel Sambuc : __tree_(__vc(__comp), __a) 9124684ddb6SLionel Sambuc { 9134684ddb6SLionel Sambuc insert(__f, __l); 9144684ddb6SLionel Sambuc } 9154684ddb6SLionel Sambuc 9164684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 9174684ddb6SLionel Sambuc template <class _InputIterator> 9184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9194684ddb6SLionel Sambuc map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) 9204684ddb6SLionel Sambuc : map(__f, __l, key_compare(), __a) {} 9214684ddb6SLionel Sambuc#endif 9224684ddb6SLionel Sambuc 9234684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9244684ddb6SLionel Sambuc map(const map& __m) 9254684ddb6SLionel Sambuc : __tree_(__m.__tree_) 9264684ddb6SLionel Sambuc { 9274684ddb6SLionel Sambuc insert(__m.begin(), __m.end()); 9284684ddb6SLionel Sambuc } 9294684ddb6SLionel Sambuc 9304684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9314684ddb6SLionel Sambuc map& operator=(const map& __m) 9324684ddb6SLionel Sambuc { 9334684ddb6SLionel Sambuc#if __cplusplus >= 201103L 9344684ddb6SLionel Sambuc __tree_ = __m.__tree_; 9354684ddb6SLionel Sambuc#else 936*0a6a1f1dSLionel Sambuc if (this != &__m) { 9374684ddb6SLionel Sambuc __tree_.clear(); 9384684ddb6SLionel Sambuc __tree_.value_comp() = __m.__tree_.value_comp(); 9394684ddb6SLionel Sambuc __tree_.__copy_assign_alloc(__m.__tree_); 9404684ddb6SLionel Sambuc insert(__m.begin(), __m.end()); 941*0a6a1f1dSLionel Sambuc } 9424684ddb6SLionel Sambuc#endif 9434684ddb6SLionel Sambuc return *this; 9444684ddb6SLionel Sambuc } 9454684ddb6SLionel Sambuc 9464684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 9474684ddb6SLionel Sambuc 9484684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9494684ddb6SLionel Sambuc map(map&& __m) 9504684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) 9514684ddb6SLionel Sambuc : __tree_(_VSTD::move(__m.__tree_)) 9524684ddb6SLionel Sambuc { 9534684ddb6SLionel Sambuc } 9544684ddb6SLionel Sambuc 9554684ddb6SLionel Sambuc map(map&& __m, const allocator_type& __a); 9564684ddb6SLionel Sambuc 9574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9584684ddb6SLionel Sambuc map& operator=(map&& __m) 9594684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) 9604684ddb6SLionel Sambuc { 9614684ddb6SLionel Sambuc __tree_ = _VSTD::move(__m.__tree_); 9624684ddb6SLionel Sambuc return *this; 9634684ddb6SLionel Sambuc } 9644684ddb6SLionel Sambuc 9654684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 9664684ddb6SLionel Sambuc 9674684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 9684684ddb6SLionel Sambuc 9694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9704684ddb6SLionel Sambuc map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) 9714684ddb6SLionel Sambuc : __tree_(__vc(__comp)) 9724684ddb6SLionel Sambuc { 9734684ddb6SLionel Sambuc insert(__il.begin(), __il.end()); 9744684ddb6SLionel Sambuc } 9754684ddb6SLionel Sambuc 9764684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9774684ddb6SLionel Sambuc map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) 9784684ddb6SLionel Sambuc : __tree_(__vc(__comp), __a) 9794684ddb6SLionel Sambuc { 9804684ddb6SLionel Sambuc insert(__il.begin(), __il.end()); 9814684ddb6SLionel Sambuc } 9824684ddb6SLionel Sambuc 9834684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 9844684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9854684ddb6SLionel Sambuc map(initializer_list<value_type> __il, const allocator_type& __a) 9864684ddb6SLionel Sambuc : map(__il, key_compare(), __a) {} 9874684ddb6SLionel Sambuc#endif 9884684ddb6SLionel Sambuc 9894684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9904684ddb6SLionel Sambuc map& operator=(initializer_list<value_type> __il) 9914684ddb6SLionel Sambuc { 9924684ddb6SLionel Sambuc __tree_.__assign_unique(__il.begin(), __il.end()); 9934684ddb6SLionel Sambuc return *this; 9944684ddb6SLionel Sambuc } 9954684ddb6SLionel Sambuc 9964684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 9974684ddb6SLionel Sambuc 9984684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9994684ddb6SLionel Sambuc explicit map(const allocator_type& __a) 10004684ddb6SLionel Sambuc : __tree_(__a) 10014684ddb6SLionel Sambuc { 10024684ddb6SLionel Sambuc } 10034684ddb6SLionel Sambuc 10044684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10054684ddb6SLionel Sambuc map(const map& __m, const allocator_type& __a) 10064684ddb6SLionel Sambuc : __tree_(__m.__tree_.value_comp(), __a) 10074684ddb6SLionel Sambuc { 10084684ddb6SLionel Sambuc insert(__m.begin(), __m.end()); 10094684ddb6SLionel Sambuc } 10104684ddb6SLionel Sambuc 10114684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10124684ddb6SLionel Sambuc iterator begin() _NOEXCEPT {return __tree_.begin();} 10134684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10144684ddb6SLionel Sambuc const_iterator begin() const _NOEXCEPT {return __tree_.begin();} 10154684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10164684ddb6SLionel Sambuc iterator end() _NOEXCEPT {return __tree_.end();} 10174684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10184684ddb6SLionel Sambuc const_iterator end() const _NOEXCEPT {return __tree_.end();} 10194684ddb6SLionel Sambuc 10204684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10214684ddb6SLionel Sambuc reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} 10224684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10234684ddb6SLionel Sambuc const_reverse_iterator rbegin() const _NOEXCEPT 10244684ddb6SLionel Sambuc {return const_reverse_iterator(end());} 10254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10264684ddb6SLionel Sambuc reverse_iterator rend() _NOEXCEPT 10274684ddb6SLionel Sambuc {return reverse_iterator(begin());} 10284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10294684ddb6SLionel Sambuc const_reverse_iterator rend() const _NOEXCEPT 10304684ddb6SLionel Sambuc {return const_reverse_iterator(begin());} 10314684ddb6SLionel Sambuc 10324684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10334684ddb6SLionel Sambuc const_iterator cbegin() const _NOEXCEPT {return begin();} 10344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10354684ddb6SLionel Sambuc const_iterator cend() const _NOEXCEPT {return end();} 10364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10374684ddb6SLionel Sambuc const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 10384684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10394684ddb6SLionel Sambuc const_reverse_iterator crend() const _NOEXCEPT {return rend();} 10404684ddb6SLionel Sambuc 10414684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10424684ddb6SLionel Sambuc bool empty() const _NOEXCEPT {return __tree_.size() == 0;} 10434684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10444684ddb6SLionel Sambuc size_type size() const _NOEXCEPT {return __tree_.size();} 10454684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10464684ddb6SLionel Sambuc size_type max_size() const _NOEXCEPT {return __tree_.max_size();} 10474684ddb6SLionel Sambuc 10484684ddb6SLionel Sambuc mapped_type& operator[](const key_type& __k); 10494684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 10504684ddb6SLionel Sambuc mapped_type& operator[](key_type&& __k); 10514684ddb6SLionel Sambuc#endif 10524684ddb6SLionel Sambuc 10534684ddb6SLionel Sambuc mapped_type& at(const key_type& __k); 10544684ddb6SLionel Sambuc const mapped_type& at(const key_type& __k) const; 10554684ddb6SLionel Sambuc 10564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10574684ddb6SLionel Sambuc allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} 10584684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10594684ddb6SLionel Sambuc key_compare key_comp() const {return __tree_.value_comp().key_comp();} 10604684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10614684ddb6SLionel Sambuc value_compare value_comp() const {return value_compare(__tree_.value_comp().key_comp());} 10624684ddb6SLionel Sambuc 10634684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 10644684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 10654684ddb6SLionel Sambuc 10664684ddb6SLionel Sambuc template <class ..._Args> 10674684ddb6SLionel Sambuc pair<iterator, bool> 10684684ddb6SLionel Sambuc emplace(_Args&& ...__args); 10694684ddb6SLionel Sambuc 10704684ddb6SLionel Sambuc template <class ..._Args> 10714684ddb6SLionel Sambuc iterator 10724684ddb6SLionel Sambuc emplace_hint(const_iterator __p, _Args&& ...__args); 10734684ddb6SLionel Sambuc 10744684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 10754684ddb6SLionel Sambuc 10764684ddb6SLionel Sambuc template <class _Pp, 10774684ddb6SLionel Sambuc class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 10784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10794684ddb6SLionel Sambuc pair<iterator, bool> insert(_Pp&& __p) 10804684ddb6SLionel Sambuc {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));} 10814684ddb6SLionel Sambuc 10824684ddb6SLionel Sambuc template <class _Pp, 10834684ddb6SLionel Sambuc class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 10844684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10854684ddb6SLionel Sambuc iterator insert(const_iterator __pos, _Pp&& __p) 10864684ddb6SLionel Sambuc {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));} 10874684ddb6SLionel Sambuc 10884684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 10894684ddb6SLionel Sambuc 10904684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10914684ddb6SLionel Sambuc pair<iterator, bool> 10924684ddb6SLionel Sambuc insert(const value_type& __v) {return __tree_.__insert_unique(__v);} 10934684ddb6SLionel Sambuc 10944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10954684ddb6SLionel Sambuc iterator 10964684ddb6SLionel Sambuc insert(const_iterator __p, const value_type& __v) 10974684ddb6SLionel Sambuc {return __tree_.__insert_unique(__p.__i_, __v);} 10984684ddb6SLionel Sambuc 10994684ddb6SLionel Sambuc template <class _InputIterator> 11004684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 11014684ddb6SLionel Sambuc void insert(_InputIterator __f, _InputIterator __l) 11024684ddb6SLionel Sambuc { 11034684ddb6SLionel Sambuc for (const_iterator __e = cend(); __f != __l; ++__f) 11044684ddb6SLionel Sambuc insert(__e.__i_, *__f); 11054684ddb6SLionel Sambuc } 11064684ddb6SLionel Sambuc 11074684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 11084684ddb6SLionel Sambuc 11094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 11104684ddb6SLionel Sambuc void insert(initializer_list<value_type> __il) 11114684ddb6SLionel Sambuc {insert(__il.begin(), __il.end());} 11124684ddb6SLionel Sambuc 11134684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 11144684ddb6SLionel Sambuc 1115*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 14 1116*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1117*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 1118*0a6a1f1dSLionel Sambuc template <class... _Args> 1119*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1120*0a6a1f1dSLionel Sambuc pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) 1121*0a6a1f1dSLionel Sambuc { 1122*0a6a1f1dSLionel Sambuc iterator __p = lower_bound(__k); 1123*0a6a1f1dSLionel Sambuc if ( __p != end() && !key_comp()(__k, __p->first)) 1124*0a6a1f1dSLionel Sambuc return _VSTD::make_pair(__p, false); 1125*0a6a1f1dSLionel Sambuc else 1126*0a6a1f1dSLionel Sambuc return _VSTD::make_pair( 1127*0a6a1f1dSLionel Sambuc emplace_hint(__p, 1128*0a6a1f1dSLionel Sambuc _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), 1129*0a6a1f1dSLionel Sambuc _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)), 1130*0a6a1f1dSLionel Sambuc true); 1131*0a6a1f1dSLionel Sambuc } 1132*0a6a1f1dSLionel Sambuc 1133*0a6a1f1dSLionel Sambuc template <class... _Args> 1134*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1135*0a6a1f1dSLionel Sambuc pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) 1136*0a6a1f1dSLionel Sambuc { 1137*0a6a1f1dSLionel Sambuc iterator __p = lower_bound(__k); 1138*0a6a1f1dSLionel Sambuc if ( __p != end() && !key_comp()(__k, __p->first)) 1139*0a6a1f1dSLionel Sambuc return _VSTD::make_pair(__p, false); 1140*0a6a1f1dSLionel Sambuc else 1141*0a6a1f1dSLionel Sambuc return _VSTD::make_pair( 1142*0a6a1f1dSLionel Sambuc emplace_hint(__p, 1143*0a6a1f1dSLionel Sambuc _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), 1144*0a6a1f1dSLionel Sambuc _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)), 1145*0a6a1f1dSLionel Sambuc true); 1146*0a6a1f1dSLionel Sambuc } 1147*0a6a1f1dSLionel Sambuc 1148*0a6a1f1dSLionel Sambuc template <class... _Args> 1149*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1150*0a6a1f1dSLionel Sambuc iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) 1151*0a6a1f1dSLionel Sambuc { 1152*0a6a1f1dSLionel Sambuc iterator __p = lower_bound(__k); 1153*0a6a1f1dSLionel Sambuc if ( __p != end() && !key_comp()(__k, __p->first)) 1154*0a6a1f1dSLionel Sambuc return __p; 1155*0a6a1f1dSLionel Sambuc else 1156*0a6a1f1dSLionel Sambuc return emplace_hint(__p, 1157*0a6a1f1dSLionel Sambuc _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), 1158*0a6a1f1dSLionel Sambuc _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); 1159*0a6a1f1dSLionel Sambuc } 1160*0a6a1f1dSLionel Sambuc 1161*0a6a1f1dSLionel Sambuc template <class... _Args> 1162*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1163*0a6a1f1dSLionel Sambuc iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) 1164*0a6a1f1dSLionel Sambuc { 1165*0a6a1f1dSLionel Sambuc iterator __p = lower_bound(__k); 1166*0a6a1f1dSLionel Sambuc if ( __p != end() && !key_comp()(__k, __p->first)) 1167*0a6a1f1dSLionel Sambuc return __p; 1168*0a6a1f1dSLionel Sambuc else 1169*0a6a1f1dSLionel Sambuc return emplace_hint(__p, 1170*0a6a1f1dSLionel Sambuc _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), 1171*0a6a1f1dSLionel Sambuc _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); 1172*0a6a1f1dSLionel Sambuc } 1173*0a6a1f1dSLionel Sambuc 1174*0a6a1f1dSLionel Sambuc template <class _Vp> 1175*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1176*0a6a1f1dSLionel Sambuc pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) 1177*0a6a1f1dSLionel Sambuc { 1178*0a6a1f1dSLionel Sambuc iterator __p = lower_bound(__k); 1179*0a6a1f1dSLionel Sambuc if ( __p != end() && !key_comp()(__k, __p->first)) 1180*0a6a1f1dSLionel Sambuc { 1181*0a6a1f1dSLionel Sambuc __p->second = _VSTD::forward<_Vp>(__v); 1182*0a6a1f1dSLionel Sambuc return _VSTD::make_pair(__p, false); 1183*0a6a1f1dSLionel Sambuc } 1184*0a6a1f1dSLionel Sambuc return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true); 1185*0a6a1f1dSLionel Sambuc } 1186*0a6a1f1dSLionel Sambuc 1187*0a6a1f1dSLionel Sambuc template <class _Vp> 1188*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1189*0a6a1f1dSLionel Sambuc pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) 1190*0a6a1f1dSLionel Sambuc { 1191*0a6a1f1dSLionel Sambuc iterator __p = lower_bound(__k); 1192*0a6a1f1dSLionel Sambuc if ( __p != end() && !key_comp()(__k, __p->first)) 1193*0a6a1f1dSLionel Sambuc { 1194*0a6a1f1dSLionel Sambuc __p->second = _VSTD::forward<_Vp>(__v); 1195*0a6a1f1dSLionel Sambuc return _VSTD::make_pair(__p, false); 1196*0a6a1f1dSLionel Sambuc } 1197*0a6a1f1dSLionel Sambuc return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true); 1198*0a6a1f1dSLionel Sambuc } 1199*0a6a1f1dSLionel Sambuc 1200*0a6a1f1dSLionel Sambuc template <class _Vp> 1201*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1202*0a6a1f1dSLionel Sambuc iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) 1203*0a6a1f1dSLionel Sambuc { 1204*0a6a1f1dSLionel Sambuc iterator __p = lower_bound(__k); 1205*0a6a1f1dSLionel Sambuc if ( __p != end() && !key_comp()(__k, __p->first)) 1206*0a6a1f1dSLionel Sambuc { 1207*0a6a1f1dSLionel Sambuc __p->second = _VSTD::forward<_Vp>(__v); 1208*0a6a1f1dSLionel Sambuc return __p; 1209*0a6a1f1dSLionel Sambuc } 1210*0a6a1f1dSLionel Sambuc return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v)); 1211*0a6a1f1dSLionel Sambuc } 1212*0a6a1f1dSLionel Sambuc 1213*0a6a1f1dSLionel Sambuc template <class _Vp> 1214*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1215*0a6a1f1dSLionel Sambuc iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) 1216*0a6a1f1dSLionel Sambuc { 1217*0a6a1f1dSLionel Sambuc iterator __p = lower_bound(__k); 1218*0a6a1f1dSLionel Sambuc if ( __p != end() && !key_comp()(__k, __p->first)) 1219*0a6a1f1dSLionel Sambuc { 1220*0a6a1f1dSLionel Sambuc __p->second = _VSTD::forward<_Vp>(__v); 1221*0a6a1f1dSLionel Sambuc return __p; 1222*0a6a1f1dSLionel Sambuc } 1223*0a6a1f1dSLionel Sambuc return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)); 1224*0a6a1f1dSLionel Sambuc } 1225*0a6a1f1dSLionel Sambuc#endif 1226*0a6a1f1dSLionel Sambuc#endif 1227*0a6a1f1dSLionel Sambuc#endif 1228*0a6a1f1dSLionel Sambuc 12294684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12304684ddb6SLionel Sambuc iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} 12314684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1232*0a6a1f1dSLionel Sambuc iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} 1233*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12344684ddb6SLionel Sambuc size_type erase(const key_type& __k) 12354684ddb6SLionel Sambuc {return __tree_.__erase_unique(__k);} 12364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12374684ddb6SLionel Sambuc iterator erase(const_iterator __f, const_iterator __l) 12384684ddb6SLionel Sambuc {return __tree_.erase(__f.__i_, __l.__i_);} 12394684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12404684ddb6SLionel Sambuc void clear() _NOEXCEPT {__tree_.clear();} 12414684ddb6SLionel Sambuc 12424684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12434684ddb6SLionel Sambuc void swap(map& __m) 12444684ddb6SLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<__base>::value) 12454684ddb6SLionel Sambuc {__tree_.swap(__m.__tree_);} 12464684ddb6SLionel Sambuc 12474684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12484684ddb6SLionel Sambuc iterator find(const key_type& __k) {return __tree_.find(__k);} 12494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12504684ddb6SLionel Sambuc const_iterator find(const key_type& __k) const {return __tree_.find(__k);} 12514684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 12524684ddb6SLionel Sambuc template <typename _K2> 12534684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12544684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 12554684ddb6SLionel Sambuc find(const _K2& __k) {return __tree_.find(__k);} 12564684ddb6SLionel Sambuc template <typename _K2> 12574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12584684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 12594684ddb6SLionel Sambuc find(const _K2& __k) const {return __tree_.find(__k);} 12604684ddb6SLionel Sambuc#endif 12614684ddb6SLionel Sambuc 12624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12634684ddb6SLionel Sambuc size_type count(const key_type& __k) const 12644684ddb6SLionel Sambuc {return __tree_.__count_unique(__k);} 1265*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 11 1266*0a6a1f1dSLionel Sambuc template <typename _K2> 1267*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1268*0a6a1f1dSLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type 1269*0a6a1f1dSLionel Sambuc count(const _K2& __k) const {return __tree_.__count_unique(__k);} 1270*0a6a1f1dSLionel Sambuc#endif 12714684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12724684ddb6SLionel Sambuc iterator lower_bound(const key_type& __k) 12734684ddb6SLionel Sambuc {return __tree_.lower_bound(__k);} 12744684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12754684ddb6SLionel Sambuc const_iterator lower_bound(const key_type& __k) const 12764684ddb6SLionel Sambuc {return __tree_.lower_bound(__k);} 12774684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 12784684ddb6SLionel Sambuc template <typename _K2> 12794684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12804684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 12814684ddb6SLionel Sambuc lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} 12824684ddb6SLionel Sambuc 12834684ddb6SLionel Sambuc template <typename _K2> 12844684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12854684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 12864684ddb6SLionel Sambuc lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} 12874684ddb6SLionel Sambuc#endif 12884684ddb6SLionel Sambuc 12894684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12904684ddb6SLionel Sambuc iterator upper_bound(const key_type& __k) 12914684ddb6SLionel Sambuc {return __tree_.upper_bound(__k);} 12924684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12934684ddb6SLionel Sambuc const_iterator upper_bound(const key_type& __k) const 12944684ddb6SLionel Sambuc {return __tree_.upper_bound(__k);} 12954684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 12964684ddb6SLionel Sambuc template <typename _K2> 12974684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 12984684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 12994684ddb6SLionel Sambuc upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} 13004684ddb6SLionel Sambuc template <typename _K2> 13014684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13024684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 13034684ddb6SLionel Sambuc upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} 13044684ddb6SLionel Sambuc#endif 13054684ddb6SLionel Sambuc 13064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13074684ddb6SLionel Sambuc pair<iterator,iterator> equal_range(const key_type& __k) 13084684ddb6SLionel Sambuc {return __tree_.__equal_range_unique(__k);} 13094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13104684ddb6SLionel Sambuc pair<const_iterator,const_iterator> equal_range(const key_type& __k) const 13114684ddb6SLionel Sambuc {return __tree_.__equal_range_unique(__k);} 13124684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 13134684ddb6SLionel Sambuc template <typename _K2> 13144684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13154684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type 13164684ddb6SLionel Sambuc equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);} 13174684ddb6SLionel Sambuc template <typename _K2> 13184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13194684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type 13204684ddb6SLionel Sambuc equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);} 13214684ddb6SLionel Sambuc#endif 13224684ddb6SLionel Sambuc 13234684ddb6SLionel Sambucprivate: 13244684ddb6SLionel Sambuc typedef typename __base::__node __node; 13254684ddb6SLionel Sambuc typedef typename __base::__node_allocator __node_allocator; 13264684ddb6SLionel Sambuc typedef typename __base::__node_pointer __node_pointer; 13274684ddb6SLionel Sambuc typedef typename __base::__node_const_pointer __node_const_pointer; 13284684ddb6SLionel Sambuc typedef typename __base::__node_base_pointer __node_base_pointer; 13294684ddb6SLionel Sambuc typedef typename __base::__node_base_const_pointer __node_base_const_pointer; 13304684ddb6SLionel Sambuc typedef __map_node_destructor<__node_allocator> _Dp; 13314684ddb6SLionel Sambuc typedef unique_ptr<__node, _Dp> __node_holder; 13324684ddb6SLionel Sambuc 13334684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 13344684ddb6SLionel Sambuc __node_holder __construct_node(); 13354684ddb6SLionel Sambuc template <class _A0> 13364684ddb6SLionel Sambuc __node_holder __construct_node(_A0&& __a0); 13374684ddb6SLionel Sambuc __node_holder __construct_node_with_key(key_type&& __k); 13384684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 13394684ddb6SLionel Sambuc template <class _A0, class _A1, class ..._Args> 13404684ddb6SLionel Sambuc __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args); 13414684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 13424684ddb6SLionel Sambuc#endif 13434684ddb6SLionel Sambuc __node_holder __construct_node_with_key(const key_type& __k); 13444684ddb6SLionel Sambuc 13454684ddb6SLionel Sambuc __node_base_pointer& 13464684ddb6SLionel Sambuc __find_equal_key(__node_base_pointer& __parent, const key_type& __k); 13474684ddb6SLionel Sambuc __node_base_const_pointer 13484684ddb6SLionel Sambuc __find_equal_key(__node_base_const_pointer& __parent, const key_type& __k) const; 13494684ddb6SLionel Sambuc}; 13504684ddb6SLionel Sambuc 13514684ddb6SLionel Sambuc// Find place to insert if __k doesn't exist 13524684ddb6SLionel Sambuc// Set __parent to parent of null leaf 13534684ddb6SLionel Sambuc// Return reference to null leaf 13544684ddb6SLionel Sambuc// If __k exists, set parent to node of __k and return reference to node of __k 13554684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 13564684ddb6SLionel Sambuctypename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer& 13574684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent, 13584684ddb6SLionel Sambuc const key_type& __k) 13594684ddb6SLionel Sambuc{ 13604684ddb6SLionel Sambuc __node_pointer __nd = __tree_.__root(); 13614684ddb6SLionel Sambuc if (__nd != nullptr) 13624684ddb6SLionel Sambuc { 13634684ddb6SLionel Sambuc while (true) 13644684ddb6SLionel Sambuc { 13654684ddb6SLionel Sambuc if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first)) 13664684ddb6SLionel Sambuc { 13674684ddb6SLionel Sambuc if (__nd->__left_ != nullptr) 13684684ddb6SLionel Sambuc __nd = static_cast<__node_pointer>(__nd->__left_); 13694684ddb6SLionel Sambuc else 13704684ddb6SLionel Sambuc { 13714684ddb6SLionel Sambuc __parent = static_cast<__node_base_pointer>(__nd); 13724684ddb6SLionel Sambuc return __parent->__left_; 13734684ddb6SLionel Sambuc } 13744684ddb6SLionel Sambuc } 13754684ddb6SLionel Sambuc else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k)) 13764684ddb6SLionel Sambuc { 13774684ddb6SLionel Sambuc if (__nd->__right_ != nullptr) 13784684ddb6SLionel Sambuc __nd = static_cast<__node_pointer>(__nd->__right_); 13794684ddb6SLionel Sambuc else 13804684ddb6SLionel Sambuc { 13814684ddb6SLionel Sambuc __parent = static_cast<__node_base_pointer>(__nd); 13824684ddb6SLionel Sambuc return __parent->__right_; 13834684ddb6SLionel Sambuc } 13844684ddb6SLionel Sambuc } 13854684ddb6SLionel Sambuc else 13864684ddb6SLionel Sambuc { 13874684ddb6SLionel Sambuc __parent = static_cast<__node_base_pointer>(__nd); 13884684ddb6SLionel Sambuc return __parent; 13894684ddb6SLionel Sambuc } 13904684ddb6SLionel Sambuc } 13914684ddb6SLionel Sambuc } 13924684ddb6SLionel Sambuc __parent = static_cast<__node_base_pointer>(__tree_.__end_node()); 13934684ddb6SLionel Sambuc return __parent->__left_; 13944684ddb6SLionel Sambuc} 13954684ddb6SLionel Sambuc 13964684ddb6SLionel Sambuc// Find __k 13974684ddb6SLionel Sambuc// Set __parent to parent of null leaf and 13984684ddb6SLionel Sambuc// return reference to null leaf iv __k does not exist. 13994684ddb6SLionel Sambuc// If __k exists, set parent to node of __k and return reference to node of __k 14004684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 14014684ddb6SLionel Sambuctypename map<_Key, _Tp, _Compare, _Allocator>::__node_base_const_pointer 14024684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer& __parent, 14034684ddb6SLionel Sambuc const key_type& __k) const 14044684ddb6SLionel Sambuc{ 14054684ddb6SLionel Sambuc __node_const_pointer __nd = __tree_.__root(); 14064684ddb6SLionel Sambuc if (__nd != nullptr) 14074684ddb6SLionel Sambuc { 14084684ddb6SLionel Sambuc while (true) 14094684ddb6SLionel Sambuc { 14104684ddb6SLionel Sambuc if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first)) 14114684ddb6SLionel Sambuc { 14124684ddb6SLionel Sambuc if (__nd->__left_ != nullptr) 14134684ddb6SLionel Sambuc __nd = static_cast<__node_pointer>(__nd->__left_); 14144684ddb6SLionel Sambuc else 14154684ddb6SLionel Sambuc { 14164684ddb6SLionel Sambuc __parent = static_cast<__node_base_pointer>(__nd); 14174684ddb6SLionel Sambuc return const_cast<const __node_base_const_pointer&>(__parent->__left_); 14184684ddb6SLionel Sambuc } 14194684ddb6SLionel Sambuc } 14204684ddb6SLionel Sambuc else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k)) 14214684ddb6SLionel Sambuc { 14224684ddb6SLionel Sambuc if (__nd->__right_ != nullptr) 14234684ddb6SLionel Sambuc __nd = static_cast<__node_pointer>(__nd->__right_); 14244684ddb6SLionel Sambuc else 14254684ddb6SLionel Sambuc { 14264684ddb6SLionel Sambuc __parent = static_cast<__node_base_pointer>(__nd); 14274684ddb6SLionel Sambuc return const_cast<const __node_base_const_pointer&>(__parent->__right_); 14284684ddb6SLionel Sambuc } 14294684ddb6SLionel Sambuc } 14304684ddb6SLionel Sambuc else 14314684ddb6SLionel Sambuc { 14324684ddb6SLionel Sambuc __parent = static_cast<__node_base_pointer>(__nd); 14334684ddb6SLionel Sambuc return __parent; 14344684ddb6SLionel Sambuc } 14354684ddb6SLionel Sambuc } 14364684ddb6SLionel Sambuc } 14374684ddb6SLionel Sambuc __parent = static_cast<__node_base_pointer>(__tree_.__end_node()); 14384684ddb6SLionel Sambuc return const_cast<const __node_base_const_pointer&>(__parent->__left_); 14394684ddb6SLionel Sambuc} 14404684ddb6SLionel Sambuc 14414684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 14424684ddb6SLionel Sambuc 14434684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 14444684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) 14454684ddb6SLionel Sambuc : __tree_(_VSTD::move(__m.__tree_), __a) 14464684ddb6SLionel Sambuc{ 14474684ddb6SLionel Sambuc if (__a != __m.get_allocator()) 14484684ddb6SLionel Sambuc { 14494684ddb6SLionel Sambuc const_iterator __e = cend(); 14504684ddb6SLionel Sambuc while (!__m.empty()) 14514684ddb6SLionel Sambuc __tree_.__insert_unique(__e.__i_, 14524684ddb6SLionel Sambuc _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_)); 14534684ddb6SLionel Sambuc } 14544684ddb6SLionel Sambuc} 14554684ddb6SLionel Sambuc 14564684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 14574684ddb6SLionel Sambuctypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder 14584684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::__construct_node() 14594684ddb6SLionel Sambuc{ 14604684ddb6SLionel Sambuc __node_allocator& __na = __tree_.__node_alloc(); 14614684ddb6SLionel Sambuc __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 14624684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first)); 14634684ddb6SLionel Sambuc __h.get_deleter().__first_constructed = true; 14644684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); 14654684ddb6SLionel Sambuc __h.get_deleter().__second_constructed = true; 14664684ddb6SLionel Sambuc return __h; 14674684ddb6SLionel Sambuc} 14684684ddb6SLionel Sambuc 14694684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 14704684ddb6SLionel Sambuctemplate <class _A0> 14714684ddb6SLionel Sambuctypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder 14724684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0) 14734684ddb6SLionel Sambuc{ 14744684ddb6SLionel Sambuc __node_allocator& __na = __tree_.__node_alloc(); 14754684ddb6SLionel Sambuc __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 14764684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_A0>(__a0)); 14774684ddb6SLionel Sambuc __h.get_deleter().__first_constructed = true; 14784684ddb6SLionel Sambuc __h.get_deleter().__second_constructed = true; 14794684ddb6SLionel Sambuc return __h; 14804684ddb6SLionel Sambuc} 14814684ddb6SLionel Sambuc 14824684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 14834684ddb6SLionel Sambuctypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder 14844684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k) 14854684ddb6SLionel Sambuc{ 14864684ddb6SLionel Sambuc __node_allocator& __na = __tree_.__node_alloc(); 14874684ddb6SLionel Sambuc __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 14884684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k)); 14894684ddb6SLionel Sambuc __h.get_deleter().__first_constructed = true; 14904684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); 14914684ddb6SLionel Sambuc __h.get_deleter().__second_constructed = true; 14924684ddb6SLionel Sambuc return __h; 14934684ddb6SLionel Sambuc} 14944684ddb6SLionel Sambuc 14954684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 14964684ddb6SLionel Sambuc 14974684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 14984684ddb6SLionel Sambuctemplate <class _A0, class _A1, class ..._Args> 14994684ddb6SLionel Sambuctypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder 15004684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args) 15014684ddb6SLionel Sambuc{ 15024684ddb6SLionel Sambuc __node_allocator& __na = __tree_.__node_alloc(); 15034684ddb6SLionel Sambuc __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 15044684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_), 15054684ddb6SLionel Sambuc _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1), 15064684ddb6SLionel Sambuc _VSTD::forward<_Args>(__args)...); 15074684ddb6SLionel Sambuc __h.get_deleter().__first_constructed = true; 15084684ddb6SLionel Sambuc __h.get_deleter().__second_constructed = true; 15094684ddb6SLionel Sambuc return __h; 15104684ddb6SLionel Sambuc} 15114684ddb6SLionel Sambuc 15124684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 15134684ddb6SLionel Sambuc 15144684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 15154684ddb6SLionel Sambuc 15164684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15174684ddb6SLionel Sambuctypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder 15184684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) 15194684ddb6SLionel Sambuc{ 15204684ddb6SLionel Sambuc __node_allocator& __na = __tree_.__node_alloc(); 15214684ddb6SLionel Sambuc __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 15224684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k); 15234684ddb6SLionel Sambuc __h.get_deleter().__first_constructed = true; 15244684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); 15254684ddb6SLionel Sambuc __h.get_deleter().__second_constructed = true; 1526*0a6a1f1dSLionel Sambuc return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 15274684ddb6SLionel Sambuc} 15284684ddb6SLionel Sambuc 15294684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15304684ddb6SLionel Sambuc_Tp& 15314684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) 15324684ddb6SLionel Sambuc{ 15334684ddb6SLionel Sambuc __node_base_pointer __parent; 15344684ddb6SLionel Sambuc __node_base_pointer& __child = __find_equal_key(__parent, __k); 15354684ddb6SLionel Sambuc __node_pointer __r = static_cast<__node_pointer>(__child); 15364684ddb6SLionel Sambuc if (__child == nullptr) 15374684ddb6SLionel Sambuc { 15384684ddb6SLionel Sambuc __node_holder __h = __construct_node_with_key(__k); 15394684ddb6SLionel Sambuc __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); 15404684ddb6SLionel Sambuc __r = __h.release(); 15414684ddb6SLionel Sambuc } 15424684ddb6SLionel Sambuc return __r->__value_.__cc.second; 15434684ddb6SLionel Sambuc} 15444684ddb6SLionel Sambuc 15454684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 15464684ddb6SLionel Sambuc 15474684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15484684ddb6SLionel Sambuc_Tp& 15494684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) 15504684ddb6SLionel Sambuc{ 15514684ddb6SLionel Sambuc __node_base_pointer __parent; 15524684ddb6SLionel Sambuc __node_base_pointer& __child = __find_equal_key(__parent, __k); 15534684ddb6SLionel Sambuc __node_pointer __r = static_cast<__node_pointer>(__child); 15544684ddb6SLionel Sambuc if (__child == nullptr) 15554684ddb6SLionel Sambuc { 15564684ddb6SLionel Sambuc __node_holder __h = __construct_node_with_key(_VSTD::move(__k)); 15574684ddb6SLionel Sambuc __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); 15584684ddb6SLionel Sambuc __r = __h.release(); 15594684ddb6SLionel Sambuc } 15604684ddb6SLionel Sambuc return __r->__value_.__cc.second; 15614684ddb6SLionel Sambuc} 15624684ddb6SLionel Sambuc 15634684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 15644684ddb6SLionel Sambuc 15654684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15664684ddb6SLionel Sambuc_Tp& 15674684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) 15684684ddb6SLionel Sambuc{ 15694684ddb6SLionel Sambuc __node_base_pointer __parent; 15704684ddb6SLionel Sambuc __node_base_pointer& __child = __find_equal_key(__parent, __k); 15714684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 15724684ddb6SLionel Sambuc if (__child == nullptr) 15734684ddb6SLionel Sambuc throw out_of_range("map::at: key not found"); 15744684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 15754684ddb6SLionel Sambuc return static_cast<__node_pointer>(__child)->__value_.__cc.second; 15764684ddb6SLionel Sambuc} 15774684ddb6SLionel Sambuc 15784684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15794684ddb6SLionel Sambucconst _Tp& 15804684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const 15814684ddb6SLionel Sambuc{ 15824684ddb6SLionel Sambuc __node_base_const_pointer __parent; 15834684ddb6SLionel Sambuc __node_base_const_pointer __child = __find_equal_key(__parent, __k); 15844684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 15854684ddb6SLionel Sambuc if (__child == nullptr) 15864684ddb6SLionel Sambuc throw out_of_range("map::at: key not found"); 15874684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 15884684ddb6SLionel Sambuc return static_cast<__node_const_pointer>(__child)->__value_.__cc.second; 15894684ddb6SLionel Sambuc} 15904684ddb6SLionel Sambuc 15914684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 15924684ddb6SLionel Sambuc 15934684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15944684ddb6SLionel Sambuctemplate <class ..._Args> 15954684ddb6SLionel Sambucpair<typename map<_Key, _Tp, _Compare, _Allocator>::iterator, bool> 15964684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::emplace(_Args&& ...__args) 15974684ddb6SLionel Sambuc{ 15984684ddb6SLionel Sambuc __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); 15994684ddb6SLionel Sambuc pair<iterator, bool> __r = __tree_.__node_insert_unique(__h.get()); 16004684ddb6SLionel Sambuc if (__r.second) 16014684ddb6SLionel Sambuc __h.release(); 16024684ddb6SLionel Sambuc return __r; 16034684ddb6SLionel Sambuc} 16044684ddb6SLionel Sambuc 16054684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16064684ddb6SLionel Sambuctemplate <class ..._Args> 16074684ddb6SLionel Sambuctypename map<_Key, _Tp, _Compare, _Allocator>::iterator 16084684ddb6SLionel Sambucmap<_Key, _Tp, _Compare, _Allocator>::emplace_hint(const_iterator __p, 16094684ddb6SLionel Sambuc _Args&& ...__args) 16104684ddb6SLionel Sambuc{ 16114684ddb6SLionel Sambuc __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); 16124684ddb6SLionel Sambuc iterator __r = __tree_.__node_insert_unique(__p.__i_, __h.get()); 16134684ddb6SLionel Sambuc if (__r.__i_.__ptr_ == __h.get()) 16144684ddb6SLionel Sambuc __h.release(); 16154684ddb6SLionel Sambuc return __r; 16164684ddb6SLionel Sambuc} 16174684ddb6SLionel Sambuc 16184684ddb6SLionel Sambuc#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 16194684ddb6SLionel Sambuc 16204684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16214684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16224684ddb6SLionel Sambucbool 16234684ddb6SLionel Sambucoperator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, 16244684ddb6SLionel Sambuc const map<_Key, _Tp, _Compare, _Allocator>& __y) 16254684ddb6SLionel Sambuc{ 16264684ddb6SLionel Sambuc return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); 16274684ddb6SLionel Sambuc} 16284684ddb6SLionel Sambuc 16294684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16304684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16314684ddb6SLionel Sambucbool 16324684ddb6SLionel Sambucoperator< (const map<_Key, _Tp, _Compare, _Allocator>& __x, 16334684ddb6SLionel Sambuc const map<_Key, _Tp, _Compare, _Allocator>& __y) 16344684ddb6SLionel Sambuc{ 16354684ddb6SLionel Sambuc return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 16364684ddb6SLionel Sambuc} 16374684ddb6SLionel Sambuc 16384684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16394684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16404684ddb6SLionel Sambucbool 16414684ddb6SLionel Sambucoperator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x, 16424684ddb6SLionel Sambuc const map<_Key, _Tp, _Compare, _Allocator>& __y) 16434684ddb6SLionel Sambuc{ 16444684ddb6SLionel Sambuc return !(__x == __y); 16454684ddb6SLionel Sambuc} 16464684ddb6SLionel Sambuc 16474684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16494684ddb6SLionel Sambucbool 16504684ddb6SLionel Sambucoperator> (const map<_Key, _Tp, _Compare, _Allocator>& __x, 16514684ddb6SLionel Sambuc const map<_Key, _Tp, _Compare, _Allocator>& __y) 16524684ddb6SLionel Sambuc{ 16534684ddb6SLionel Sambuc return __y < __x; 16544684ddb6SLionel Sambuc} 16554684ddb6SLionel Sambuc 16564684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16574684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16584684ddb6SLionel Sambucbool 16594684ddb6SLionel Sambucoperator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x, 16604684ddb6SLionel Sambuc const map<_Key, _Tp, _Compare, _Allocator>& __y) 16614684ddb6SLionel Sambuc{ 16624684ddb6SLionel Sambuc return !(__x < __y); 16634684ddb6SLionel Sambuc} 16644684ddb6SLionel Sambuc 16654684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16664684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16674684ddb6SLionel Sambucbool 16684684ddb6SLionel Sambucoperator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, 16694684ddb6SLionel Sambuc const map<_Key, _Tp, _Compare, _Allocator>& __y) 16704684ddb6SLionel Sambuc{ 16714684ddb6SLionel Sambuc return !(__y < __x); 16724684ddb6SLionel Sambuc} 16734684ddb6SLionel Sambuc 16744684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16754684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16764684ddb6SLionel Sambucvoid 16774684ddb6SLionel Sambucswap(map<_Key, _Tp, _Compare, _Allocator>& __x, 16784684ddb6SLionel Sambuc map<_Key, _Tp, _Compare, _Allocator>& __y) 16794684ddb6SLionel Sambuc _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 16804684ddb6SLionel Sambuc{ 16814684ddb6SLionel Sambuc __x.swap(__y); 16824684ddb6SLionel Sambuc} 16834684ddb6SLionel Sambuc 16844684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare = less<_Key>, 16854684ddb6SLionel Sambuc class _Allocator = allocator<pair<const _Key, _Tp> > > 16864684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY multimap 16874684ddb6SLionel Sambuc{ 16884684ddb6SLionel Sambucpublic: 16894684ddb6SLionel Sambuc // types: 16904684ddb6SLionel Sambuc typedef _Key key_type; 16914684ddb6SLionel Sambuc typedef _Tp mapped_type; 16924684ddb6SLionel Sambuc typedef pair<const key_type, mapped_type> value_type; 16934684ddb6SLionel Sambuc typedef pair<key_type, mapped_type> __nc_value_type; 16944684ddb6SLionel Sambuc typedef _Compare key_compare; 16954684ddb6SLionel Sambuc typedef _Allocator allocator_type; 16964684ddb6SLionel Sambuc typedef value_type& reference; 16974684ddb6SLionel Sambuc typedef const value_type& const_reference; 16984684ddb6SLionel Sambuc 16994684ddb6SLionel Sambuc class _LIBCPP_TYPE_VIS_ONLY value_compare 17004684ddb6SLionel Sambuc : public binary_function<value_type, value_type, bool> 17014684ddb6SLionel Sambuc { 17024684ddb6SLionel Sambuc friend class multimap; 17034684ddb6SLionel Sambuc protected: 17044684ddb6SLionel Sambuc key_compare comp; 17054684ddb6SLionel Sambuc 17064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17074684ddb6SLionel Sambuc value_compare(key_compare c) : comp(c) {} 17084684ddb6SLionel Sambuc public: 17094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17104684ddb6SLionel Sambuc bool operator()(const value_type& __x, const value_type& __y) const 17114684ddb6SLionel Sambuc {return comp(__x.first, __y.first);} 17124684ddb6SLionel Sambuc }; 17134684ddb6SLionel Sambuc 17144684ddb6SLionel Sambucprivate: 17154684ddb6SLionel Sambuc 17164684ddb6SLionel Sambuc typedef _VSTD::__value_type<key_type, mapped_type> __value_type; 17174684ddb6SLionel Sambuc typedef __map_value_compare<key_type, __value_type, key_compare> __vc; 1718*0a6a1f1dSLionel Sambuc typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, 1719*0a6a1f1dSLionel Sambuc __value_type>::type __allocator_type; 17204684ddb6SLionel Sambuc typedef __tree<__value_type, __vc, __allocator_type> __base; 17214684ddb6SLionel Sambuc typedef typename __base::__node_traits __node_traits; 17224684ddb6SLionel Sambuc typedef allocator_traits<allocator_type> __alloc_traits; 17234684ddb6SLionel Sambuc 17244684ddb6SLionel Sambuc __base __tree_; 17254684ddb6SLionel Sambuc 17264684ddb6SLionel Sambucpublic: 17274684ddb6SLionel Sambuc typedef typename __alloc_traits::pointer pointer; 17284684ddb6SLionel Sambuc typedef typename __alloc_traits::const_pointer const_pointer; 17294684ddb6SLionel Sambuc typedef typename __alloc_traits::size_type size_type; 17304684ddb6SLionel Sambuc typedef typename __alloc_traits::difference_type difference_type; 17314684ddb6SLionel Sambuc typedef __map_iterator<typename __base::iterator> iterator; 17324684ddb6SLionel Sambuc typedef __map_const_iterator<typename __base::const_iterator> const_iterator; 17334684ddb6SLionel Sambuc typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 17344684ddb6SLionel Sambuc typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 17354684ddb6SLionel Sambuc 17364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1737*0a6a1f1dSLionel Sambuc multimap() 17384684ddb6SLionel Sambuc _NOEXCEPT_( 17394684ddb6SLionel Sambuc is_nothrow_default_constructible<allocator_type>::value && 17404684ddb6SLionel Sambuc is_nothrow_default_constructible<key_compare>::value && 17414684ddb6SLionel Sambuc is_nothrow_copy_constructible<key_compare>::value) 1742*0a6a1f1dSLionel Sambuc : __tree_(__vc(key_compare())) {} 1743*0a6a1f1dSLionel Sambuc 1744*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1745*0a6a1f1dSLionel Sambuc explicit multimap(const key_compare& __comp) 1746*0a6a1f1dSLionel Sambuc _NOEXCEPT_( 1747*0a6a1f1dSLionel Sambuc is_nothrow_default_constructible<allocator_type>::value && 1748*0a6a1f1dSLionel Sambuc is_nothrow_copy_constructible<key_compare>::value) 17494684ddb6SLionel Sambuc : __tree_(__vc(__comp)) {} 17504684ddb6SLionel Sambuc 17514684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17524684ddb6SLionel Sambuc explicit multimap(const key_compare& __comp, const allocator_type& __a) 17534684ddb6SLionel Sambuc : __tree_(__vc(__comp), __a) {} 17544684ddb6SLionel Sambuc 17554684ddb6SLionel Sambuc template <class _InputIterator> 17564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17574684ddb6SLionel Sambuc multimap(_InputIterator __f, _InputIterator __l, 17584684ddb6SLionel Sambuc const key_compare& __comp = key_compare()) 17594684ddb6SLionel Sambuc : __tree_(__vc(__comp)) 17604684ddb6SLionel Sambuc { 17614684ddb6SLionel Sambuc insert(__f, __l); 17624684ddb6SLionel Sambuc } 17634684ddb6SLionel Sambuc 17644684ddb6SLionel Sambuc template <class _InputIterator> 17654684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17664684ddb6SLionel Sambuc multimap(_InputIterator __f, _InputIterator __l, 17674684ddb6SLionel Sambuc const key_compare& __comp, const allocator_type& __a) 17684684ddb6SLionel Sambuc : __tree_(__vc(__comp), __a) 17694684ddb6SLionel Sambuc { 17704684ddb6SLionel Sambuc insert(__f, __l); 17714684ddb6SLionel Sambuc } 17724684ddb6SLionel Sambuc 17734684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 17744684ddb6SLionel Sambuc template <class _InputIterator> 17754684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17764684ddb6SLionel Sambuc multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) 17774684ddb6SLionel Sambuc : multimap(__f, __l, key_compare(), __a) {} 17784684ddb6SLionel Sambuc#endif 17794684ddb6SLionel Sambuc 17804684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17814684ddb6SLionel Sambuc multimap(const multimap& __m) 17824684ddb6SLionel Sambuc : __tree_(__m.__tree_.value_comp(), 17834684ddb6SLionel Sambuc __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc())) 17844684ddb6SLionel Sambuc { 17854684ddb6SLionel Sambuc insert(__m.begin(), __m.end()); 17864684ddb6SLionel Sambuc } 17874684ddb6SLionel Sambuc 17884684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17894684ddb6SLionel Sambuc multimap& operator=(const multimap& __m) 17904684ddb6SLionel Sambuc { 17914684ddb6SLionel Sambuc#if __cplusplus >= 201103L 17924684ddb6SLionel Sambuc __tree_ = __m.__tree_; 17934684ddb6SLionel Sambuc#else 1794*0a6a1f1dSLionel Sambuc if (this != &__m) { 17954684ddb6SLionel Sambuc __tree_.clear(); 17964684ddb6SLionel Sambuc __tree_.value_comp() = __m.__tree_.value_comp(); 17974684ddb6SLionel Sambuc __tree_.__copy_assign_alloc(__m.__tree_); 17984684ddb6SLionel Sambuc insert(__m.begin(), __m.end()); 1799*0a6a1f1dSLionel Sambuc } 18004684ddb6SLionel Sambuc#endif 18014684ddb6SLionel Sambuc return *this; 18024684ddb6SLionel Sambuc } 18034684ddb6SLionel Sambuc 18044684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 18054684ddb6SLionel Sambuc 18064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18074684ddb6SLionel Sambuc multimap(multimap&& __m) 18084684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) 18094684ddb6SLionel Sambuc : __tree_(_VSTD::move(__m.__tree_)) 18104684ddb6SLionel Sambuc { 18114684ddb6SLionel Sambuc } 18124684ddb6SLionel Sambuc 18134684ddb6SLionel Sambuc multimap(multimap&& __m, const allocator_type& __a); 18144684ddb6SLionel Sambuc 18154684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18164684ddb6SLionel Sambuc multimap& operator=(multimap&& __m) 18174684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) 18184684ddb6SLionel Sambuc { 18194684ddb6SLionel Sambuc __tree_ = _VSTD::move(__m.__tree_); 18204684ddb6SLionel Sambuc return *this; 18214684ddb6SLionel Sambuc } 18224684ddb6SLionel Sambuc 18234684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 18244684ddb6SLionel Sambuc 18254684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 18264684ddb6SLionel Sambuc 18274684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18284684ddb6SLionel Sambuc multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) 18294684ddb6SLionel Sambuc : __tree_(__vc(__comp)) 18304684ddb6SLionel Sambuc { 18314684ddb6SLionel Sambuc insert(__il.begin(), __il.end()); 18324684ddb6SLionel Sambuc } 18334684ddb6SLionel Sambuc 18344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18354684ddb6SLionel Sambuc multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) 18364684ddb6SLionel Sambuc : __tree_(__vc(__comp), __a) 18374684ddb6SLionel Sambuc { 18384684ddb6SLionel Sambuc insert(__il.begin(), __il.end()); 18394684ddb6SLionel Sambuc } 18404684ddb6SLionel Sambuc 18414684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 18424684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18434684ddb6SLionel Sambuc multimap(initializer_list<value_type> __il, const allocator_type& __a) 18444684ddb6SLionel Sambuc : multimap(__il, key_compare(), __a) {} 18454684ddb6SLionel Sambuc#endif 18464684ddb6SLionel Sambuc 18474684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18484684ddb6SLionel Sambuc multimap& operator=(initializer_list<value_type> __il) 18494684ddb6SLionel Sambuc { 18504684ddb6SLionel Sambuc __tree_.__assign_multi(__il.begin(), __il.end()); 18514684ddb6SLionel Sambuc return *this; 18524684ddb6SLionel Sambuc } 18534684ddb6SLionel Sambuc 18544684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 18554684ddb6SLionel Sambuc 18564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18574684ddb6SLionel Sambuc explicit multimap(const allocator_type& __a) 18584684ddb6SLionel Sambuc : __tree_(__a) 18594684ddb6SLionel Sambuc { 18604684ddb6SLionel Sambuc } 18614684ddb6SLionel Sambuc 18624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18634684ddb6SLionel Sambuc multimap(const multimap& __m, const allocator_type& __a) 18644684ddb6SLionel Sambuc : __tree_(__m.__tree_.value_comp(), __a) 18654684ddb6SLionel Sambuc { 18664684ddb6SLionel Sambuc insert(__m.begin(), __m.end()); 18674684ddb6SLionel Sambuc } 18684684ddb6SLionel Sambuc 18694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18704684ddb6SLionel Sambuc iterator begin() _NOEXCEPT {return __tree_.begin();} 18714684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18724684ddb6SLionel Sambuc const_iterator begin() const _NOEXCEPT {return __tree_.begin();} 18734684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18744684ddb6SLionel Sambuc iterator end() _NOEXCEPT {return __tree_.end();} 18754684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18764684ddb6SLionel Sambuc const_iterator end() const _NOEXCEPT {return __tree_.end();} 18774684ddb6SLionel Sambuc 18784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18794684ddb6SLionel Sambuc reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} 18804684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18814684ddb6SLionel Sambuc const_reverse_iterator rbegin() const _NOEXCEPT 18824684ddb6SLionel Sambuc {return const_reverse_iterator(end());} 18834684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18844684ddb6SLionel Sambuc reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} 18854684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18864684ddb6SLionel Sambuc const_reverse_iterator rend() const _NOEXCEPT 18874684ddb6SLionel Sambuc {return const_reverse_iterator(begin());} 18884684ddb6SLionel Sambuc 18894684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18904684ddb6SLionel Sambuc const_iterator cbegin() const _NOEXCEPT {return begin();} 18914684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18924684ddb6SLionel Sambuc const_iterator cend() const _NOEXCEPT {return end();} 18934684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18944684ddb6SLionel Sambuc const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 18954684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18964684ddb6SLionel Sambuc const_reverse_iterator crend() const _NOEXCEPT {return rend();} 18974684ddb6SLionel Sambuc 18984684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18994684ddb6SLionel Sambuc bool empty() const _NOEXCEPT {return __tree_.size() == 0;} 19004684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19014684ddb6SLionel Sambuc size_type size() const _NOEXCEPT {return __tree_.size();} 19024684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19034684ddb6SLionel Sambuc size_type max_size() const _NOEXCEPT {return __tree_.max_size();} 19044684ddb6SLionel Sambuc 19054684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19064684ddb6SLionel Sambuc allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} 19074684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19084684ddb6SLionel Sambuc key_compare key_comp() const {return __tree_.value_comp().key_comp();} 19094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19104684ddb6SLionel Sambuc value_compare value_comp() const 19114684ddb6SLionel Sambuc {return value_compare(__tree_.value_comp().key_comp());} 19124684ddb6SLionel Sambuc 19134684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 19144684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 19154684ddb6SLionel Sambuc 19164684ddb6SLionel Sambuc template <class ..._Args> 19174684ddb6SLionel Sambuc iterator 19184684ddb6SLionel Sambuc emplace(_Args&& ...__args); 19194684ddb6SLionel Sambuc 19204684ddb6SLionel Sambuc template <class ..._Args> 19214684ddb6SLionel Sambuc iterator 19224684ddb6SLionel Sambuc emplace_hint(const_iterator __p, _Args&& ...__args); 19234684ddb6SLionel Sambuc 19244684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 19254684ddb6SLionel Sambuc 19264684ddb6SLionel Sambuc template <class _Pp, 19274684ddb6SLionel Sambuc class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 19284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19294684ddb6SLionel Sambuc iterator insert(_Pp&& __p) 19304684ddb6SLionel Sambuc {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));} 19314684ddb6SLionel Sambuc 19324684ddb6SLionel Sambuc template <class _Pp, 19334684ddb6SLionel Sambuc class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 19344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19354684ddb6SLionel Sambuc iterator insert(const_iterator __pos, _Pp&& __p) 19364684ddb6SLionel Sambuc {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));} 19374684ddb6SLionel Sambuc 19384684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 19394684ddb6SLionel Sambuc 19404684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19414684ddb6SLionel Sambuc iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);} 19424684ddb6SLionel Sambuc 19434684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19444684ddb6SLionel Sambuc iterator insert(const_iterator __p, const value_type& __v) 19454684ddb6SLionel Sambuc {return __tree_.__insert_multi(__p.__i_, __v);} 19464684ddb6SLionel Sambuc 19474684ddb6SLionel Sambuc template <class _InputIterator> 19484684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19494684ddb6SLionel Sambuc void insert(_InputIterator __f, _InputIterator __l) 19504684ddb6SLionel Sambuc { 19514684ddb6SLionel Sambuc for (const_iterator __e = cend(); __f != __l; ++__f) 19524684ddb6SLionel Sambuc __tree_.__insert_multi(__e.__i_, *__f); 19534684ddb6SLionel Sambuc } 19544684ddb6SLionel Sambuc 19554684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 19564684ddb6SLionel Sambuc 19574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19584684ddb6SLionel Sambuc void insert(initializer_list<value_type> __il) 19594684ddb6SLionel Sambuc {insert(__il.begin(), __il.end());} 19604684ddb6SLionel Sambuc 19614684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 19624684ddb6SLionel Sambuc 19634684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19644684ddb6SLionel Sambuc iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} 19654684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1966*0a6a1f1dSLionel Sambuc iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} 1967*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19684684ddb6SLionel Sambuc size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} 19694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19704684ddb6SLionel Sambuc iterator erase(const_iterator __f, const_iterator __l) 19714684ddb6SLionel Sambuc {return __tree_.erase(__f.__i_, __l.__i_);} 19724684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19734684ddb6SLionel Sambuc void clear() {__tree_.clear();} 19744684ddb6SLionel Sambuc 19754684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19764684ddb6SLionel Sambuc void swap(multimap& __m) 19774684ddb6SLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<__base>::value) 19784684ddb6SLionel Sambuc {__tree_.swap(__m.__tree_);} 19794684ddb6SLionel Sambuc 19804684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19814684ddb6SLionel Sambuc iterator find(const key_type& __k) {return __tree_.find(__k);} 19824684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19834684ddb6SLionel Sambuc const_iterator find(const key_type& __k) const {return __tree_.find(__k);} 19844684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 19854684ddb6SLionel Sambuc template <typename _K2> 19864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19874684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 19884684ddb6SLionel Sambuc find(const _K2& __k) {return __tree_.find(__k);} 19894684ddb6SLionel Sambuc template <typename _K2> 19904684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19914684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 19924684ddb6SLionel Sambuc find(const _K2& __k) const {return __tree_.find(__k);} 19934684ddb6SLionel Sambuc#endif 19944684ddb6SLionel Sambuc 19954684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 19964684ddb6SLionel Sambuc size_type count(const key_type& __k) const 19974684ddb6SLionel Sambuc {return __tree_.__count_multi(__k);} 1998*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 11 1999*0a6a1f1dSLionel Sambuc template <typename _K2> 2000*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2001*0a6a1f1dSLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type 2002*0a6a1f1dSLionel Sambuc count(const _K2& __k) const {return __tree_.__count_multi(__k);} 2003*0a6a1f1dSLionel Sambuc#endif 20044684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20054684ddb6SLionel Sambuc iterator lower_bound(const key_type& __k) 20064684ddb6SLionel Sambuc {return __tree_.lower_bound(__k);} 20074684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20084684ddb6SLionel Sambuc const_iterator lower_bound(const key_type& __k) const 20094684ddb6SLionel Sambuc {return __tree_.lower_bound(__k);} 20104684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 20114684ddb6SLionel Sambuc template <typename _K2> 20124684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20134684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 20144684ddb6SLionel Sambuc lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} 20154684ddb6SLionel Sambuc 20164684ddb6SLionel Sambuc template <typename _K2> 20174684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20184684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 20194684ddb6SLionel Sambuc lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} 20204684ddb6SLionel Sambuc#endif 20214684ddb6SLionel Sambuc 20224684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20234684ddb6SLionel Sambuc iterator upper_bound(const key_type& __k) 20244684ddb6SLionel Sambuc {return __tree_.upper_bound(__k);} 20254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20264684ddb6SLionel Sambuc const_iterator upper_bound(const key_type& __k) const 20274684ddb6SLionel Sambuc {return __tree_.upper_bound(__k);} 20284684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 20294684ddb6SLionel Sambuc template <typename _K2> 20304684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20314684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 20324684ddb6SLionel Sambuc upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} 20334684ddb6SLionel Sambuc template <typename _K2> 20344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20354684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 20364684ddb6SLionel Sambuc upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} 20374684ddb6SLionel Sambuc#endif 20384684ddb6SLionel Sambuc 20394684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20404684ddb6SLionel Sambuc pair<iterator,iterator> equal_range(const key_type& __k) 20414684ddb6SLionel Sambuc {return __tree_.__equal_range_multi(__k);} 20424684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20434684ddb6SLionel Sambuc pair<const_iterator,const_iterator> equal_range(const key_type& __k) const 20444684ddb6SLionel Sambuc {return __tree_.__equal_range_multi(__k);} 20454684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 20464684ddb6SLionel Sambuc template <typename _K2> 20474684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20484684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type 20494684ddb6SLionel Sambuc equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} 20504684ddb6SLionel Sambuc template <typename _K2> 20514684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20524684ddb6SLionel Sambuc typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type 20534684ddb6SLionel Sambuc equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} 20544684ddb6SLionel Sambuc#endif 20554684ddb6SLionel Sambuc 20564684ddb6SLionel Sambucprivate: 20574684ddb6SLionel Sambuc typedef typename __base::__node __node; 20584684ddb6SLionel Sambuc typedef typename __base::__node_allocator __node_allocator; 20594684ddb6SLionel Sambuc typedef typename __base::__node_pointer __node_pointer; 20604684ddb6SLionel Sambuc typedef typename __base::__node_const_pointer __node_const_pointer; 20614684ddb6SLionel Sambuc typedef __map_node_destructor<__node_allocator> _Dp; 20624684ddb6SLionel Sambuc typedef unique_ptr<__node, _Dp> __node_holder; 20634684ddb6SLionel Sambuc 20644684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 20654684ddb6SLionel Sambuc __node_holder __construct_node(); 20664684ddb6SLionel Sambuc template <class _A0> 20674684ddb6SLionel Sambuc __node_holder 20684684ddb6SLionel Sambuc __construct_node(_A0&& __a0); 20694684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 20704684ddb6SLionel Sambuc template <class _A0, class _A1, class ..._Args> 20714684ddb6SLionel Sambuc __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args); 20724684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 20734684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 20744684ddb6SLionel Sambuc}; 20754684ddb6SLionel Sambuc 20764684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 20774684ddb6SLionel Sambuc 20784684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 20794684ddb6SLionel Sambucmultimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a) 20804684ddb6SLionel Sambuc : __tree_(_VSTD::move(__m.__tree_), __a) 20814684ddb6SLionel Sambuc{ 20824684ddb6SLionel Sambuc if (__a != __m.get_allocator()) 20834684ddb6SLionel Sambuc { 20844684ddb6SLionel Sambuc const_iterator __e = cend(); 20854684ddb6SLionel Sambuc while (!__m.empty()) 20864684ddb6SLionel Sambuc __tree_.__insert_multi(__e.__i_, 20874684ddb6SLionel Sambuc _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_)); 20884684ddb6SLionel Sambuc } 20894684ddb6SLionel Sambuc} 20904684ddb6SLionel Sambuc 20914684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 20924684ddb6SLionel Sambuctypename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder 20934684ddb6SLionel Sambucmultimap<_Key, _Tp, _Compare, _Allocator>::__construct_node() 20944684ddb6SLionel Sambuc{ 20954684ddb6SLionel Sambuc __node_allocator& __na = __tree_.__node_alloc(); 20964684ddb6SLionel Sambuc __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 20974684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first)); 20984684ddb6SLionel Sambuc __h.get_deleter().__first_constructed = true; 20994684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); 21004684ddb6SLionel Sambuc __h.get_deleter().__second_constructed = true; 21014684ddb6SLionel Sambuc return __h; 21024684ddb6SLionel Sambuc} 21034684ddb6SLionel Sambuc 21044684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21054684ddb6SLionel Sambuctemplate <class _A0> 21064684ddb6SLionel Sambuctypename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder 21074684ddb6SLionel Sambucmultimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0) 21084684ddb6SLionel Sambuc{ 21094684ddb6SLionel Sambuc __node_allocator& __na = __tree_.__node_alloc(); 21104684ddb6SLionel Sambuc __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 21114684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_A0>(__a0)); 21124684ddb6SLionel Sambuc __h.get_deleter().__first_constructed = true; 21134684ddb6SLionel Sambuc __h.get_deleter().__second_constructed = true; 21144684ddb6SLionel Sambuc return __h; 21154684ddb6SLionel Sambuc} 21164684ddb6SLionel Sambuc 21174684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 21184684ddb6SLionel Sambuc 21194684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21204684ddb6SLionel Sambuctemplate <class _A0, class _A1, class ..._Args> 21214684ddb6SLionel Sambuctypename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder 21224684ddb6SLionel Sambucmultimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args) 21234684ddb6SLionel Sambuc{ 21244684ddb6SLionel Sambuc __node_allocator& __na = __tree_.__node_alloc(); 21254684ddb6SLionel Sambuc __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 21264684ddb6SLionel Sambuc __node_traits::construct(__na, _VSTD::addressof(__h->__value_), 21274684ddb6SLionel Sambuc _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1), 21284684ddb6SLionel Sambuc _VSTD::forward<_Args>(__args)...); 21294684ddb6SLionel Sambuc __h.get_deleter().__first_constructed = true; 21304684ddb6SLionel Sambuc __h.get_deleter().__second_constructed = true; 21314684ddb6SLionel Sambuc return __h; 21324684ddb6SLionel Sambuc} 21334684ddb6SLionel Sambuc 21344684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 21354684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 21364684ddb6SLionel Sambuc 21374684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 21384684ddb6SLionel Sambuc 21394684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21404684ddb6SLionel Sambuctemplate <class ..._Args> 21414684ddb6SLionel Sambuctypename multimap<_Key, _Tp, _Compare, _Allocator>::iterator 21424684ddb6SLionel Sambucmultimap<_Key, _Tp, _Compare, _Allocator>::emplace(_Args&& ...__args) 21434684ddb6SLionel Sambuc{ 21444684ddb6SLionel Sambuc __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); 21454684ddb6SLionel Sambuc iterator __r = __tree_.__node_insert_multi(__h.get()); 21464684ddb6SLionel Sambuc __h.release(); 21474684ddb6SLionel Sambuc return __r; 21484684ddb6SLionel Sambuc} 21494684ddb6SLionel Sambuc 21504684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21514684ddb6SLionel Sambuctemplate <class ..._Args> 21524684ddb6SLionel Sambuctypename multimap<_Key, _Tp, _Compare, _Allocator>::iterator 21534684ddb6SLionel Sambucmultimap<_Key, _Tp, _Compare, _Allocator>::emplace_hint(const_iterator __p, 21544684ddb6SLionel Sambuc _Args&& ...__args) 21554684ddb6SLionel Sambuc{ 21564684ddb6SLionel Sambuc __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); 21574684ddb6SLionel Sambuc iterator __r = __tree_.__node_insert_multi(__p.__i_, __h.get()); 21584684ddb6SLionel Sambuc __h.release(); 21594684ddb6SLionel Sambuc return __r; 21604684ddb6SLionel Sambuc} 21614684ddb6SLionel Sambuc 21624684ddb6SLionel Sambuc#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 21634684ddb6SLionel Sambuc 21644684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21654684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 21664684ddb6SLionel Sambucbool 21674684ddb6SLionel Sambucoperator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21684684ddb6SLionel Sambuc const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21694684ddb6SLionel Sambuc{ 21704684ddb6SLionel Sambuc return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); 21714684ddb6SLionel Sambuc} 21724684ddb6SLionel Sambuc 21734684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21744684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 21754684ddb6SLionel Sambucbool 21764684ddb6SLionel Sambucoperator< (const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21774684ddb6SLionel Sambuc const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21784684ddb6SLionel Sambuc{ 21794684ddb6SLionel Sambuc return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 21804684ddb6SLionel Sambuc} 21814684ddb6SLionel Sambuc 21824684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21834684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 21844684ddb6SLionel Sambucbool 21854684ddb6SLionel Sambucoperator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21864684ddb6SLionel Sambuc const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21874684ddb6SLionel Sambuc{ 21884684ddb6SLionel Sambuc return !(__x == __y); 21894684ddb6SLionel Sambuc} 21904684ddb6SLionel Sambuc 21914684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21924684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 21934684ddb6SLionel Sambucbool 21944684ddb6SLionel Sambucoperator> (const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21954684ddb6SLionel Sambuc const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21964684ddb6SLionel Sambuc{ 21974684ddb6SLionel Sambuc return __y < __x; 21984684ddb6SLionel Sambuc} 21994684ddb6SLionel Sambuc 22004684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 22014684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 22024684ddb6SLionel Sambucbool 22034684ddb6SLionel Sambucoperator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 22044684ddb6SLionel Sambuc const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 22054684ddb6SLionel Sambuc{ 22064684ddb6SLionel Sambuc return !(__x < __y); 22074684ddb6SLionel Sambuc} 22084684ddb6SLionel Sambuc 22094684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 22104684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 22114684ddb6SLionel Sambucbool 22124684ddb6SLionel Sambucoperator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 22134684ddb6SLionel Sambuc const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 22144684ddb6SLionel Sambuc{ 22154684ddb6SLionel Sambuc return !(__y < __x); 22164684ddb6SLionel Sambuc} 22174684ddb6SLionel Sambuc 22184684ddb6SLionel Sambuctemplate <class _Key, class _Tp, class _Compare, class _Allocator> 22194684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 22204684ddb6SLionel Sambucvoid 22214684ddb6SLionel Sambucswap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, 22224684ddb6SLionel Sambuc multimap<_Key, _Tp, _Compare, _Allocator>& __y) 22234684ddb6SLionel Sambuc _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 22244684ddb6SLionel Sambuc{ 22254684ddb6SLionel Sambuc __x.swap(__y); 22264684ddb6SLionel Sambuc} 22274684ddb6SLionel Sambuc 22284684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD 22294684ddb6SLionel Sambuc 22304684ddb6SLionel Sambuc#endif // _LIBCPP_MAP 2231