1*700637cbSDimitry Andric// -*- C++ -*- 2*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 3*700637cbSDimitry Andric// 4*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*700637cbSDimitry Andric// 8*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 9*700637cbSDimitry Andric 10*700637cbSDimitry Andric#ifndef _LIBCPP___CXX03_MAP 11*700637cbSDimitry Andric#define _LIBCPP___CXX03_MAP 12*700637cbSDimitry Andric 13*700637cbSDimitry Andric/* 14*700637cbSDimitry Andric 15*700637cbSDimitry Andric map synopsis 16*700637cbSDimitry Andric 17*700637cbSDimitry Andricnamespace std 18*700637cbSDimitry Andric{ 19*700637cbSDimitry Andric 20*700637cbSDimitry Andrictemplate <class Key, class T, class Compare = less<Key>, 21*700637cbSDimitry Andric class Allocator = allocator<pair<const Key, T>>> 22*700637cbSDimitry Andricclass map 23*700637cbSDimitry Andric{ 24*700637cbSDimitry Andricpublic: 25*700637cbSDimitry Andric // types: 26*700637cbSDimitry Andric typedef Key key_type; 27*700637cbSDimitry Andric typedef T mapped_type; 28*700637cbSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 29*700637cbSDimitry Andric typedef Compare key_compare; 30*700637cbSDimitry Andric typedef Allocator allocator_type; 31*700637cbSDimitry Andric typedef typename allocator_type::reference reference; 32*700637cbSDimitry Andric typedef typename allocator_type::const_reference const_reference; 33*700637cbSDimitry Andric typedef typename allocator_type::pointer pointer; 34*700637cbSDimitry Andric typedef typename allocator_type::const_pointer const_pointer; 35*700637cbSDimitry Andric typedef typename allocator_type::size_type size_type; 36*700637cbSDimitry Andric typedef typename allocator_type::difference_type difference_type; 37*700637cbSDimitry Andric 38*700637cbSDimitry Andric typedef implementation-defined iterator; 39*700637cbSDimitry Andric typedef implementation-defined const_iterator; 40*700637cbSDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 41*700637cbSDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 42*700637cbSDimitry Andric typedef unspecified node_type; // C++17 43*700637cbSDimitry Andric typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 44*700637cbSDimitry Andric 45*700637cbSDimitry Andric class value_compare 46*700637cbSDimitry Andric { 47*700637cbSDimitry Andric friend class map; 48*700637cbSDimitry Andric protected: 49*700637cbSDimitry Andric key_compare comp; 50*700637cbSDimitry Andric 51*700637cbSDimitry Andric value_compare(key_compare c); 52*700637cbSDimitry Andric public: 53*700637cbSDimitry Andric typedef bool result_type; // deprecated in C++17, removed in C++20 54*700637cbSDimitry Andric typedef value_type first_argument_type; // deprecated in C++17, removed in C++20 55*700637cbSDimitry Andric typedef value_type second_argument_type; // deprecated in C++17, removed in C++20 56*700637cbSDimitry Andric bool operator()(const value_type& x, const value_type& y) const; 57*700637cbSDimitry Andric }; 58*700637cbSDimitry Andric 59*700637cbSDimitry Andric // construct/copy/destroy: 60*700637cbSDimitry Andric map() 61*700637cbSDimitry Andric noexcept( 62*700637cbSDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 63*700637cbSDimitry Andric is_nothrow_default_constructible<key_compare>::value && 64*700637cbSDimitry Andric is_nothrow_copy_constructible<key_compare>::value); 65*700637cbSDimitry Andric explicit map(const key_compare& comp); 66*700637cbSDimitry Andric map(const key_compare& comp, const allocator_type& a); 67*700637cbSDimitry Andric template <class InputIterator> 68*700637cbSDimitry Andric map(InputIterator first, InputIterator last, 69*700637cbSDimitry Andric const key_compare& comp = key_compare()); 70*700637cbSDimitry Andric template <class InputIterator> 71*700637cbSDimitry Andric map(InputIterator first, InputIterator last, 72*700637cbSDimitry Andric const key_compare& comp, const allocator_type& a); 73*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 74*700637cbSDimitry Andric map(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23 75*700637cbSDimitry Andric map(const map& m); 76*700637cbSDimitry Andric map(map&& m) 77*700637cbSDimitry Andric noexcept( 78*700637cbSDimitry Andric is_nothrow_move_constructible<allocator_type>::value && 79*700637cbSDimitry Andric is_nothrow_move_constructible<key_compare>::value); 80*700637cbSDimitry Andric explicit map(const allocator_type& a); 81*700637cbSDimitry Andric map(const map& m, const allocator_type& a); 82*700637cbSDimitry Andric map(map&& m, const allocator_type& a); 83*700637cbSDimitry Andric map(initializer_list<value_type> il, const key_compare& comp = key_compare()); 84*700637cbSDimitry Andric map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); 85*700637cbSDimitry Andric template <class InputIterator> 86*700637cbSDimitry Andric map(InputIterator first, InputIterator last, const allocator_type& a) 87*700637cbSDimitry Andric : map(first, last, Compare(), a) {} // C++14 88*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 89*700637cbSDimitry Andric map(from_range_t, R&& rg, const Allocator& a)) 90*700637cbSDimitry Andric : map(from_range, std::forward<R>(rg), Compare(), a) { } // C++23 91*700637cbSDimitry Andric map(initializer_list<value_type> il, const allocator_type& a) 92*700637cbSDimitry Andric : map(il, Compare(), a) {} // C++14 93*700637cbSDimitry Andric ~map(); 94*700637cbSDimitry Andric 95*700637cbSDimitry Andric map& operator=(const map& m); 96*700637cbSDimitry Andric map& operator=(map&& m) 97*700637cbSDimitry Andric noexcept( 98*700637cbSDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 99*700637cbSDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 100*700637cbSDimitry Andric is_nothrow_move_assignable<key_compare>::value); 101*700637cbSDimitry Andric map& operator=(initializer_list<value_type> il); 102*700637cbSDimitry Andric 103*700637cbSDimitry Andric // iterators: 104*700637cbSDimitry Andric iterator begin() noexcept; 105*700637cbSDimitry Andric const_iterator begin() const noexcept; 106*700637cbSDimitry Andric iterator end() noexcept; 107*700637cbSDimitry Andric const_iterator end() const noexcept; 108*700637cbSDimitry Andric 109*700637cbSDimitry Andric reverse_iterator rbegin() noexcept; 110*700637cbSDimitry Andric const_reverse_iterator rbegin() const noexcept; 111*700637cbSDimitry Andric reverse_iterator rend() noexcept; 112*700637cbSDimitry Andric const_reverse_iterator rend() const noexcept; 113*700637cbSDimitry Andric 114*700637cbSDimitry Andric const_iterator cbegin() const noexcept; 115*700637cbSDimitry Andric const_iterator cend() const noexcept; 116*700637cbSDimitry Andric const_reverse_iterator crbegin() const noexcept; 117*700637cbSDimitry Andric const_reverse_iterator crend() const noexcept; 118*700637cbSDimitry Andric 119*700637cbSDimitry Andric // capacity: 120*700637cbSDimitry Andric bool empty() const noexcept; 121*700637cbSDimitry Andric size_type size() const noexcept; 122*700637cbSDimitry Andric size_type max_size() const noexcept; 123*700637cbSDimitry Andric 124*700637cbSDimitry Andric // element access: 125*700637cbSDimitry Andric mapped_type& operator[](const key_type& k); 126*700637cbSDimitry Andric mapped_type& operator[](key_type&& k); 127*700637cbSDimitry Andric 128*700637cbSDimitry Andric mapped_type& at(const key_type& k); 129*700637cbSDimitry Andric const mapped_type& at(const key_type& k) const; 130*700637cbSDimitry Andric 131*700637cbSDimitry Andric // modifiers: 132*700637cbSDimitry Andric template <class... Args> 133*700637cbSDimitry Andric pair<iterator, bool> emplace(Args&&... args); 134*700637cbSDimitry Andric template <class... Args> 135*700637cbSDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 136*700637cbSDimitry Andric pair<iterator, bool> insert(const value_type& v); 137*700637cbSDimitry Andric pair<iterator, bool> insert( value_type&& v); // C++17 138*700637cbSDimitry Andric template <class P> 139*700637cbSDimitry Andric pair<iterator, bool> insert(P&& p); 140*700637cbSDimitry Andric iterator insert(const_iterator position, const value_type& v); 141*700637cbSDimitry Andric iterator insert(const_iterator position, value_type&& v); // C++17 142*700637cbSDimitry Andric template <class P> 143*700637cbSDimitry Andric iterator insert(const_iterator position, P&& p); 144*700637cbSDimitry Andric template <class InputIterator> 145*700637cbSDimitry Andric void insert(InputIterator first, InputIterator last); 146*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 147*700637cbSDimitry Andric void insert_range(R&& rg); // C++23 148*700637cbSDimitry Andric void insert(initializer_list<value_type> il); 149*700637cbSDimitry Andric 150*700637cbSDimitry Andric node_type extract(const_iterator position); // C++17 151*700637cbSDimitry Andric node_type extract(const key_type& x); // C++17 152*700637cbSDimitry Andric insert_return_type insert(node_type&& nh); // C++17 153*700637cbSDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 154*700637cbSDimitry Andric 155*700637cbSDimitry Andric template <class... Args> 156*700637cbSDimitry Andric pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17 157*700637cbSDimitry Andric template <class... Args> 158*700637cbSDimitry Andric pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17 159*700637cbSDimitry Andric template <class... Args> 160*700637cbSDimitry Andric iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 161*700637cbSDimitry Andric template <class... Args> 162*700637cbSDimitry Andric iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 163*700637cbSDimitry Andric template <class M> 164*700637cbSDimitry Andric pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17 165*700637cbSDimitry Andric template <class M> 166*700637cbSDimitry Andric pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17 167*700637cbSDimitry Andric template <class M> 168*700637cbSDimitry Andric iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 169*700637cbSDimitry Andric template <class M> 170*700637cbSDimitry Andric iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 171*700637cbSDimitry Andric 172*700637cbSDimitry Andric iterator erase(const_iterator position); 173*700637cbSDimitry Andric iterator erase(iterator position); // C++14 174*700637cbSDimitry Andric size_type erase(const key_type& k); 175*700637cbSDimitry Andric iterator erase(const_iterator first, const_iterator last); 176*700637cbSDimitry Andric void clear() noexcept; 177*700637cbSDimitry Andric 178*700637cbSDimitry Andric template<class C2> 179*700637cbSDimitry Andric void merge(map<Key, T, C2, Allocator>& source); // C++17 180*700637cbSDimitry Andric template<class C2> 181*700637cbSDimitry Andric void merge(map<Key, T, C2, Allocator>&& source); // C++17 182*700637cbSDimitry Andric template<class C2> 183*700637cbSDimitry Andric void merge(multimap<Key, T, C2, Allocator>& source); // C++17 184*700637cbSDimitry Andric template<class C2> 185*700637cbSDimitry Andric void merge(multimap<Key, T, C2, Allocator>&& source); // C++17 186*700637cbSDimitry Andric 187*700637cbSDimitry Andric void swap(map& m) 188*700637cbSDimitry Andric noexcept(allocator_traits<allocator_type>::is_always_equal::value && 189*700637cbSDimitry Andric is_nothrow_swappable<key_compare>::value); // C++17 190*700637cbSDimitry Andric 191*700637cbSDimitry Andric // observers: 192*700637cbSDimitry Andric allocator_type get_allocator() const noexcept; 193*700637cbSDimitry Andric key_compare key_comp() const; 194*700637cbSDimitry Andric value_compare value_comp() const; 195*700637cbSDimitry Andric 196*700637cbSDimitry Andric // map operations: 197*700637cbSDimitry Andric iterator find(const key_type& k); 198*700637cbSDimitry Andric const_iterator find(const key_type& k) const; 199*700637cbSDimitry Andric template<typename K> 200*700637cbSDimitry Andric iterator find(const K& x); // C++14 201*700637cbSDimitry Andric template<typename K> 202*700637cbSDimitry Andric const_iterator find(const K& x) const; // C++14 203*700637cbSDimitry Andric 204*700637cbSDimitry Andric template<typename K> 205*700637cbSDimitry Andric size_type count(const K& x) const; // C++14 206*700637cbSDimitry Andric size_type count(const key_type& k) const; 207*700637cbSDimitry Andric 208*700637cbSDimitry Andric bool contains(const key_type& x) const; // C++20 209*700637cbSDimitry Andric template<class K> bool contains(const K& x) const; // C++20 210*700637cbSDimitry Andric 211*700637cbSDimitry Andric iterator lower_bound(const key_type& k); 212*700637cbSDimitry Andric const_iterator lower_bound(const key_type& k) const; 213*700637cbSDimitry Andric template<typename K> 214*700637cbSDimitry Andric iterator lower_bound(const K& x); // C++14 215*700637cbSDimitry Andric template<typename K> 216*700637cbSDimitry Andric const_iterator lower_bound(const K& x) const; // C++14 217*700637cbSDimitry Andric 218*700637cbSDimitry Andric iterator upper_bound(const key_type& k); 219*700637cbSDimitry Andric const_iterator upper_bound(const key_type& k) const; 220*700637cbSDimitry Andric template<typename K> 221*700637cbSDimitry Andric iterator upper_bound(const K& x); // C++14 222*700637cbSDimitry Andric template<typename K> 223*700637cbSDimitry Andric const_iterator upper_bound(const K& x) const; // C++14 224*700637cbSDimitry Andric 225*700637cbSDimitry Andric pair<iterator,iterator> equal_range(const key_type& k); 226*700637cbSDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 227*700637cbSDimitry Andric template<typename K> 228*700637cbSDimitry Andric pair<iterator,iterator> equal_range(const K& x); // C++14 229*700637cbSDimitry Andric template<typename K> 230*700637cbSDimitry Andric pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 231*700637cbSDimitry Andric}; 232*700637cbSDimitry Andric 233*700637cbSDimitry Andrictemplate <class InputIterator, 234*700637cbSDimitry Andric class Compare = less<iter_key_t<InputIterator>>, 235*700637cbSDimitry Andric class Allocator = allocator<iter_to_alloc_t<InputIterator>>> 236*700637cbSDimitry Andricmap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) 237*700637cbSDimitry Andric -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17 238*700637cbSDimitry Andric 239*700637cbSDimitry Andrictemplate<ranges::input_range R, class Compare = less<range-key-type<R>, 240*700637cbSDimitry Andric class Allocator = allocator<range-to-alloc-type<R>>> 241*700637cbSDimitry Andric map(from_range_t, R&&, Compare = Compare(), Allocator = Allocator()) 242*700637cbSDimitry Andric -> map<range-key-type<R>, range-mapped-type<R>, Compare, Allocator>; // C++23 243*700637cbSDimitry Andric 244*700637cbSDimitry Andrictemplate<class Key, class T, class Compare = less<Key>, 245*700637cbSDimitry Andric class Allocator = allocator<pair<const Key, T>>> 246*700637cbSDimitry Andricmap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator()) 247*700637cbSDimitry Andric -> map<Key, T, Compare, Allocator>; // C++17 248*700637cbSDimitry Andric 249*700637cbSDimitry Andrictemplate <class InputIterator, class Allocator> 250*700637cbSDimitry Andricmap(InputIterator, InputIterator, Allocator) 251*700637cbSDimitry Andric -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, less<iter_key_t<InputIterator>>, 252*700637cbSDimitry Andric Allocator>; // C++17 253*700637cbSDimitry Andric 254*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator> 255*700637cbSDimitry Andric map(from_range_t, R&&, Allocator) 256*700637cbSDimitry Andric -> map<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>, Allocator>; // C++23 257*700637cbSDimitry Andric 258*700637cbSDimitry Andrictemplate<class Key, class T, class Allocator> 259*700637cbSDimitry Andricmap(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>; // C++17 260*700637cbSDimitry Andric 261*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 262*700637cbSDimitry Andricbool 263*700637cbSDimitry Andricoperator==(const map<Key, T, Compare, Allocator>& x, 264*700637cbSDimitry Andric const map<Key, T, Compare, Allocator>& y); 265*700637cbSDimitry Andric 266*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 267*700637cbSDimitry Andricbool 268*700637cbSDimitry Andricoperator< (const map<Key, T, Compare, Allocator>& x, 269*700637cbSDimitry Andric const map<Key, T, Compare, Allocator>& y); // removed in C++20 270*700637cbSDimitry Andric 271*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 272*700637cbSDimitry Andricbool 273*700637cbSDimitry Andricoperator!=(const map<Key, T, Compare, Allocator>& x, 274*700637cbSDimitry Andric const map<Key, T, Compare, Allocator>& y); // removed in C++20 275*700637cbSDimitry Andric 276*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 277*700637cbSDimitry Andricbool 278*700637cbSDimitry Andricoperator> (const map<Key, T, Compare, Allocator>& x, 279*700637cbSDimitry Andric const map<Key, T, Compare, Allocator>& y); // removed in C++20 280*700637cbSDimitry Andric 281*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 282*700637cbSDimitry Andricbool 283*700637cbSDimitry Andricoperator>=(const map<Key, T, Compare, Allocator>& x, 284*700637cbSDimitry Andric const map<Key, T, Compare, Allocator>& y); // removed in C++20 285*700637cbSDimitry Andric 286*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 287*700637cbSDimitry Andricbool 288*700637cbSDimitry Andricoperator<=(const map<Key, T, Compare, Allocator>& x, 289*700637cbSDimitry Andric const map<Key, T, Compare, Allocator>& y); // removed in C++20 290*700637cbSDimitry Andric 291*700637cbSDimitry Andrictemplate<class Key, class T, class Compare, class Allocator> 292*700637cbSDimitry Andric synth-three-way-result<pair<const Key, T>> 293*700637cbSDimitry Andric operator<=>(const map<Key, T, Compare, Allocator>& x, 294*700637cbSDimitry Andric const map<Key, T, Compare, Allocator>& y); // since C++20 295*700637cbSDimitry Andric 296*700637cbSDimitry Andric// specialized algorithms: 297*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 298*700637cbSDimitry Andricvoid 299*700637cbSDimitry Andricswap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y) 300*700637cbSDimitry Andric noexcept(noexcept(x.swap(y))); 301*700637cbSDimitry Andric 302*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator, class Predicate> 303*700637cbSDimitry Andrictypename map<Key, T, Compare, Allocator>::size_type 304*700637cbSDimitry Andricerase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 305*700637cbSDimitry Andric 306*700637cbSDimitry Andric 307*700637cbSDimitry Andrictemplate <class Key, class T, class Compare = less<Key>, 308*700637cbSDimitry Andric class Allocator = allocator<pair<const Key, T>>> 309*700637cbSDimitry Andricclass multimap 310*700637cbSDimitry Andric{ 311*700637cbSDimitry Andricpublic: 312*700637cbSDimitry Andric // types: 313*700637cbSDimitry Andric typedef Key key_type; 314*700637cbSDimitry Andric typedef T mapped_type; 315*700637cbSDimitry Andric typedef pair<const key_type,mapped_type> value_type; 316*700637cbSDimitry Andric typedef Compare key_compare; 317*700637cbSDimitry Andric typedef Allocator allocator_type; 318*700637cbSDimitry Andric typedef typename allocator_type::reference reference; 319*700637cbSDimitry Andric typedef typename allocator_type::const_reference const_reference; 320*700637cbSDimitry Andric typedef typename allocator_type::size_type size_type; 321*700637cbSDimitry Andric typedef typename allocator_type::difference_type difference_type; 322*700637cbSDimitry Andric typedef typename allocator_type::pointer pointer; 323*700637cbSDimitry Andric typedef typename allocator_type::const_pointer const_pointer; 324*700637cbSDimitry Andric 325*700637cbSDimitry Andric typedef implementation-defined iterator; 326*700637cbSDimitry Andric typedef implementation-defined const_iterator; 327*700637cbSDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 328*700637cbSDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 329*700637cbSDimitry Andric typedef unspecified node_type; // C++17 330*700637cbSDimitry Andric 331*700637cbSDimitry Andric class value_compare 332*700637cbSDimitry Andric { 333*700637cbSDimitry Andric friend class multimap; 334*700637cbSDimitry Andric protected: 335*700637cbSDimitry Andric key_compare comp; 336*700637cbSDimitry Andric value_compare(key_compare c); 337*700637cbSDimitry Andric public: 338*700637cbSDimitry Andric typedef bool result_type; // deprecated in C++17, removed in C++20 339*700637cbSDimitry Andric typedef value_type first_argument_type; // deprecated in C++17, removed in C++20 340*700637cbSDimitry Andric typedef value_type second_argument_type; // deprecated in C++17, removed in C++20 341*700637cbSDimitry Andric bool operator()(const value_type& x, const value_type& y) const; 342*700637cbSDimitry Andric }; 343*700637cbSDimitry Andric 344*700637cbSDimitry Andric // construct/copy/destroy: 345*700637cbSDimitry Andric multimap() 346*700637cbSDimitry Andric noexcept( 347*700637cbSDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 348*700637cbSDimitry Andric is_nothrow_default_constructible<key_compare>::value && 349*700637cbSDimitry Andric is_nothrow_copy_constructible<key_compare>::value); 350*700637cbSDimitry Andric explicit multimap(const key_compare& comp); 351*700637cbSDimitry Andric multimap(const key_compare& comp, const allocator_type& a); 352*700637cbSDimitry Andric template <class InputIterator> 353*700637cbSDimitry Andric multimap(InputIterator first, InputIterator last, const key_compare& comp); 354*700637cbSDimitry Andric template <class InputIterator> 355*700637cbSDimitry Andric multimap(InputIterator first, InputIterator last, const key_compare& comp, 356*700637cbSDimitry Andric const allocator_type& a); 357*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 358*700637cbSDimitry Andric multimap(from_range_t, R&& rg, 359*700637cbSDimitry Andric const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23 360*700637cbSDimitry Andric multimap(const multimap& m); 361*700637cbSDimitry Andric multimap(multimap&& m) 362*700637cbSDimitry Andric noexcept( 363*700637cbSDimitry Andric is_nothrow_move_constructible<allocator_type>::value && 364*700637cbSDimitry Andric is_nothrow_move_constructible<key_compare>::value); 365*700637cbSDimitry Andric explicit multimap(const allocator_type& a); 366*700637cbSDimitry Andric multimap(const multimap& m, const allocator_type& a); 367*700637cbSDimitry Andric multimap(multimap&& m, const allocator_type& a); 368*700637cbSDimitry Andric multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); 369*700637cbSDimitry Andric multimap(initializer_list<value_type> il, const key_compare& comp, 370*700637cbSDimitry Andric const allocator_type& a); 371*700637cbSDimitry Andric template <class InputIterator> 372*700637cbSDimitry Andric multimap(InputIterator first, InputIterator last, const allocator_type& a) 373*700637cbSDimitry Andric : multimap(first, last, Compare(), a) {} // C++14 374*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 375*700637cbSDimitry Andric multimap(from_range_t, R&& rg, const Allocator& a)) 376*700637cbSDimitry Andric : multimap(from_range, std::forward<R>(rg), Compare(), a) { } // C++23 377*700637cbSDimitry Andric multimap(initializer_list<value_type> il, const allocator_type& a) 378*700637cbSDimitry Andric : multimap(il, Compare(), a) {} // C++14 379*700637cbSDimitry Andric ~multimap(); 380*700637cbSDimitry Andric 381*700637cbSDimitry Andric multimap& operator=(const multimap& m); 382*700637cbSDimitry Andric multimap& operator=(multimap&& m) 383*700637cbSDimitry Andric noexcept( 384*700637cbSDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 385*700637cbSDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 386*700637cbSDimitry Andric is_nothrow_move_assignable<key_compare>::value); 387*700637cbSDimitry Andric multimap& operator=(initializer_list<value_type> il); 388*700637cbSDimitry Andric 389*700637cbSDimitry Andric // iterators: 390*700637cbSDimitry Andric iterator begin() noexcept; 391*700637cbSDimitry Andric const_iterator begin() const noexcept; 392*700637cbSDimitry Andric iterator end() noexcept; 393*700637cbSDimitry Andric const_iterator end() const noexcept; 394*700637cbSDimitry Andric 395*700637cbSDimitry Andric reverse_iterator rbegin() noexcept; 396*700637cbSDimitry Andric const_reverse_iterator rbegin() const noexcept; 397*700637cbSDimitry Andric reverse_iterator rend() noexcept; 398*700637cbSDimitry Andric const_reverse_iterator rend() const noexcept; 399*700637cbSDimitry Andric 400*700637cbSDimitry Andric const_iterator cbegin() const noexcept; 401*700637cbSDimitry Andric const_iterator cend() const noexcept; 402*700637cbSDimitry Andric const_reverse_iterator crbegin() const noexcept; 403*700637cbSDimitry Andric const_reverse_iterator crend() const noexcept; 404*700637cbSDimitry Andric 405*700637cbSDimitry Andric // capacity: 406*700637cbSDimitry Andric bool empty() const noexcept; 407*700637cbSDimitry Andric size_type size() const noexcept; 408*700637cbSDimitry Andric size_type max_size() const noexcept; 409*700637cbSDimitry Andric 410*700637cbSDimitry Andric // modifiers: 411*700637cbSDimitry Andric template <class... Args> 412*700637cbSDimitry Andric iterator emplace(Args&&... args); 413*700637cbSDimitry Andric template <class... Args> 414*700637cbSDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 415*700637cbSDimitry Andric iterator insert(const value_type& v); 416*700637cbSDimitry Andric iterator insert( value_type&& v); // C++17 417*700637cbSDimitry Andric template <class P> 418*700637cbSDimitry Andric iterator insert(P&& p); 419*700637cbSDimitry Andric iterator insert(const_iterator position, const value_type& v); 420*700637cbSDimitry Andric iterator insert(const_iterator position, value_type&& v); // C++17 421*700637cbSDimitry Andric template <class P> 422*700637cbSDimitry Andric iterator insert(const_iterator position, P&& p); 423*700637cbSDimitry Andric template <class InputIterator> 424*700637cbSDimitry Andric void insert(InputIterator first, InputIterator last); 425*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 426*700637cbSDimitry Andric void insert_range(R&& rg); // C++23 427*700637cbSDimitry Andric void insert(initializer_list<value_type> il); 428*700637cbSDimitry Andric 429*700637cbSDimitry Andric node_type extract(const_iterator position); // C++17 430*700637cbSDimitry Andric node_type extract(const key_type& x); // C++17 431*700637cbSDimitry Andric iterator insert(node_type&& nh); // C++17 432*700637cbSDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 433*700637cbSDimitry Andric 434*700637cbSDimitry Andric iterator erase(const_iterator position); 435*700637cbSDimitry Andric iterator erase(iterator position); // C++14 436*700637cbSDimitry Andric size_type erase(const key_type& k); 437*700637cbSDimitry Andric iterator erase(const_iterator first, const_iterator last); 438*700637cbSDimitry Andric void clear() noexcept; 439*700637cbSDimitry Andric 440*700637cbSDimitry Andric template<class C2> 441*700637cbSDimitry Andric void merge(multimap<Key, T, C2, Allocator>& source); // C++17 442*700637cbSDimitry Andric template<class C2> 443*700637cbSDimitry Andric void merge(multimap<Key, T, C2, Allocator>&& source); // C++17 444*700637cbSDimitry Andric template<class C2> 445*700637cbSDimitry Andric void merge(map<Key, T, C2, Allocator>& source); // C++17 446*700637cbSDimitry Andric template<class C2> 447*700637cbSDimitry Andric void merge(map<Key, T, C2, Allocator>&& source); // C++17 448*700637cbSDimitry Andric 449*700637cbSDimitry Andric void swap(multimap& m) 450*700637cbSDimitry Andric noexcept(allocator_traits<allocator_type>::is_always_equal::value && 451*700637cbSDimitry Andric is_nothrow_swappable<key_compare>::value); // C++17 452*700637cbSDimitry Andric 453*700637cbSDimitry Andric // observers: 454*700637cbSDimitry Andric allocator_type get_allocator() const noexcept; 455*700637cbSDimitry Andric key_compare key_comp() const; 456*700637cbSDimitry Andric value_compare value_comp() const; 457*700637cbSDimitry Andric 458*700637cbSDimitry Andric // map operations: 459*700637cbSDimitry Andric iterator find(const key_type& k); 460*700637cbSDimitry Andric const_iterator find(const key_type& k) const; 461*700637cbSDimitry Andric template<typename K> 462*700637cbSDimitry Andric iterator find(const K& x); // C++14 463*700637cbSDimitry Andric template<typename K> 464*700637cbSDimitry Andric const_iterator find(const K& x) const; // C++14 465*700637cbSDimitry Andric 466*700637cbSDimitry Andric template<typename K> 467*700637cbSDimitry Andric size_type count(const K& x) const; // C++14 468*700637cbSDimitry Andric size_type count(const key_type& k) const; 469*700637cbSDimitry Andric 470*700637cbSDimitry Andric bool contains(const key_type& x) const; // C++20 471*700637cbSDimitry Andric template<class K> bool contains(const K& x) const; // C++20 472*700637cbSDimitry Andric 473*700637cbSDimitry Andric iterator lower_bound(const key_type& k); 474*700637cbSDimitry Andric const_iterator lower_bound(const key_type& k) const; 475*700637cbSDimitry Andric template<typename K> 476*700637cbSDimitry Andric iterator lower_bound(const K& x); // C++14 477*700637cbSDimitry Andric template<typename K> 478*700637cbSDimitry Andric const_iterator lower_bound(const K& x) const; // C++14 479*700637cbSDimitry Andric 480*700637cbSDimitry Andric iterator upper_bound(const key_type& k); 481*700637cbSDimitry Andric const_iterator upper_bound(const key_type& k) const; 482*700637cbSDimitry Andric template<typename K> 483*700637cbSDimitry Andric iterator upper_bound(const K& x); // C++14 484*700637cbSDimitry Andric template<typename K> 485*700637cbSDimitry Andric const_iterator upper_bound(const K& x) const; // C++14 486*700637cbSDimitry Andric 487*700637cbSDimitry Andric pair<iterator,iterator> equal_range(const key_type& k); 488*700637cbSDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 489*700637cbSDimitry Andric template<typename K> 490*700637cbSDimitry Andric pair<iterator,iterator> equal_range(const K& x); // C++14 491*700637cbSDimitry Andric template<typename K> 492*700637cbSDimitry Andric pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 493*700637cbSDimitry Andric}; 494*700637cbSDimitry Andric 495*700637cbSDimitry Andrictemplate <class InputIterator, 496*700637cbSDimitry Andric class Compare = less<iter_key_t<InputIterator>>, 497*700637cbSDimitry Andric class Allocator = allocator<iter_to_alloc_t<InputIterator>>> 498*700637cbSDimitry Andricmultimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) 499*700637cbSDimitry Andric -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17 500*700637cbSDimitry Andric 501*700637cbSDimitry Andrictemplate<ranges::input_range R, class Compare = less<range-key-type<R>>, 502*700637cbSDimitry Andric class Allocator = allocator<range-to-alloc-type<R>>> 503*700637cbSDimitry Andric multimap(from_range_t, R&&, Compare = Compare(), Allocator = Allocator()) 504*700637cbSDimitry Andric -> multimap<range-key-type<R>, range-mapped-type<R>, Compare, Allocator>; // C++23 505*700637cbSDimitry Andric 506*700637cbSDimitry Andrictemplate<class Key, class T, class Compare = less<Key>, 507*700637cbSDimitry Andric class Allocator = allocator<pair<const Key, T>>> 508*700637cbSDimitry Andricmultimap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator()) 509*700637cbSDimitry Andric -> multimap<Key, T, Compare, Allocator>; // C++17 510*700637cbSDimitry Andric 511*700637cbSDimitry Andrictemplate <class InputIterator, class Allocator> 512*700637cbSDimitry Andricmultimap(InputIterator, InputIterator, Allocator) 513*700637cbSDimitry Andric -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, 514*700637cbSDimitry Andric less<iter_key_t<InputIterator>>, Allocator>; // C++17 515*700637cbSDimitry Andric 516*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator> 517*700637cbSDimitry Andric multimap(from_range_t, R&&, Allocator) 518*700637cbSDimitry Andric -> multimap<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>, Allocator>; // C++23 519*700637cbSDimitry Andric 520*700637cbSDimitry Andrictemplate<class Key, class T, class Allocator> 521*700637cbSDimitry Andricmultimap(initializer_list<pair<const Key, T>>, Allocator) 522*700637cbSDimitry Andric -> multimap<Key, T, less<Key>, Allocator>; // C++17 523*700637cbSDimitry Andric 524*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 525*700637cbSDimitry Andricbool 526*700637cbSDimitry Andricoperator==(const multimap<Key, T, Compare, Allocator>& x, 527*700637cbSDimitry Andric const multimap<Key, T, Compare, Allocator>& y); 528*700637cbSDimitry Andric 529*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 530*700637cbSDimitry Andricbool 531*700637cbSDimitry Andricoperator< (const multimap<Key, T, Compare, Allocator>& x, 532*700637cbSDimitry Andric const multimap<Key, T, Compare, Allocator>& y); // removed in C++20 533*700637cbSDimitry Andric 534*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 535*700637cbSDimitry Andricbool 536*700637cbSDimitry Andricoperator!=(const multimap<Key, T, Compare, Allocator>& x, 537*700637cbSDimitry Andric const multimap<Key, T, Compare, Allocator>& y); // removed in C++20 538*700637cbSDimitry Andric 539*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 540*700637cbSDimitry Andricbool 541*700637cbSDimitry Andricoperator> (const multimap<Key, T, Compare, Allocator>& x, 542*700637cbSDimitry Andric const multimap<Key, T, Compare, Allocator>& y); // removed in C++20 543*700637cbSDimitry Andric 544*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 545*700637cbSDimitry Andricbool 546*700637cbSDimitry Andricoperator>=(const multimap<Key, T, Compare, Allocator>& x, 547*700637cbSDimitry Andric const multimap<Key, T, Compare, Allocator>& y); // removed in C++20 548*700637cbSDimitry Andric 549*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 550*700637cbSDimitry Andricbool 551*700637cbSDimitry Andricoperator<=(const multimap<Key, T, Compare, Allocator>& x, 552*700637cbSDimitry Andric const multimap<Key, T, Compare, Allocator>& y); // removed in C++20 553*700637cbSDimitry Andric 554*700637cbSDimitry Andrictemplate<class Key, class T, class Compare, class Allocator> 555*700637cbSDimitry Andric synth-three-way-result<pair<const Key, T>> 556*700637cbSDimitry Andric operator<=>(const multimap<Key, T, Compare, Allocator>& x, 557*700637cbSDimitry Andric const multimap<Key, T, Compare, Allocator>& y); // since c++20 558*700637cbSDimitry Andric 559*700637cbSDimitry Andric// specialized algorithms: 560*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator> 561*700637cbSDimitry Andricvoid 562*700637cbSDimitry Andricswap(multimap<Key, T, Compare, Allocator>& x, 563*700637cbSDimitry Andric multimap<Key, T, Compare, Allocator>& y) 564*700637cbSDimitry Andric noexcept(noexcept(x.swap(y))); 565*700637cbSDimitry Andric 566*700637cbSDimitry Andrictemplate <class Key, class T, class Compare, class Allocator, class Predicate> 567*700637cbSDimitry Andrictypename multimap<Key, T, Compare, Allocator>::size_type 568*700637cbSDimitry Andricerase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 569*700637cbSDimitry Andric 570*700637cbSDimitry Andric} // std 571*700637cbSDimitry Andric 572*700637cbSDimitry Andric*/ 573*700637cbSDimitry Andric 574*700637cbSDimitry Andric#include <__cxx03/__algorithm/equal.h> 575*700637cbSDimitry Andric#include <__cxx03/__algorithm/lexicographical_compare.h> 576*700637cbSDimitry Andric#include <__cxx03/__assert> 577*700637cbSDimitry Andric#include <__cxx03/__config> 578*700637cbSDimitry Andric#include <__cxx03/__functional/binary_function.h> 579*700637cbSDimitry Andric#include <__cxx03/__functional/operations.h> 580*700637cbSDimitry Andric#include <__cxx03/__iterator/erase_if_container.h> 581*700637cbSDimitry Andric#include <__cxx03/__iterator/iterator_traits.h> 582*700637cbSDimitry Andric#include <__cxx03/__iterator/reverse_iterator.h> 583*700637cbSDimitry Andric#include <__cxx03/__memory/addressof.h> 584*700637cbSDimitry Andric#include <__cxx03/__memory/allocator.h> 585*700637cbSDimitry Andric#include <__cxx03/__tree> 586*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_allocator.h> 587*700637cbSDimitry Andric#include <__cxx03/__utility/forward.h> 588*700637cbSDimitry Andric#include <__cxx03/__utility/piecewise_construct.h> 589*700637cbSDimitry Andric#include <__cxx03/__utility/swap.h> 590*700637cbSDimitry Andric#include <__cxx03/stdexcept> 591*700637cbSDimitry Andric#include <__cxx03/version> 592*700637cbSDimitry Andric 593*700637cbSDimitry Andric// standard-mandated includes 594*700637cbSDimitry Andric 595*700637cbSDimitry Andric// [iterator.range] 596*700637cbSDimitry Andric#include <__cxx03/__iterator/access.h> 597*700637cbSDimitry Andric 598*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 599*700637cbSDimitry Andric# pragma GCC system_header 600*700637cbSDimitry Andric#endif 601*700637cbSDimitry Andric 602*700637cbSDimitry Andric_LIBCPP_PUSH_MACROS 603*700637cbSDimitry Andric#include <__cxx03/__undef_macros> 604*700637cbSDimitry Andric 605*700637cbSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 606*700637cbSDimitry Andric 607*700637cbSDimitry Andrictemplate <class _Key, 608*700637cbSDimitry Andric class _CP, 609*700637cbSDimitry Andric class _Compare, 610*700637cbSDimitry Andric bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value> 611*700637cbSDimitry Andricclass __map_value_compare : private _Compare { 612*700637cbSDimitry Andricpublic: 613*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_value_compare() : _Compare() {} 614*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_value_compare(_Compare __c) : _Compare(__c) {} 615*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return *this; } 616*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { 617*700637cbSDimitry Andric return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first); 618*700637cbSDimitry Andric } 619*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { 620*700637cbSDimitry Andric return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y); 621*700637cbSDimitry Andric } 622*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { 623*700637cbSDimitry Andric return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first); 624*700637cbSDimitry Andric } 625*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) { 626*700637cbSDimitry Andric using std::swap; 627*700637cbSDimitry Andric swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); 628*700637cbSDimitry Andric } 629*700637cbSDimitry Andric}; 630*700637cbSDimitry Andric 631*700637cbSDimitry Andrictemplate <class _Key, class _CP, class _Compare> 632*700637cbSDimitry Andricclass __map_value_compare<_Key, _CP, _Compare, false> { 633*700637cbSDimitry Andric _Compare __comp_; 634*700637cbSDimitry Andric 635*700637cbSDimitry Andricpublic: 636*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_value_compare() : __comp_() {} 637*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_value_compare(_Compare __c) : __comp_(__c) {} 638*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return __comp_; } 639*700637cbSDimitry Andric 640*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { 641*700637cbSDimitry Andric return __comp_(__x.__get_value().first, __y.__get_value().first); 642*700637cbSDimitry Andric } 643*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { 644*700637cbSDimitry Andric return __comp_(__x.__get_value().first, __y); 645*700637cbSDimitry Andric } 646*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { 647*700637cbSDimitry Andric return __comp_(__x, __y.__get_value().first); 648*700637cbSDimitry Andric } 649*700637cbSDimitry Andric void swap(__map_value_compare& __y) { 650*700637cbSDimitry Andric using std::swap; 651*700637cbSDimitry Andric swap(__comp_, __y.__comp_); 652*700637cbSDimitry Andric } 653*700637cbSDimitry Andric}; 654*700637cbSDimitry Andric 655*700637cbSDimitry Andrictemplate <class _Key, class _CP, class _Compare, bool __b> 656*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void 657*700637cbSDimitry Andricswap(__map_value_compare<_Key, _CP, _Compare, __b>& __x, __map_value_compare<_Key, _CP, _Compare, __b>& __y) { 658*700637cbSDimitry Andric __x.swap(__y); 659*700637cbSDimitry Andric} 660*700637cbSDimitry Andric 661*700637cbSDimitry Andrictemplate <class _Allocator> 662*700637cbSDimitry Andricclass __map_node_destructor { 663*700637cbSDimitry Andric typedef _Allocator allocator_type; 664*700637cbSDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 665*700637cbSDimitry Andric 666*700637cbSDimitry Andricpublic: 667*700637cbSDimitry Andric typedef typename __alloc_traits::pointer pointer; 668*700637cbSDimitry Andric 669*700637cbSDimitry Andricprivate: 670*700637cbSDimitry Andric allocator_type& __na_; 671*700637cbSDimitry Andric 672*700637cbSDimitry Andricpublic: 673*700637cbSDimitry Andric bool __first_constructed; 674*700637cbSDimitry Andric bool __second_constructed; 675*700637cbSDimitry Andric 676*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT 677*700637cbSDimitry Andric : __na_(__na), 678*700637cbSDimitry Andric __first_constructed(false), 679*700637cbSDimitry Andric __second_constructed(false) {} 680*700637cbSDimitry Andric 681*700637cbSDimitry Andric __map_node_destructor& operator=(const __map_node_destructor&) = delete; 682*700637cbSDimitry Andric 683*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { 684*700637cbSDimitry Andric if (__second_constructed) 685*700637cbSDimitry Andric __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().second)); 686*700637cbSDimitry Andric if (__first_constructed) 687*700637cbSDimitry Andric __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().first)); 688*700637cbSDimitry Andric if (__p) 689*700637cbSDimitry Andric __alloc_traits::deallocate(__na_, __p, 1); 690*700637cbSDimitry Andric } 691*700637cbSDimitry Andric}; 692*700637cbSDimitry Andric 693*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 694*700637cbSDimitry Andricclass map; 695*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 696*700637cbSDimitry Andricclass multimap; 697*700637cbSDimitry Andrictemplate <class _TreeIterator> 698*700637cbSDimitry Andricclass __map_const_iterator; 699*700637cbSDimitry Andric 700*700637cbSDimitry Andrictemplate <class _Key, class _Tp> 701*700637cbSDimitry Andricstruct __value_type { 702*700637cbSDimitry Andric typedef _Key key_type; 703*700637cbSDimitry Andric typedef _Tp mapped_type; 704*700637cbSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 705*700637cbSDimitry Andric 706*700637cbSDimitry Andricprivate: 707*700637cbSDimitry Andric value_type __cc_; 708*700637cbSDimitry Andric 709*700637cbSDimitry Andricpublic: 710*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; } 711*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; } 712*700637cbSDimitry Andric 713*700637cbSDimitry Andric __value_type() = delete; 714*700637cbSDimitry Andric __value_type(__value_type const&) = delete; 715*700637cbSDimitry Andric __value_type& operator=(__value_type const&) = delete; 716*700637cbSDimitry Andric ~__value_type() = delete; 717*700637cbSDimitry Andric}; 718*700637cbSDimitry Andric 719*700637cbSDimitry Andrictemplate <class _Tp> 720*700637cbSDimitry Andricstruct __extract_key_value_types; 721*700637cbSDimitry Andric 722*700637cbSDimitry Andrictemplate <class _Key, class _Tp> 723*700637cbSDimitry Andricstruct __extract_key_value_types<__value_type<_Key, _Tp> > { 724*700637cbSDimitry Andric typedef _Key const __key_type; 725*700637cbSDimitry Andric typedef _Tp __mapped_type; 726*700637cbSDimitry Andric}; 727*700637cbSDimitry Andric 728*700637cbSDimitry Andrictemplate <class _TreeIterator> 729*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __map_iterator { 730*700637cbSDimitry Andric typedef typename _TreeIterator::_NodeTypes _NodeTypes; 731*700637cbSDimitry Andric typedef typename _TreeIterator::__pointer_traits __pointer_traits; 732*700637cbSDimitry Andric 733*700637cbSDimitry Andric _TreeIterator __i_; 734*700637cbSDimitry Andric 735*700637cbSDimitry Andricpublic: 736*700637cbSDimitry Andric typedef bidirectional_iterator_tag iterator_category; 737*700637cbSDimitry Andric typedef typename _NodeTypes::__map_value_type value_type; 738*700637cbSDimitry Andric typedef typename _TreeIterator::difference_type difference_type; 739*700637cbSDimitry Andric typedef value_type& reference; 740*700637cbSDimitry Andric typedef typename _NodeTypes::__map_value_type_pointer pointer; 741*700637cbSDimitry Andric 742*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_iterator() _NOEXCEPT {} 743*700637cbSDimitry Andric 744*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} 745*700637cbSDimitry Andric 746*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } 747*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); } 748*700637cbSDimitry Andric 749*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_iterator& operator++() { 750*700637cbSDimitry Andric ++__i_; 751*700637cbSDimitry Andric return *this; 752*700637cbSDimitry Andric } 753*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_iterator operator++(int) { 754*700637cbSDimitry Andric __map_iterator __t(*this); 755*700637cbSDimitry Andric ++(*this); 756*700637cbSDimitry Andric return __t; 757*700637cbSDimitry Andric } 758*700637cbSDimitry Andric 759*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_iterator& operator--() { 760*700637cbSDimitry Andric --__i_; 761*700637cbSDimitry Andric return *this; 762*700637cbSDimitry Andric } 763*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_iterator operator--(int) { 764*700637cbSDimitry Andric __map_iterator __t(*this); 765*700637cbSDimitry Andric --(*this); 766*700637cbSDimitry Andric return __t; 767*700637cbSDimitry Andric } 768*700637cbSDimitry Andric 769*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __map_iterator& __x, const __map_iterator& __y) { 770*700637cbSDimitry Andric return __x.__i_ == __y.__i_; 771*700637cbSDimitry Andric } 772*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __map_iterator& __x, const __map_iterator& __y) { 773*700637cbSDimitry Andric return __x.__i_ != __y.__i_; 774*700637cbSDimitry Andric } 775*700637cbSDimitry Andric 776*700637cbSDimitry Andric template <class, class, class, class> 777*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS map; 778*700637cbSDimitry Andric template <class, class, class, class> 779*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multimap; 780*700637cbSDimitry Andric template <class> 781*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; 782*700637cbSDimitry Andric}; 783*700637cbSDimitry Andric 784*700637cbSDimitry Andrictemplate <class _TreeIterator> 785*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __map_const_iterator { 786*700637cbSDimitry Andric typedef typename _TreeIterator::_NodeTypes _NodeTypes; 787*700637cbSDimitry Andric typedef typename _TreeIterator::__pointer_traits __pointer_traits; 788*700637cbSDimitry Andric 789*700637cbSDimitry Andric _TreeIterator __i_; 790*700637cbSDimitry Andric 791*700637cbSDimitry Andricpublic: 792*700637cbSDimitry Andric typedef bidirectional_iterator_tag iterator_category; 793*700637cbSDimitry Andric typedef typename _NodeTypes::__map_value_type value_type; 794*700637cbSDimitry Andric typedef typename _TreeIterator::difference_type difference_type; 795*700637cbSDimitry Andric typedef const value_type& reference; 796*700637cbSDimitry Andric typedef typename _NodeTypes::__const_map_value_type_pointer pointer; 797*700637cbSDimitry Andric 798*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_const_iterator() _NOEXCEPT {} 799*700637cbSDimitry Andric 800*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} 801*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI 802*700637cbSDimitry Andric __map_const_iterator(__map_iterator< typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT : __i_(__i.__i_) {} 803*700637cbSDimitry Andric 804*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } 805*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); } 806*700637cbSDimitry Andric 807*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator++() { 808*700637cbSDimitry Andric ++__i_; 809*700637cbSDimitry Andric return *this; 810*700637cbSDimitry Andric } 811*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_const_iterator operator++(int) { 812*700637cbSDimitry Andric __map_const_iterator __t(*this); 813*700637cbSDimitry Andric ++(*this); 814*700637cbSDimitry Andric return __t; 815*700637cbSDimitry Andric } 816*700637cbSDimitry Andric 817*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator--() { 818*700637cbSDimitry Andric --__i_; 819*700637cbSDimitry Andric return *this; 820*700637cbSDimitry Andric } 821*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __map_const_iterator operator--(int) { 822*700637cbSDimitry Andric __map_const_iterator __t(*this); 823*700637cbSDimitry Andric --(*this); 824*700637cbSDimitry Andric return __t; 825*700637cbSDimitry Andric } 826*700637cbSDimitry Andric 827*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) { 828*700637cbSDimitry Andric return __x.__i_ == __y.__i_; 829*700637cbSDimitry Andric } 830*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) { 831*700637cbSDimitry Andric return __x.__i_ != __y.__i_; 832*700637cbSDimitry Andric } 833*700637cbSDimitry Andric 834*700637cbSDimitry Andric template <class, class, class, class> 835*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS map; 836*700637cbSDimitry Andric template <class, class, class, class> 837*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multimap; 838*700637cbSDimitry Andric template <class, class, class> 839*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; 840*700637cbSDimitry Andric}; 841*700637cbSDimitry Andric 842*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > 843*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS map { 844*700637cbSDimitry Andricpublic: 845*700637cbSDimitry Andric // types: 846*700637cbSDimitry Andric typedef _Key key_type; 847*700637cbSDimitry Andric typedef _Tp mapped_type; 848*700637cbSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 849*700637cbSDimitry Andric typedef __type_identity_t<_Compare> key_compare; 850*700637cbSDimitry Andric typedef __type_identity_t<_Allocator> allocator_type; 851*700637cbSDimitry Andric typedef value_type& reference; 852*700637cbSDimitry Andric typedef const value_type& const_reference; 853*700637cbSDimitry Andric 854*700637cbSDimitry Andric static_assert(is_same<typename allocator_type::value_type, value_type>::value, 855*700637cbSDimitry Andric "Allocator::value_type must be same type as value_type"); 856*700637cbSDimitry Andric 857*700637cbSDimitry Andric class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> { 858*700637cbSDimitry Andric friend class map; 859*700637cbSDimitry Andric 860*700637cbSDimitry Andric protected: 861*700637cbSDimitry Andric key_compare comp; 862*700637cbSDimitry Andric 863*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : comp(__c) {} 864*700637cbSDimitry Andric 865*700637cbSDimitry Andric public: 866*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const value_type& __x, const value_type& __y) const { 867*700637cbSDimitry Andric return comp(__x.first, __y.first); 868*700637cbSDimitry Andric } 869*700637cbSDimitry Andric }; 870*700637cbSDimitry Andric 871*700637cbSDimitry Andricprivate: 872*700637cbSDimitry Andric typedef std::__value_type<key_type, mapped_type> __value_type; 873*700637cbSDimitry Andric typedef __map_value_compare<key_type, __value_type, key_compare> __vc; 874*700637cbSDimitry Andric typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type; 875*700637cbSDimitry Andric typedef __tree<__value_type, __vc, __allocator_type> __base; 876*700637cbSDimitry Andric typedef typename __base::__node_traits __node_traits; 877*700637cbSDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 878*700637cbSDimitry Andric 879*700637cbSDimitry Andric static_assert(__check_valid_allocator<allocator_type>::value, ""); 880*700637cbSDimitry Andric 881*700637cbSDimitry Andric __base __tree_; 882*700637cbSDimitry Andric 883*700637cbSDimitry Andricpublic: 884*700637cbSDimitry Andric typedef typename __alloc_traits::pointer pointer; 885*700637cbSDimitry Andric typedef typename __alloc_traits::const_pointer const_pointer; 886*700637cbSDimitry Andric typedef typename __alloc_traits::size_type size_type; 887*700637cbSDimitry Andric typedef typename __alloc_traits::difference_type difference_type; 888*700637cbSDimitry Andric typedef __map_iterator<typename __base::iterator> iterator; 889*700637cbSDimitry Andric typedef __map_const_iterator<typename __base::const_iterator> const_iterator; 890*700637cbSDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 891*700637cbSDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 892*700637cbSDimitry Andric 893*700637cbSDimitry Andric template <class _Key2, class _Value2, class _Comp2, class _Alloc2> 894*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS map; 895*700637cbSDimitry Andric template <class _Key2, class _Value2, class _Comp2, class _Alloc2> 896*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multimap; 897*700637cbSDimitry Andric 898*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI map() : __tree_(__vc(key_compare())) {} 899*700637cbSDimitry Andric 900*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit map(const key_compare& __comp) : __tree_(__vc(__comp)) {} 901*700637cbSDimitry Andric 902*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit map(const key_compare& __comp, const allocator_type& __a) 903*700637cbSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {} 904*700637cbSDimitry Andric 905*700637cbSDimitry Andric template <class _InputIterator> 906*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare()) 907*700637cbSDimitry Andric : __tree_(__vc(__comp)) { 908*700637cbSDimitry Andric insert(__f, __l); 909*700637cbSDimitry Andric } 910*700637cbSDimitry Andric 911*700637cbSDimitry Andric template <class _InputIterator> 912*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI 913*700637cbSDimitry Andric map(_InputIterator __f, _InputIterator __l, const key_compare& __comp, const allocator_type& __a) 914*700637cbSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) { 915*700637cbSDimitry Andric insert(__f, __l); 916*700637cbSDimitry Andric } 917*700637cbSDimitry Andric 918*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); } 919*700637cbSDimitry Andric 920*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) { 921*700637cbSDimitry Andric if (this != std::addressof(__m)) { 922*700637cbSDimitry Andric __tree_.clear(); 923*700637cbSDimitry Andric __tree_.value_comp() = __m.__tree_.value_comp(); 924*700637cbSDimitry Andric __tree_.__copy_assign_alloc(__m.__tree_); 925*700637cbSDimitry Andric insert(__m.begin(), __m.end()); 926*700637cbSDimitry Andric } 927*700637cbSDimitry Andric return *this; 928*700637cbSDimitry Andric } 929*700637cbSDimitry Andric 930*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} 931*700637cbSDimitry Andric 932*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI map(const map& __m, const allocator_type& __a) 933*700637cbSDimitry Andric : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) { 934*700637cbSDimitry Andric insert(__m.begin(), __m.end()); 935*700637cbSDimitry Andric } 936*700637cbSDimitry Andric 937*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } 938*700637cbSDimitry Andric 939*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } 940*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } 941*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } 942*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } 943*700637cbSDimitry Andric 944*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } 945*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } 946*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } 947*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } 948*700637cbSDimitry Andric 949*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } 950*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } 951*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } 952*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } 953*700637cbSDimitry Andric 954*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } 955*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } 956*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } 957*700637cbSDimitry Andric 958*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k); 959*700637cbSDimitry Andric 960*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); 961*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; 962*700637cbSDimitry Andric 963*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(__tree_.__alloc()); } 964*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } 965*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); } 966*700637cbSDimitry Andric 967*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); } 968*700637cbSDimitry Andric 969*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { 970*700637cbSDimitry Andric return __tree_.__insert_unique(__p.__i_, __v); 971*700637cbSDimitry Andric } 972*700637cbSDimitry Andric 973*700637cbSDimitry Andric template <class _InputIterator> 974*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { 975*700637cbSDimitry Andric for (const_iterator __e = cend(); __f != __l; ++__f) 976*700637cbSDimitry Andric insert(__e.__i_, *__f); 977*700637cbSDimitry Andric } 978*700637cbSDimitry Andric 979*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); } 980*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } 981*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); } 982*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { 983*700637cbSDimitry Andric return __tree_.erase(__f.__i_, __l.__i_); 984*700637cbSDimitry Andric } 985*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } 986*700637cbSDimitry Andric 987*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(map& __m) { __tree_.swap(__m.__tree_); } 988*700637cbSDimitry Andric 989*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } 990*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } 991*700637cbSDimitry Andric 992*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } 993*700637cbSDimitry Andric 994*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } 995*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } 996*700637cbSDimitry Andric 997*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } 998*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } 999*700637cbSDimitry Andric 1000*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { 1001*700637cbSDimitry Andric return __tree_.__equal_range_unique(__k); 1002*700637cbSDimitry Andric } 1003*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { 1004*700637cbSDimitry Andric return __tree_.__equal_range_unique(__k); 1005*700637cbSDimitry Andric } 1006*700637cbSDimitry Andric 1007*700637cbSDimitry Andricprivate: 1008*700637cbSDimitry Andric typedef typename __base::__node __node; 1009*700637cbSDimitry Andric typedef typename __base::__node_allocator __node_allocator; 1010*700637cbSDimitry Andric typedef typename __base::__node_pointer __node_pointer; 1011*700637cbSDimitry Andric typedef typename __base::__node_base_pointer __node_base_pointer; 1012*700637cbSDimitry Andric typedef typename __base::__parent_pointer __parent_pointer; 1013*700637cbSDimitry Andric 1014*700637cbSDimitry Andric typedef __map_node_destructor<__node_allocator> _Dp; 1015*700637cbSDimitry Andric typedef unique_ptr<__node, _Dp> __node_holder; 1016*700637cbSDimitry Andric 1017*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k); 1018*700637cbSDimitry Andric}; 1019*700637cbSDimitry Andric 1020*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1021*700637cbSDimitry Andrictypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder 1022*700637cbSDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) { 1023*700637cbSDimitry Andric __node_allocator& __na = __tree_.__node_alloc(); 1024*700637cbSDimitry Andric __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 1025*700637cbSDimitry Andric __node_traits::construct(__na, std::addressof(__h->__value_.__get_value().first), __k); 1026*700637cbSDimitry Andric __h.get_deleter().__first_constructed = true; 1027*700637cbSDimitry Andric __node_traits::construct(__na, std::addressof(__h->__value_.__get_value().second)); 1028*700637cbSDimitry Andric __h.get_deleter().__second_constructed = true; 1029*700637cbSDimitry Andric return __h; 1030*700637cbSDimitry Andric} 1031*700637cbSDimitry Andric 1032*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1033*700637cbSDimitry Andric_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { 1034*700637cbSDimitry Andric __parent_pointer __parent; 1035*700637cbSDimitry Andric __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); 1036*700637cbSDimitry Andric __node_pointer __r = static_cast<__node_pointer>(__child); 1037*700637cbSDimitry Andric if (__child == nullptr) { 1038*700637cbSDimitry Andric __node_holder __h = __construct_node_with_key(__k); 1039*700637cbSDimitry Andric __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); 1040*700637cbSDimitry Andric __r = __h.release(); 1041*700637cbSDimitry Andric } 1042*700637cbSDimitry Andric return __r->__value_.__get_value().second; 1043*700637cbSDimitry Andric} 1044*700637cbSDimitry Andric 1045*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1046*700637cbSDimitry Andric_Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { 1047*700637cbSDimitry Andric __parent_pointer __parent; 1048*700637cbSDimitry Andric __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); 1049*700637cbSDimitry Andric if (__child == nullptr) 1050*700637cbSDimitry Andric __throw_out_of_range("map::at: key not found"); 1051*700637cbSDimitry Andric return static_cast<__node_pointer>(__child)->__value_.__get_value().second; 1052*700637cbSDimitry Andric} 1053*700637cbSDimitry Andric 1054*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1055*700637cbSDimitry Andricconst _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const { 1056*700637cbSDimitry Andric __parent_pointer __parent; 1057*700637cbSDimitry Andric __node_base_pointer __child = __tree_.__find_equal(__parent, __k); 1058*700637cbSDimitry Andric if (__child == nullptr) 1059*700637cbSDimitry Andric __throw_out_of_range("map::at: key not found"); 1060*700637cbSDimitry Andric return static_cast<__node_pointer>(__child)->__value_.__get_value().second; 1061*700637cbSDimitry Andric} 1062*700637cbSDimitry Andric 1063*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1064*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1065*700637cbSDimitry Andricoperator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) { 1066*700637cbSDimitry Andric return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); 1067*700637cbSDimitry Andric} 1068*700637cbSDimitry Andric 1069*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1070*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1071*700637cbSDimitry Andricoperator<(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) { 1072*700637cbSDimitry Andric return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 1073*700637cbSDimitry Andric} 1074*700637cbSDimitry Andric 1075*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1076*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1077*700637cbSDimitry Andricoperator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) { 1078*700637cbSDimitry Andric return !(__x == __y); 1079*700637cbSDimitry Andric} 1080*700637cbSDimitry Andric 1081*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1082*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1083*700637cbSDimitry Andricoperator>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) { 1084*700637cbSDimitry Andric return __y < __x; 1085*700637cbSDimitry Andric} 1086*700637cbSDimitry Andric 1087*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1088*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1089*700637cbSDimitry Andricoperator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) { 1090*700637cbSDimitry Andric return !(__x < __y); 1091*700637cbSDimitry Andric} 1092*700637cbSDimitry Andric 1093*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1094*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1095*700637cbSDimitry Andricoperator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) { 1096*700637cbSDimitry Andric return !(__y < __x); 1097*700637cbSDimitry Andric} 1098*700637cbSDimitry Andric 1099*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1100*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void 1101*700637cbSDimitry Andricswap(map<_Key, _Tp, _Compare, _Allocator>& __x, map<_Key, _Tp, _Compare, _Allocator>& __y) { 1102*700637cbSDimitry Andric __x.swap(__y); 1103*700637cbSDimitry Andric} 1104*700637cbSDimitry Andric 1105*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > 1106*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS multimap { 1107*700637cbSDimitry Andricpublic: 1108*700637cbSDimitry Andric // types: 1109*700637cbSDimitry Andric typedef _Key key_type; 1110*700637cbSDimitry Andric typedef _Tp mapped_type; 1111*700637cbSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 1112*700637cbSDimitry Andric typedef __type_identity_t<_Compare> key_compare; 1113*700637cbSDimitry Andric typedef __type_identity_t<_Allocator> allocator_type; 1114*700637cbSDimitry Andric typedef value_type& reference; 1115*700637cbSDimitry Andric typedef const value_type& const_reference; 1116*700637cbSDimitry Andric 1117*700637cbSDimitry Andric static_assert(__check_valid_allocator<allocator_type>::value, ""); 1118*700637cbSDimitry Andric static_assert(is_same<typename allocator_type::value_type, value_type>::value, 1119*700637cbSDimitry Andric "Allocator::value_type must be same type as value_type"); 1120*700637cbSDimitry Andric 1121*700637cbSDimitry Andric class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> { 1122*700637cbSDimitry Andric friend class multimap; 1123*700637cbSDimitry Andric 1124*700637cbSDimitry Andric protected: 1125*700637cbSDimitry Andric key_compare comp; 1126*700637cbSDimitry Andric 1127*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : comp(__c) {} 1128*700637cbSDimitry Andric 1129*700637cbSDimitry Andric public: 1130*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const value_type& __x, const value_type& __y) const { 1131*700637cbSDimitry Andric return comp(__x.first, __y.first); 1132*700637cbSDimitry Andric } 1133*700637cbSDimitry Andric }; 1134*700637cbSDimitry Andric 1135*700637cbSDimitry Andricprivate: 1136*700637cbSDimitry Andric typedef std::__value_type<key_type, mapped_type> __value_type; 1137*700637cbSDimitry Andric typedef __map_value_compare<key_type, __value_type, key_compare> __vc; 1138*700637cbSDimitry Andric typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type; 1139*700637cbSDimitry Andric typedef __tree<__value_type, __vc, __allocator_type> __base; 1140*700637cbSDimitry Andric typedef typename __base::__node_traits __node_traits; 1141*700637cbSDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 1142*700637cbSDimitry Andric 1143*700637cbSDimitry Andric __base __tree_; 1144*700637cbSDimitry Andric 1145*700637cbSDimitry Andricpublic: 1146*700637cbSDimitry Andric typedef typename __alloc_traits::pointer pointer; 1147*700637cbSDimitry Andric typedef typename __alloc_traits::const_pointer const_pointer; 1148*700637cbSDimitry Andric typedef typename __alloc_traits::size_type size_type; 1149*700637cbSDimitry Andric typedef typename __alloc_traits::difference_type difference_type; 1150*700637cbSDimitry Andric typedef __map_iterator<typename __base::iterator> iterator; 1151*700637cbSDimitry Andric typedef __map_const_iterator<typename __base::const_iterator> const_iterator; 1152*700637cbSDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 1153*700637cbSDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 1154*700637cbSDimitry Andric 1155*700637cbSDimitry Andric template <class _Key2, class _Value2, class _Comp2, class _Alloc2> 1156*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS map; 1157*700637cbSDimitry Andric template <class _Key2, class _Value2, class _Comp2, class _Alloc2> 1158*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multimap; 1159*700637cbSDimitry Andric 1160*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI multimap() : __tree_(__vc(key_compare())) {} 1161*700637cbSDimitry Andric 1162*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit multimap(const key_compare& __comp) : __tree_(__vc(__comp)) {} 1163*700637cbSDimitry Andric 1164*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit multimap(const key_compare& __comp, const allocator_type& __a) 1165*700637cbSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {} 1166*700637cbSDimitry Andric 1167*700637cbSDimitry Andric template <class _InputIterator> 1168*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI multimap(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare()) 1169*700637cbSDimitry Andric : __tree_(__vc(__comp)) { 1170*700637cbSDimitry Andric insert(__f, __l); 1171*700637cbSDimitry Andric } 1172*700637cbSDimitry Andric 1173*700637cbSDimitry Andric template <class _InputIterator> 1174*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1175*700637cbSDimitry Andric multimap(_InputIterator __f, _InputIterator __l, const key_compare& __comp, const allocator_type& __a) 1176*700637cbSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) { 1177*700637cbSDimitry Andric insert(__f, __l); 1178*700637cbSDimitry Andric } 1179*700637cbSDimitry Andric 1180*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m) 1181*700637cbSDimitry Andric : __tree_(__m.__tree_.value_comp(), 1182*700637cbSDimitry Andric __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc())) { 1183*700637cbSDimitry Andric insert(__m.begin(), __m.end()); 1184*700637cbSDimitry Andric } 1185*700637cbSDimitry Andric 1186*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) { 1187*700637cbSDimitry Andric if (this != std::addressof(__m)) { 1188*700637cbSDimitry Andric __tree_.clear(); 1189*700637cbSDimitry Andric __tree_.value_comp() = __m.__tree_.value_comp(); 1190*700637cbSDimitry Andric __tree_.__copy_assign_alloc(__m.__tree_); 1191*700637cbSDimitry Andric insert(__m.begin(), __m.end()); 1192*700637cbSDimitry Andric } 1193*700637cbSDimitry Andric return *this; 1194*700637cbSDimitry Andric } 1195*700637cbSDimitry Andric 1196*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit multimap(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} 1197*700637cbSDimitry Andric 1198*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m, const allocator_type& __a) 1199*700637cbSDimitry Andric : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) { 1200*700637cbSDimitry Andric insert(__m.begin(), __m.end()); 1201*700637cbSDimitry Andric } 1202*700637cbSDimitry Andric 1203*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI ~multimap() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } 1204*700637cbSDimitry Andric 1205*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } 1206*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } 1207*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } 1208*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } 1209*700637cbSDimitry Andric 1210*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } 1211*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } 1212*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } 1213*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } 1214*700637cbSDimitry Andric 1215*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } 1216*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } 1217*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } 1218*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } 1219*700637cbSDimitry Andric 1220*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } 1221*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } 1222*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } 1223*700637cbSDimitry Andric 1224*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(__tree_.__alloc()); } 1225*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } 1226*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); } 1227*700637cbSDimitry Andric 1228*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); } 1229*700637cbSDimitry Andric 1230*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { 1231*700637cbSDimitry Andric return __tree_.__insert_multi(__p.__i_, __v); 1232*700637cbSDimitry Andric } 1233*700637cbSDimitry Andric 1234*700637cbSDimitry Andric template <class _InputIterator> 1235*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { 1236*700637cbSDimitry Andric for (const_iterator __e = cend(); __f != __l; ++__f) 1237*700637cbSDimitry Andric __tree_.__insert_multi(__e.__i_, *__f); 1238*700637cbSDimitry Andric } 1239*700637cbSDimitry Andric 1240*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); } 1241*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } 1242*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); } 1243*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { 1244*700637cbSDimitry Andric return __tree_.erase(__f.__i_, __l.__i_); 1245*700637cbSDimitry Andric } 1246*700637cbSDimitry Andric 1247*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } 1248*700637cbSDimitry Andric 1249*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(multimap& __m) { __tree_.swap(__m.__tree_); } 1250*700637cbSDimitry Andric 1251*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } 1252*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } 1253*700637cbSDimitry Andric 1254*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } 1255*700637cbSDimitry Andric 1256*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } 1257*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } 1258*700637cbSDimitry Andric 1259*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } 1260*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } 1261*700637cbSDimitry Andric 1262*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { 1263*700637cbSDimitry Andric return __tree_.__equal_range_multi(__k); 1264*700637cbSDimitry Andric } 1265*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { 1266*700637cbSDimitry Andric return __tree_.__equal_range_multi(__k); 1267*700637cbSDimitry Andric } 1268*700637cbSDimitry Andric 1269*700637cbSDimitry Andricprivate: 1270*700637cbSDimitry Andric typedef typename __base::__node __node; 1271*700637cbSDimitry Andric typedef typename __base::__node_allocator __node_allocator; 1272*700637cbSDimitry Andric typedef typename __base::__node_pointer __node_pointer; 1273*700637cbSDimitry Andric 1274*700637cbSDimitry Andric typedef __map_node_destructor<__node_allocator> _Dp; 1275*700637cbSDimitry Andric typedef unique_ptr<__node, _Dp> __node_holder; 1276*700637cbSDimitry Andric}; 1277*700637cbSDimitry Andric 1278*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1279*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1280*700637cbSDimitry Andricoperator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) { 1281*700637cbSDimitry Andric return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); 1282*700637cbSDimitry Andric} 1283*700637cbSDimitry Andric 1284*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1285*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1286*700637cbSDimitry Andricoperator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) { 1287*700637cbSDimitry Andric return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 1288*700637cbSDimitry Andric} 1289*700637cbSDimitry Andric 1290*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1291*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1292*700637cbSDimitry Andricoperator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) { 1293*700637cbSDimitry Andric return !(__x == __y); 1294*700637cbSDimitry Andric} 1295*700637cbSDimitry Andric 1296*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1297*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1298*700637cbSDimitry Andricoperator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) { 1299*700637cbSDimitry Andric return __y < __x; 1300*700637cbSDimitry Andric} 1301*700637cbSDimitry Andric 1302*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1303*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1304*700637cbSDimitry Andricoperator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) { 1305*700637cbSDimitry Andric return !(__x < __y); 1306*700637cbSDimitry Andric} 1307*700637cbSDimitry Andric 1308*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1309*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool 1310*700637cbSDimitry Andricoperator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) { 1311*700637cbSDimitry Andric return !(__y < __x); 1312*700637cbSDimitry Andric} 1313*700637cbSDimitry Andric 1314*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1315*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void 1316*700637cbSDimitry Andricswap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, multimap<_Key, _Tp, _Compare, _Allocator>& __y) { 1317*700637cbSDimitry Andric __x.swap(__y); 1318*700637cbSDimitry Andric} 1319*700637cbSDimitry Andric 1320*700637cbSDimitry Andric_LIBCPP_END_NAMESPACE_STD 1321*700637cbSDimitry Andric 1322*700637cbSDimitry Andric_LIBCPP_POP_MACROS 1323*700637cbSDimitry Andric 1324*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 1325*700637cbSDimitry Andric# include <__cxx03/cstdlib> 1326*700637cbSDimitry Andric# include <__cxx03/functional> 1327*700637cbSDimitry Andric# include <__cxx03/iterator> 1328*700637cbSDimitry Andric# include <__cxx03/type_traits> 1329*700637cbSDimitry Andric# include <__cxx03/utility> 1330*700637cbSDimitry Andric#endif 1331*700637cbSDimitry Andric 1332*700637cbSDimitry Andric#endif // _LIBCPP___CXX03_MAP 1333