17a984708SDavid Chisnall// -*- C++ -*- 27a984708SDavid Chisnall//===----------------------------- map ------------------------------------===// 37a984708SDavid Chisnall// 47a984708SDavid Chisnall// The LLVM Compiler Infrastructure 57a984708SDavid Chisnall// 67a984708SDavid Chisnall// This file is dual licensed under the MIT and the University of Illinois Open 77a984708SDavid Chisnall// Source Licenses. See LICENSE.TXT for details. 87a984708SDavid Chisnall// 97a984708SDavid Chisnall//===----------------------------------------------------------------------===// 107a984708SDavid Chisnall 117a984708SDavid Chisnall#ifndef _LIBCPP_MAP 127a984708SDavid Chisnall#define _LIBCPP_MAP 137a984708SDavid Chisnall 147a984708SDavid Chisnall/* 157a984708SDavid Chisnall 167a984708SDavid Chisnall map synopsis 177a984708SDavid Chisnall 187a984708SDavid Chisnallnamespace std 197a984708SDavid Chisnall{ 207a984708SDavid Chisnall 217a984708SDavid Chisnalltemplate <class Key, class T, class Compare = less<Key>, 227a984708SDavid Chisnall class Allocator = allocator<pair<const Key, T>>> 237a984708SDavid Chisnallclass map 247a984708SDavid Chisnall{ 257a984708SDavid Chisnallpublic: 267a984708SDavid Chisnall // types: 277a984708SDavid Chisnall typedef Key key_type; 287a984708SDavid Chisnall typedef T mapped_type; 297a984708SDavid Chisnall typedef pair<const key_type, mapped_type> value_type; 307a984708SDavid Chisnall typedef Compare key_compare; 317a984708SDavid Chisnall typedef Allocator allocator_type; 327a984708SDavid Chisnall typedef typename allocator_type::reference reference; 337a984708SDavid Chisnall typedef typename allocator_type::const_reference const_reference; 347a984708SDavid Chisnall typedef typename allocator_type::pointer pointer; 357a984708SDavid Chisnall typedef typename allocator_type::const_pointer const_pointer; 367a984708SDavid Chisnall typedef typename allocator_type::size_type size_type; 377a984708SDavid Chisnall typedef typename allocator_type::difference_type difference_type; 387a984708SDavid Chisnall 397a984708SDavid Chisnall typedef implementation-defined iterator; 407a984708SDavid Chisnall typedef implementation-defined const_iterator; 417a984708SDavid Chisnall typedef std::reverse_iterator<iterator> reverse_iterator; 427a984708SDavid Chisnall typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 434ba319b5SDimitry Andric typedef unspecified node_type; // C++17 444ba319b5SDimitry Andric typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 457a984708SDavid Chisnall 467a984708SDavid Chisnall class value_compare 477a984708SDavid Chisnall : public binary_function<value_type, value_type, bool> 487a984708SDavid Chisnall { 497a984708SDavid Chisnall friend class map; 507a984708SDavid Chisnall protected: 517a984708SDavid Chisnall key_compare comp; 527a984708SDavid Chisnall 537a984708SDavid Chisnall value_compare(key_compare c); 547a984708SDavid Chisnall public: 557a984708SDavid Chisnall bool operator()(const value_type& x, const value_type& y) const; 567a984708SDavid Chisnall }; 577a984708SDavid Chisnall 587a984708SDavid Chisnall // construct/copy/destroy: 597a984708SDavid Chisnall map() 607a984708SDavid Chisnall noexcept( 617a984708SDavid Chisnall is_nothrow_default_constructible<allocator_type>::value && 627a984708SDavid Chisnall is_nothrow_default_constructible<key_compare>::value && 637a984708SDavid Chisnall is_nothrow_copy_constructible<key_compare>::value); 647a984708SDavid Chisnall explicit map(const key_compare& comp); 657a984708SDavid Chisnall map(const key_compare& comp, const allocator_type& a); 667a984708SDavid Chisnall template <class InputIterator> 677a984708SDavid Chisnall map(InputIterator first, InputIterator last, 687a984708SDavid Chisnall const key_compare& comp = key_compare()); 697a984708SDavid Chisnall template <class InputIterator> 707a984708SDavid Chisnall map(InputIterator first, InputIterator last, 717a984708SDavid Chisnall const key_compare& comp, const allocator_type& a); 727a984708SDavid Chisnall map(const map& m); 737a984708SDavid Chisnall map(map&& m) 747a984708SDavid Chisnall noexcept( 757a984708SDavid Chisnall is_nothrow_move_constructible<allocator_type>::value && 767a984708SDavid Chisnall is_nothrow_move_constructible<key_compare>::value); 777a984708SDavid Chisnall explicit map(const allocator_type& a); 787a984708SDavid Chisnall map(const map& m, const allocator_type& a); 797a984708SDavid Chisnall map(map&& m, const allocator_type& a); 807a984708SDavid Chisnall map(initializer_list<value_type> il, const key_compare& comp = key_compare()); 817a984708SDavid Chisnall map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); 824f7ab58eSDimitry Andric template <class InputIterator> 834f7ab58eSDimitry Andric map(InputIterator first, InputIterator last, const allocator_type& a) 844f7ab58eSDimitry Andric : map(first, last, Compare(), a) {} // C++14 854f7ab58eSDimitry Andric map(initializer_list<value_type> il, const allocator_type& a) 864f7ab58eSDimitry Andric : map(il, Compare(), a) {} // C++14 877a984708SDavid Chisnall ~map(); 887a984708SDavid Chisnall 897a984708SDavid Chisnall map& operator=(const map& m); 907a984708SDavid Chisnall map& operator=(map&& m) 917a984708SDavid Chisnall noexcept( 927a984708SDavid Chisnall allocator_type::propagate_on_container_move_assignment::value && 937a984708SDavid Chisnall is_nothrow_move_assignable<allocator_type>::value && 947a984708SDavid Chisnall is_nothrow_move_assignable<key_compare>::value); 957a984708SDavid Chisnall map& operator=(initializer_list<value_type> il); 967a984708SDavid Chisnall 977a984708SDavid Chisnall // iterators: 987a984708SDavid Chisnall iterator begin() noexcept; 997a984708SDavid Chisnall const_iterator begin() const noexcept; 1007a984708SDavid Chisnall iterator end() noexcept; 1017a984708SDavid Chisnall const_iterator end() const noexcept; 1027a984708SDavid Chisnall 1037a984708SDavid Chisnall reverse_iterator rbegin() noexcept; 1047a984708SDavid Chisnall const_reverse_iterator rbegin() const noexcept; 1057a984708SDavid Chisnall reverse_iterator rend() noexcept; 1067a984708SDavid Chisnall const_reverse_iterator rend() const noexcept; 1077a984708SDavid Chisnall 1087a984708SDavid Chisnall const_iterator cbegin() const noexcept; 1097a984708SDavid Chisnall const_iterator cend() const noexcept; 1107a984708SDavid Chisnall const_reverse_iterator crbegin() const noexcept; 1117a984708SDavid Chisnall const_reverse_iterator crend() const noexcept; 1127a984708SDavid Chisnall 1137a984708SDavid Chisnall // capacity: 1147a984708SDavid Chisnall bool empty() const noexcept; 1157a984708SDavid Chisnall size_type size() const noexcept; 1167a984708SDavid Chisnall size_type max_size() const noexcept; 1177a984708SDavid Chisnall 1187a984708SDavid Chisnall // element access: 1197a984708SDavid Chisnall mapped_type& operator[](const key_type& k); 1207a984708SDavid Chisnall mapped_type& operator[](key_type&& k); 1217a984708SDavid Chisnall 1227a984708SDavid Chisnall mapped_type& at(const key_type& k); 1237a984708SDavid Chisnall const mapped_type& at(const key_type& k) const; 1247a984708SDavid Chisnall 1257a984708SDavid Chisnall // modifiers: 1267a984708SDavid Chisnall template <class... Args> 1277a984708SDavid Chisnall pair<iterator, bool> emplace(Args&&... args); 1287a984708SDavid Chisnall template <class... Args> 1297a984708SDavid Chisnall iterator emplace_hint(const_iterator position, Args&&... args); 1307a984708SDavid Chisnall pair<iterator, bool> insert(const value_type& v); 1319729cf09SDimitry Andric pair<iterator, bool> insert( value_type&& v); // C++17 1327a984708SDavid Chisnall template <class P> 1337a984708SDavid Chisnall pair<iterator, bool> insert(P&& p); 1347a984708SDavid Chisnall iterator insert(const_iterator position, const value_type& v); 1359729cf09SDimitry Andric iterator insert(const_iterator position, value_type&& v); // C++17 1367a984708SDavid Chisnall template <class P> 1377a984708SDavid Chisnall iterator insert(const_iterator position, P&& p); 1387a984708SDavid Chisnall template <class InputIterator> 1397a984708SDavid Chisnall void insert(InputIterator first, InputIterator last); 1407a984708SDavid Chisnall void insert(initializer_list<value_type> il); 1417a984708SDavid Chisnall 1424ba319b5SDimitry Andric node_type extract(const_iterator position); // C++17 1434ba319b5SDimitry Andric node_type extract(const key_type& x); // C++17 1444ba319b5SDimitry Andric insert_return_type insert(node_type&& nh); // C++17 1454ba319b5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 1464ba319b5SDimitry Andric 147854fa44bSDimitry Andric template <class... Args> 148854fa44bSDimitry Andric pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17 149854fa44bSDimitry Andric template <class... Args> 150854fa44bSDimitry Andric pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17 151854fa44bSDimitry Andric template <class... Args> 152854fa44bSDimitry Andric iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 153854fa44bSDimitry Andric template <class... Args> 154854fa44bSDimitry Andric iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 155854fa44bSDimitry Andric template <class M> 156854fa44bSDimitry Andric pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17 157854fa44bSDimitry Andric template <class M> 158854fa44bSDimitry Andric pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17 159854fa44bSDimitry Andric template <class M> 160854fa44bSDimitry Andric iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 161854fa44bSDimitry Andric template <class M> 162854fa44bSDimitry Andric iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 163854fa44bSDimitry Andric 1647a984708SDavid Chisnall iterator erase(const_iterator position); 165854fa44bSDimitry Andric iterator erase(iterator position); // C++14 1667a984708SDavid Chisnall size_type erase(const key_type& k); 1677a984708SDavid Chisnall iterator erase(const_iterator first, const_iterator last); 1687a984708SDavid Chisnall void clear() noexcept; 1697a984708SDavid Chisnall 170*b5893f02SDimitry Andric template<class C2> 171*b5893f02SDimitry Andric void merge(map<Key, T, C2, Allocator>& source); // C++17 172*b5893f02SDimitry Andric template<class C2> 173*b5893f02SDimitry Andric void merge(map<Key, T, C2, Allocator>&& source); // C++17 174*b5893f02SDimitry Andric template<class C2> 175*b5893f02SDimitry Andric void merge(multimap<Key, T, C2, Allocator>& source); // C++17 176*b5893f02SDimitry Andric template<class C2> 177*b5893f02SDimitry Andric void merge(multimap<Key, T, C2, Allocator>&& source); // C++17 178*b5893f02SDimitry Andric 1797a984708SDavid Chisnall void swap(map& m) 180854fa44bSDimitry Andric noexcept(allocator_traits<allocator_type>::is_always_equal::value && 1817c82a1ecSDimitry Andric is_nothrow_swappable<key_compare>::value); // C++17 1827a984708SDavid Chisnall 1837a984708SDavid Chisnall // observers: 1847a984708SDavid Chisnall allocator_type get_allocator() const noexcept; 1857a984708SDavid Chisnall key_compare key_comp() const; 1867a984708SDavid Chisnall value_compare value_comp() const; 1877a984708SDavid Chisnall 1887a984708SDavid Chisnall // map operations: 1897a984708SDavid Chisnall iterator find(const key_type& k); 1907a984708SDavid Chisnall const_iterator find(const key_type& k) const; 1914f7ab58eSDimitry Andric template<typename K> 1924f7ab58eSDimitry Andric iterator find(const K& x); // C++14 1934f7ab58eSDimitry Andric template<typename K> 1944f7ab58eSDimitry Andric const_iterator find(const K& x) const; // C++14 1954f7ab58eSDimitry Andric template<typename K> 196d72607e9SDimitry Andric size_type count(const K& x) const; // C++14 1974f7ab58eSDimitry Andric 1987a984708SDavid Chisnall size_type count(const key_type& k) const; 1997a984708SDavid Chisnall iterator lower_bound(const key_type& k); 2007a984708SDavid Chisnall const_iterator lower_bound(const key_type& k) const; 2014f7ab58eSDimitry Andric template<typename K> 2024f7ab58eSDimitry Andric iterator lower_bound(const K& x); // C++14 2034f7ab58eSDimitry Andric template<typename K> 2044f7ab58eSDimitry Andric const_iterator lower_bound(const K& x) const; // C++14 2054f7ab58eSDimitry Andric 2067a984708SDavid Chisnall iterator upper_bound(const key_type& k); 2077a984708SDavid Chisnall const_iterator upper_bound(const key_type& k) const; 2084f7ab58eSDimitry Andric template<typename K> 2094f7ab58eSDimitry Andric iterator upper_bound(const K& x); // C++14 2104f7ab58eSDimitry Andric template<typename K> 2114f7ab58eSDimitry Andric const_iterator upper_bound(const K& x) const; // C++14 2124f7ab58eSDimitry Andric 2137a984708SDavid Chisnall pair<iterator,iterator> equal_range(const key_type& k); 2147a984708SDavid Chisnall pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 2154f7ab58eSDimitry Andric template<typename K> 2164f7ab58eSDimitry Andric pair<iterator,iterator> equal_range(const K& x); // C++14 2174f7ab58eSDimitry Andric template<typename K> 2184f7ab58eSDimitry Andric pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 2197a984708SDavid Chisnall}; 2207a984708SDavid Chisnall 2217a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 2227a984708SDavid Chisnallbool 2237a984708SDavid Chisnalloperator==(const map<Key, T, Compare, Allocator>& x, 2247a984708SDavid Chisnall const map<Key, T, Compare, Allocator>& y); 2257a984708SDavid Chisnall 2267a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 2277a984708SDavid Chisnallbool 2287a984708SDavid Chisnalloperator< (const map<Key, T, Compare, Allocator>& x, 2297a984708SDavid Chisnall const map<Key, T, Compare, Allocator>& y); 2307a984708SDavid Chisnall 2317a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 2327a984708SDavid Chisnallbool 2337a984708SDavid Chisnalloperator!=(const map<Key, T, Compare, Allocator>& x, 2347a984708SDavid Chisnall const map<Key, T, Compare, Allocator>& y); 2357a984708SDavid Chisnall 2367a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 2377a984708SDavid Chisnallbool 2387a984708SDavid Chisnalloperator> (const map<Key, T, Compare, Allocator>& x, 2397a984708SDavid Chisnall const map<Key, T, Compare, Allocator>& y); 2407a984708SDavid Chisnall 2417a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 2427a984708SDavid Chisnallbool 2437a984708SDavid Chisnalloperator>=(const map<Key, T, Compare, Allocator>& x, 2447a984708SDavid Chisnall const map<Key, T, Compare, Allocator>& y); 2457a984708SDavid Chisnall 2467a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 2477a984708SDavid Chisnallbool 2487a984708SDavid Chisnalloperator<=(const map<Key, T, Compare, Allocator>& x, 2497a984708SDavid Chisnall const map<Key, T, Compare, Allocator>& y); 2507a984708SDavid Chisnall 2517a984708SDavid Chisnall// specialized algorithms: 2527a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 2537a984708SDavid Chisnallvoid 2547a984708SDavid Chisnallswap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y) 2557a984708SDavid Chisnall noexcept(noexcept(x.swap(y))); 2567a984708SDavid Chisnall 257*b5893f02SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator, class Predicate> 258*b5893f02SDimitry Andric void erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 259*b5893f02SDimitry Andric 260*b5893f02SDimitry Andric 2617a984708SDavid Chisnalltemplate <class Key, class T, class Compare = less<Key>, 2627a984708SDavid Chisnall class Allocator = allocator<pair<const Key, T>>> 2637a984708SDavid Chisnallclass multimap 2647a984708SDavid Chisnall{ 2657a984708SDavid Chisnallpublic: 2667a984708SDavid Chisnall // types: 2677a984708SDavid Chisnall typedef Key key_type; 2687a984708SDavid Chisnall typedef T mapped_type; 2697a984708SDavid Chisnall typedef pair<const key_type,mapped_type> value_type; 2707a984708SDavid Chisnall typedef Compare key_compare; 2717a984708SDavid Chisnall typedef Allocator allocator_type; 2727a984708SDavid Chisnall typedef typename allocator_type::reference reference; 2737a984708SDavid Chisnall typedef typename allocator_type::const_reference const_reference; 2747a984708SDavid Chisnall typedef typename allocator_type::size_type size_type; 2757a984708SDavid Chisnall typedef typename allocator_type::difference_type difference_type; 2767a984708SDavid Chisnall typedef typename allocator_type::pointer pointer; 2777a984708SDavid Chisnall typedef typename allocator_type::const_pointer const_pointer; 2787a984708SDavid Chisnall 2797a984708SDavid Chisnall typedef implementation-defined iterator; 2807a984708SDavid Chisnall typedef implementation-defined const_iterator; 2817a984708SDavid Chisnall typedef std::reverse_iterator<iterator> reverse_iterator; 2827a984708SDavid Chisnall typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 2834ba319b5SDimitry Andric typedef unspecified node_type; // C++17 2847a984708SDavid Chisnall 2857a984708SDavid Chisnall class value_compare 2867a984708SDavid Chisnall : public binary_function<value_type,value_type,bool> 2877a984708SDavid Chisnall { 2887a984708SDavid Chisnall friend class multimap; 2897a984708SDavid Chisnall protected: 2907a984708SDavid Chisnall key_compare comp; 2917a984708SDavid Chisnall value_compare(key_compare c); 2927a984708SDavid Chisnall public: 2937a984708SDavid Chisnall bool operator()(const value_type& x, const value_type& y) const; 2947a984708SDavid Chisnall }; 2957a984708SDavid Chisnall 2967a984708SDavid Chisnall // construct/copy/destroy: 2977a984708SDavid Chisnall multimap() 2987a984708SDavid Chisnall noexcept( 2997a984708SDavid Chisnall is_nothrow_default_constructible<allocator_type>::value && 3007a984708SDavid Chisnall is_nothrow_default_constructible<key_compare>::value && 3017a984708SDavid Chisnall is_nothrow_copy_constructible<key_compare>::value); 3027a984708SDavid Chisnall explicit multimap(const key_compare& comp); 3037a984708SDavid Chisnall multimap(const key_compare& comp, const allocator_type& a); 3047a984708SDavid Chisnall template <class InputIterator> 3057a984708SDavid Chisnall multimap(InputIterator first, InputIterator last, const key_compare& comp); 3067a984708SDavid Chisnall template <class InputIterator> 3077a984708SDavid Chisnall multimap(InputIterator first, InputIterator last, const key_compare& comp, 3087a984708SDavid Chisnall const allocator_type& a); 3097a984708SDavid Chisnall multimap(const multimap& m); 3107a984708SDavid Chisnall multimap(multimap&& m) 3117a984708SDavid Chisnall noexcept( 3127a984708SDavid Chisnall is_nothrow_move_constructible<allocator_type>::value && 3137a984708SDavid Chisnall is_nothrow_move_constructible<key_compare>::value); 3147a984708SDavid Chisnall explicit multimap(const allocator_type& a); 3157a984708SDavid Chisnall multimap(const multimap& m, const allocator_type& a); 3167a984708SDavid Chisnall multimap(multimap&& m, const allocator_type& a); 3177a984708SDavid Chisnall multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); 3187a984708SDavid Chisnall multimap(initializer_list<value_type> il, const key_compare& comp, 3197a984708SDavid Chisnall const allocator_type& a); 3204f7ab58eSDimitry Andric template <class InputIterator> 3214f7ab58eSDimitry Andric multimap(InputIterator first, InputIterator last, const allocator_type& a) 3224f7ab58eSDimitry Andric : multimap(first, last, Compare(), a) {} // C++14 3234f7ab58eSDimitry Andric multimap(initializer_list<value_type> il, const allocator_type& a) 3244f7ab58eSDimitry Andric : multimap(il, Compare(), a) {} // C++14 3257a984708SDavid Chisnall ~multimap(); 3267a984708SDavid Chisnall 3277a984708SDavid Chisnall multimap& operator=(const multimap& m); 3287a984708SDavid Chisnall multimap& operator=(multimap&& m) 3297a984708SDavid Chisnall noexcept( 3307a984708SDavid Chisnall allocator_type::propagate_on_container_move_assignment::value && 3317a984708SDavid Chisnall is_nothrow_move_assignable<allocator_type>::value && 3327a984708SDavid Chisnall is_nothrow_move_assignable<key_compare>::value); 3337a984708SDavid Chisnall multimap& operator=(initializer_list<value_type> il); 3347a984708SDavid Chisnall 3357a984708SDavid Chisnall // iterators: 3367a984708SDavid Chisnall iterator begin() noexcept; 3377a984708SDavid Chisnall const_iterator begin() const noexcept; 3387a984708SDavid Chisnall iterator end() noexcept; 3397a984708SDavid Chisnall const_iterator end() const noexcept; 3407a984708SDavid Chisnall 3417a984708SDavid Chisnall reverse_iterator rbegin() noexcept; 3427a984708SDavid Chisnall const_reverse_iterator rbegin() const noexcept; 3437a984708SDavid Chisnall reverse_iterator rend() noexcept; 3447a984708SDavid Chisnall const_reverse_iterator rend() const noexcept; 3457a984708SDavid Chisnall 3467a984708SDavid Chisnall const_iterator cbegin() const noexcept; 3477a984708SDavid Chisnall const_iterator cend() const noexcept; 3487a984708SDavid Chisnall const_reverse_iterator crbegin() const noexcept; 3497a984708SDavid Chisnall const_reverse_iterator crend() const noexcept; 3507a984708SDavid Chisnall 3517a984708SDavid Chisnall // capacity: 3527a984708SDavid Chisnall bool empty() const noexcept; 3537a984708SDavid Chisnall size_type size() const noexcept; 3547a984708SDavid Chisnall size_type max_size() const noexcept; 3557a984708SDavid Chisnall 3567a984708SDavid Chisnall // modifiers: 3577a984708SDavid Chisnall template <class... Args> 3587a984708SDavid Chisnall iterator emplace(Args&&... args); 3597a984708SDavid Chisnall template <class... Args> 3607a984708SDavid Chisnall iterator emplace_hint(const_iterator position, Args&&... args); 3617a984708SDavid Chisnall iterator insert(const value_type& v); 3629729cf09SDimitry Andric iterator insert( value_type&& v); // C++17 3637a984708SDavid Chisnall template <class P> 3647a984708SDavid Chisnall iterator insert(P&& p); 3657a984708SDavid Chisnall iterator insert(const_iterator position, const value_type& v); 3669729cf09SDimitry Andric iterator insert(const_iterator position, value_type&& v); // C++17 3677a984708SDavid Chisnall template <class P> 3687a984708SDavid Chisnall iterator insert(const_iterator position, P&& p); 3697a984708SDavid Chisnall template <class InputIterator> 3707a984708SDavid Chisnall void insert(InputIterator first, InputIterator last); 3717a984708SDavid Chisnall void insert(initializer_list<value_type> il); 3727a984708SDavid Chisnall 3734ba319b5SDimitry Andric node_type extract(const_iterator position); // C++17 3744ba319b5SDimitry Andric node_type extract(const key_type& x); // C++17 3754ba319b5SDimitry Andric iterator insert(node_type&& nh); // C++17 3764ba319b5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 3774ba319b5SDimitry Andric 3787a984708SDavid Chisnall iterator erase(const_iterator position); 379854fa44bSDimitry Andric iterator erase(iterator position); // C++14 3807a984708SDavid Chisnall size_type erase(const key_type& k); 3817a984708SDavid Chisnall iterator erase(const_iterator first, const_iterator last); 3827a984708SDavid Chisnall void clear() noexcept; 3837a984708SDavid Chisnall 384*b5893f02SDimitry Andric template<class C2> 385*b5893f02SDimitry Andric void merge(multimap<Key, T, C2, Allocator>& source); // C++17 386*b5893f02SDimitry Andric template<class C2> 387*b5893f02SDimitry Andric void merge(multimap<Key, T, C2, Allocator>&& source); // C++17 388*b5893f02SDimitry Andric template<class C2> 389*b5893f02SDimitry Andric void merge(map<Key, T, C2, Allocator>& source); // C++17 390*b5893f02SDimitry Andric template<class C2> 391*b5893f02SDimitry Andric void merge(map<Key, T, C2, Allocator>&& source); // C++17 392*b5893f02SDimitry Andric 3937a984708SDavid Chisnall void swap(multimap& m) 394854fa44bSDimitry Andric noexcept(allocator_traits<allocator_type>::is_always_equal::value && 3957c82a1ecSDimitry Andric is_nothrow_swappable<key_compare>::value); // C++17 3967a984708SDavid Chisnall 3977a984708SDavid Chisnall // observers: 3987a984708SDavid Chisnall allocator_type get_allocator() const noexcept; 3997a984708SDavid Chisnall key_compare key_comp() const; 4007a984708SDavid Chisnall value_compare value_comp() const; 4017a984708SDavid Chisnall 4027a984708SDavid Chisnall // map operations: 4037a984708SDavid Chisnall iterator find(const key_type& k); 4047a984708SDavid Chisnall const_iterator find(const key_type& k) const; 4054f7ab58eSDimitry Andric template<typename K> 4064f7ab58eSDimitry Andric iterator find(const K& x); // C++14 4074f7ab58eSDimitry Andric template<typename K> 4084f7ab58eSDimitry Andric const_iterator find(const K& x) const; // C++14 4094f7ab58eSDimitry Andric template<typename K> 410d72607e9SDimitry Andric size_type count(const K& x) const; // C++14 4114f7ab58eSDimitry Andric 4127a984708SDavid Chisnall size_type count(const key_type& k) const; 4137a984708SDavid Chisnall iterator lower_bound(const key_type& k); 4147a984708SDavid Chisnall const_iterator lower_bound(const key_type& k) const; 4154f7ab58eSDimitry Andric template<typename K> 4164f7ab58eSDimitry Andric iterator lower_bound(const K& x); // C++14 4174f7ab58eSDimitry Andric template<typename K> 4184f7ab58eSDimitry Andric const_iterator lower_bound(const K& x) const; // C++14 4194f7ab58eSDimitry Andric 4207a984708SDavid Chisnall iterator upper_bound(const key_type& k); 4217a984708SDavid Chisnall const_iterator upper_bound(const key_type& k) const; 4224f7ab58eSDimitry Andric template<typename K> 4234f7ab58eSDimitry Andric iterator upper_bound(const K& x); // C++14 4244f7ab58eSDimitry Andric template<typename K> 4254f7ab58eSDimitry Andric const_iterator upper_bound(const K& x) const; // C++14 4264f7ab58eSDimitry Andric 4277a984708SDavid Chisnall pair<iterator,iterator> equal_range(const key_type& k); 4287a984708SDavid Chisnall pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 4294f7ab58eSDimitry Andric template<typename K> 4304f7ab58eSDimitry Andric pair<iterator,iterator> equal_range(const K& x); // C++14 4314f7ab58eSDimitry Andric template<typename K> 4324f7ab58eSDimitry Andric pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 4337a984708SDavid Chisnall}; 4347a984708SDavid Chisnall 4357a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 4367a984708SDavid Chisnallbool 4377a984708SDavid Chisnalloperator==(const multimap<Key, T, Compare, Allocator>& x, 4387a984708SDavid Chisnall const multimap<Key, T, Compare, Allocator>& y); 4397a984708SDavid Chisnall 4407a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 4417a984708SDavid Chisnallbool 4427a984708SDavid Chisnalloperator< (const multimap<Key, T, Compare, Allocator>& x, 4437a984708SDavid Chisnall const multimap<Key, T, Compare, Allocator>& y); 4447a984708SDavid Chisnall 4457a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 4467a984708SDavid Chisnallbool 4477a984708SDavid Chisnalloperator!=(const multimap<Key, T, Compare, Allocator>& x, 4487a984708SDavid Chisnall const multimap<Key, T, Compare, Allocator>& y); 4497a984708SDavid Chisnall 4507a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 4517a984708SDavid Chisnallbool 4527a984708SDavid Chisnalloperator> (const multimap<Key, T, Compare, Allocator>& x, 4537a984708SDavid Chisnall const multimap<Key, T, Compare, Allocator>& y); 4547a984708SDavid Chisnall 4557a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 4567a984708SDavid Chisnallbool 4577a984708SDavid Chisnalloperator>=(const multimap<Key, T, Compare, Allocator>& x, 4587a984708SDavid Chisnall const multimap<Key, T, Compare, Allocator>& y); 4597a984708SDavid Chisnall 4607a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 4617a984708SDavid Chisnallbool 4627a984708SDavid Chisnalloperator<=(const multimap<Key, T, Compare, Allocator>& x, 4637a984708SDavid Chisnall const multimap<Key, T, Compare, Allocator>& y); 4647a984708SDavid Chisnall 4657a984708SDavid Chisnall// specialized algorithms: 4667a984708SDavid Chisnalltemplate <class Key, class T, class Compare, class Allocator> 4677a984708SDavid Chisnallvoid 4687a984708SDavid Chisnallswap(multimap<Key, T, Compare, Allocator>& x, 4697a984708SDavid Chisnall multimap<Key, T, Compare, Allocator>& y) 4707a984708SDavid Chisnall noexcept(noexcept(x.swap(y))); 4717a984708SDavid Chisnall 472*b5893f02SDimitry Andrictemplate <class Key, class T, class Compare, class Allocator, class Predicate> 473*b5893f02SDimitry Andric void erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 474*b5893f02SDimitry Andric 4757a984708SDavid Chisnall} // std 4767a984708SDavid Chisnall 4777a984708SDavid Chisnall*/ 4787a984708SDavid Chisnall 4797a984708SDavid Chisnall#include <__config> 4807a984708SDavid Chisnall#include <__tree> 4814ba319b5SDimitry Andric#include <__node_handle> 4827a984708SDavid Chisnall#include <iterator> 4837a984708SDavid Chisnall#include <memory> 4847a984708SDavid Chisnall#include <utility> 4857a984708SDavid Chisnall#include <functional> 4867a984708SDavid Chisnall#include <initializer_list> 487854fa44bSDimitry Andric#include <type_traits> 488*b5893f02SDimitry Andric#include <version> 4897a984708SDavid Chisnall 4907a984708SDavid Chisnall#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 4917a984708SDavid Chisnall#pragma GCC system_header 4927a984708SDavid Chisnall#endif 4937a984708SDavid Chisnall 4947a984708SDavid Chisnall_LIBCPP_BEGIN_NAMESPACE_STD 4957a984708SDavid Chisnall 496*b5893f02SDimitry Andrictemplate <class _Key, class _CP, class _Compare, 497*b5893f02SDimitry Andric bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value> 4987a984708SDavid Chisnallclass __map_value_compare 4997a984708SDavid Chisnall : private _Compare 5007a984708SDavid Chisnall{ 5017a984708SDavid Chisnallpublic: 5027a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5037a984708SDavid Chisnall __map_value_compare() 5047a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) 5057a984708SDavid Chisnall : _Compare() {} 5067a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5077a984708SDavid Chisnall __map_value_compare(_Compare c) 5087a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) 5097a984708SDavid Chisnall : _Compare(c) {} 5107a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5117a984708SDavid Chisnall const _Compare& key_comp() const _NOEXCEPT {return *this;} 5127a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5137a984708SDavid Chisnall bool operator()(const _CP& __x, const _CP& __y) const 5144ba319b5SDimitry Andric {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first);} 5157a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5167a984708SDavid Chisnall bool operator()(const _CP& __x, const _Key& __y) const 5174ba319b5SDimitry Andric {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);} 5187a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5197a984708SDavid Chisnall bool operator()(const _Key& __x, const _CP& __y) const 5204ba319b5SDimitry Andric {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);} 521854fa44bSDimitry Andric void swap(__map_value_compare&__y) 522854fa44bSDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) 523854fa44bSDimitry Andric { 524854fa44bSDimitry Andric using _VSTD::swap; 525540d2a8bSDimitry Andric swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); 526854fa44bSDimitry Andric } 5274f7ab58eSDimitry Andric 5284f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 5294f7ab58eSDimitry Andric template <typename _K2> 5304f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 5314f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type 5324f7ab58eSDimitry Andric operator () ( const _K2& __x, const _CP& __y ) const 5334ba319b5SDimitry Andric {return static_cast<const _Compare&>(*this) (__x, __y.__get_value().first);} 5344f7ab58eSDimitry Andric 5354f7ab58eSDimitry Andric template <typename _K2> 5364f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 5374f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type 5384f7ab58eSDimitry Andric operator () (const _CP& __x, const _K2& __y) const 5394ba319b5SDimitry Andric {return static_cast<const _Compare&>(*this) (__x.__get_value().first, __y);} 5404f7ab58eSDimitry Andric#endif 5417a984708SDavid Chisnall}; 5427a984708SDavid Chisnall 5434bab9fd9SDavid Chisnalltemplate <class _Key, class _CP, class _Compare> 5444bab9fd9SDavid Chisnallclass __map_value_compare<_Key, _CP, _Compare, false> 5457a984708SDavid Chisnall{ 5467a984708SDavid Chisnall _Compare comp; 5477a984708SDavid Chisnall 5487a984708SDavid Chisnallpublic: 5497a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5507a984708SDavid Chisnall __map_value_compare() 5517a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) 5527a984708SDavid Chisnall : comp() {} 5537a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5547a984708SDavid Chisnall __map_value_compare(_Compare c) 5557a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) 5567a984708SDavid Chisnall : comp(c) {} 5577a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5587a984708SDavid Chisnall const _Compare& key_comp() const _NOEXCEPT {return comp;} 5597a984708SDavid Chisnall 5607a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5617a984708SDavid Chisnall bool operator()(const _CP& __x, const _CP& __y) const 5624ba319b5SDimitry Andric {return comp(__x.__get_value().first, __y.__get_value().first);} 5637a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5647a984708SDavid Chisnall bool operator()(const _CP& __x, const _Key& __y) const 5654ba319b5SDimitry Andric {return comp(__x.__get_value().first, __y);} 5667a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5677a984708SDavid Chisnall bool operator()(const _Key& __x, const _CP& __y) const 5684ba319b5SDimitry Andric {return comp(__x, __y.__get_value().first);} 569854fa44bSDimitry Andric void swap(__map_value_compare&__y) 570854fa44bSDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) 571854fa44bSDimitry Andric { 572854fa44bSDimitry Andric using _VSTD::swap; 573854fa44bSDimitry Andric swap(comp, __y.comp); 574854fa44bSDimitry Andric } 5754f7ab58eSDimitry Andric 5764f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 5774f7ab58eSDimitry Andric template <typename _K2> 5784f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 5794f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type 5804f7ab58eSDimitry Andric operator () ( const _K2& __x, const _CP& __y ) const 5814ba319b5SDimitry Andric {return comp (__x, __y.__get_value().first);} 5824f7ab58eSDimitry Andric 5834f7ab58eSDimitry Andric template <typename _K2> 5844f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 5854f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type 5864f7ab58eSDimitry Andric operator () (const _CP& __x, const _K2& __y) const 5874ba319b5SDimitry Andric {return comp (__x.__get_value().first, __y);} 5884f7ab58eSDimitry Andric#endif 5897a984708SDavid Chisnall}; 5907a984708SDavid Chisnall 591854fa44bSDimitry Andrictemplate <class _Key, class _CP, class _Compare, bool __b> 592854fa44bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 593854fa44bSDimitry Andricvoid 594854fa44bSDimitry Andricswap(__map_value_compare<_Key, _CP, _Compare, __b>& __x, 595854fa44bSDimitry Andric __map_value_compare<_Key, _CP, _Compare, __b>& __y) 596854fa44bSDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 597854fa44bSDimitry Andric{ 598854fa44bSDimitry Andric __x.swap(__y); 599854fa44bSDimitry Andric} 600854fa44bSDimitry Andric 6017a984708SDavid Chisnalltemplate <class _Allocator> 6027a984708SDavid Chisnallclass __map_node_destructor 6037a984708SDavid Chisnall{ 6047a984708SDavid Chisnall typedef _Allocator allocator_type; 6057a984708SDavid Chisnall typedef allocator_traits<allocator_type> __alloc_traits; 6067c82a1ecSDimitry Andric 6077a984708SDavid Chisnallpublic: 6087a984708SDavid Chisnall typedef typename __alloc_traits::pointer pointer; 6097a984708SDavid Chisnall 6107c82a1ecSDimitry Andricprivate: 6117a984708SDavid Chisnall allocator_type& __na_; 6127a984708SDavid Chisnall 6137a984708SDavid Chisnall __map_node_destructor& operator=(const __map_node_destructor&); 6147a984708SDavid Chisnall 6157a984708SDavid Chisnallpublic: 6167a984708SDavid Chisnall bool __first_constructed; 6177a984708SDavid Chisnall bool __second_constructed; 6187a984708SDavid Chisnall 6197a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6207a984708SDavid Chisnall explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT 6217a984708SDavid Chisnall : __na_(__na), 6227a984708SDavid Chisnall __first_constructed(false), 6237a984708SDavid Chisnall __second_constructed(false) 6247a984708SDavid Chisnall {} 6257a984708SDavid Chisnall 626540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6277a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6287a984708SDavid Chisnall __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT 6297a984708SDavid Chisnall : __na_(__x.__na_), 6307a984708SDavid Chisnall __first_constructed(__x.__value_constructed), 6317a984708SDavid Chisnall __second_constructed(__x.__value_constructed) 6327a984708SDavid Chisnall { 6337a984708SDavid Chisnall __x.__value_constructed = false; 6347a984708SDavid Chisnall } 635540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 6367a984708SDavid Chisnall 6377a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6387a984708SDavid Chisnall void operator()(pointer __p) _NOEXCEPT 6397a984708SDavid Chisnall { 6407a984708SDavid Chisnall if (__second_constructed) 6414ba319b5SDimitry Andric __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second)); 6427a984708SDavid Chisnall if (__first_constructed) 6434ba319b5SDimitry Andric __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first)); 6447a984708SDavid Chisnall if (__p) 6457a984708SDavid Chisnall __alloc_traits::deallocate(__na_, __p, 1); 6467a984708SDavid Chisnall } 6477a984708SDavid Chisnall}; 6487a984708SDavid Chisnall 6497a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 6507a984708SDavid Chisnall class map; 6517a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 6527a984708SDavid Chisnall class multimap; 6537a984708SDavid Chisnalltemplate <class _TreeIterator> class __map_const_iterator; 6547a984708SDavid Chisnall 6557c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6564f7ab58eSDimitry Andric 6574f7ab58eSDimitry Andrictemplate <class _Key, class _Tp> 6584ba319b5SDimitry Andricstruct __value_type 6594f7ab58eSDimitry Andric{ 6604f7ab58eSDimitry Andric typedef _Key key_type; 6614f7ab58eSDimitry Andric typedef _Tp mapped_type; 6624f7ab58eSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 6634ba319b5SDimitry Andric typedef pair<key_type&, mapped_type&> __nc_ref_pair_type; 6644ba319b5SDimitry Andric typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type; 6654f7ab58eSDimitry Andric 6664ba319b5SDimitry Andricprivate: 6674f7ab58eSDimitry Andric value_type __cc; 6684ba319b5SDimitry Andric 6694ba319b5SDimitry Andricpublic: 6704ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6714ba319b5SDimitry Andric value_type& __get_value() 6724ba319b5SDimitry Andric { 6734ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 6744ba319b5SDimitry Andric return *_VSTD::launder(_VSTD::addressof(__cc)); 6754ba319b5SDimitry Andric#else 6764ba319b5SDimitry Andric return __cc; 6774ba319b5SDimitry Andric#endif 6784ba319b5SDimitry Andric } 6794ba319b5SDimitry Andric 6804ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6814ba319b5SDimitry Andric const value_type& __get_value() const 6824ba319b5SDimitry Andric { 6834ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 6844ba319b5SDimitry Andric return *_VSTD::launder(_VSTD::addressof(__cc)); 6854ba319b5SDimitry Andric#else 6864ba319b5SDimitry Andric return __cc; 6874ba319b5SDimitry Andric#endif 6884ba319b5SDimitry Andric } 6894ba319b5SDimitry Andric 6904ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6914ba319b5SDimitry Andric __nc_ref_pair_type __ref() 6924ba319b5SDimitry Andric { 6934ba319b5SDimitry Andric value_type& __v = __get_value(); 6944ba319b5SDimitry Andric return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second); 6954ba319b5SDimitry Andric } 6964ba319b5SDimitry Andric 6974ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6984ba319b5SDimitry Andric __nc_rref_pair_type __move() 6994ba319b5SDimitry Andric { 7004ba319b5SDimitry Andric value_type& __v = __get_value(); 7014ba319b5SDimitry Andric return __nc_rref_pair_type( 7024ba319b5SDimitry Andric _VSTD::move(const_cast<key_type&>(__v.first)), 7034ba319b5SDimitry Andric _VSTD::move(__v.second)); 7044ba319b5SDimitry Andric } 7054f7ab58eSDimitry Andric 7064f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 7074f7ab58eSDimitry Andric __value_type& operator=(const __value_type& __v) 7084ba319b5SDimitry Andric { 7094ba319b5SDimitry Andric __ref() = __v.__get_value(); 7104ba319b5SDimitry Andric return *this; 7114ba319b5SDimitry Andric } 7124f7ab58eSDimitry Andric 7134f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 7144f7ab58eSDimitry Andric __value_type& operator=(__value_type&& __v) 7154ba319b5SDimitry Andric { 7164ba319b5SDimitry Andric __ref() = __v.__move(); 7174ba319b5SDimitry Andric return *this; 7184ba319b5SDimitry Andric } 7194f7ab58eSDimitry Andric 7207c82a1ecSDimitry Andric template <class _ValueTp, 7217c82a1ecSDimitry Andric class = typename enable_if< 7227c82a1ecSDimitry Andric __is_same_uncvref<_ValueTp, value_type>::value 7237c82a1ecSDimitry Andric >::type 7247c82a1ecSDimitry Andric > 7254f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 7264ba319b5SDimitry Andric __value_type& operator=(_ValueTp&& __v) 7274ba319b5SDimitry Andric { 7284ba319b5SDimitry Andric __ref() = _VSTD::forward<_ValueTp>(__v); 7294ba319b5SDimitry Andric return *this; 7307c82a1ecSDimitry Andric } 7317c82a1ecSDimitry Andric 7327c82a1ecSDimitry Andricprivate: 7337c82a1ecSDimitry Andric __value_type() _LIBCPP_EQUAL_DELETE; 7347c82a1ecSDimitry Andric ~__value_type() _LIBCPP_EQUAL_DELETE; 7357c82a1ecSDimitry Andric __value_type(const __value_type& __v) _LIBCPP_EQUAL_DELETE; 7367c82a1ecSDimitry Andric __value_type(__value_type&& __v) _LIBCPP_EQUAL_DELETE; 7374f7ab58eSDimitry Andric}; 7384f7ab58eSDimitry Andric 7394f7ab58eSDimitry Andric#else 7404f7ab58eSDimitry Andric 7414f7ab58eSDimitry Andrictemplate <class _Key, class _Tp> 7424f7ab58eSDimitry Andricstruct __value_type 7434f7ab58eSDimitry Andric{ 7444f7ab58eSDimitry Andric typedef _Key key_type; 7454f7ab58eSDimitry Andric typedef _Tp mapped_type; 7464f7ab58eSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 7474f7ab58eSDimitry Andric 7484ba319b5SDimitry Andricprivate: 7494f7ab58eSDimitry Andric value_type __cc; 7504f7ab58eSDimitry Andric 7514ba319b5SDimitry Andricpublic: 7524ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7534ba319b5SDimitry Andric value_type& __get_value() { return __cc; } 7544ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7554ba319b5SDimitry Andric const value_type& __get_value() const { return __cc; } 7564ba319b5SDimitry Andric 7577c82a1ecSDimitry Andricprivate: 7587c82a1ecSDimitry Andric __value_type(); 7597c82a1ecSDimitry Andric __value_type(__value_type const&); 7607c82a1ecSDimitry Andric __value_type& operator=(__value_type const&); 7617c82a1ecSDimitry Andric ~__value_type(); 7624f7ab58eSDimitry Andric}; 7634f7ab58eSDimitry Andric 764540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 7654f7ab58eSDimitry Andric 766854fa44bSDimitry Andrictemplate <class _Tp> 767854fa44bSDimitry Andricstruct __extract_key_value_types; 768854fa44bSDimitry Andric 769854fa44bSDimitry Andrictemplate <class _Key, class _Tp> 770854fa44bSDimitry Andricstruct __extract_key_value_types<__value_type<_Key, _Tp> > 771854fa44bSDimitry Andric{ 772854fa44bSDimitry Andric typedef _Key const __key_type; 773854fa44bSDimitry Andric typedef _Tp __mapped_type; 774854fa44bSDimitry Andric}; 775854fa44bSDimitry Andric 7767a984708SDavid Chisnalltemplate <class _TreeIterator> 777aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __map_iterator 7787a984708SDavid Chisnall{ 7797c82a1ecSDimitry Andric typedef typename _TreeIterator::_NodeTypes _NodeTypes; 7807c82a1ecSDimitry Andric typedef typename _TreeIterator::__pointer_traits __pointer_traits; 7817c82a1ecSDimitry Andric 7827a984708SDavid Chisnall _TreeIterator __i_; 7837a984708SDavid Chisnall 7847a984708SDavid Chisnallpublic: 7857a984708SDavid Chisnall typedef bidirectional_iterator_tag iterator_category; 7867c82a1ecSDimitry Andric typedef typename _NodeTypes::__map_value_type value_type; 7877a984708SDavid Chisnall typedef typename _TreeIterator::difference_type difference_type; 7887a984708SDavid Chisnall typedef value_type& reference; 7897c82a1ecSDimitry Andric typedef typename _NodeTypes::__map_value_type_pointer pointer; 7907a984708SDavid Chisnall 7917a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7927a984708SDavid Chisnall __map_iterator() _NOEXCEPT {} 7937a984708SDavid Chisnall 7947a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7957a984708SDavid Chisnall __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} 7967a984708SDavid Chisnall 7977a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7984ba319b5SDimitry Andric reference operator*() const {return __i_->__get_value();} 7997a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8004ba319b5SDimitry Andric pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());} 8017a984708SDavid Chisnall 8027a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8037a984708SDavid Chisnall __map_iterator& operator++() {++__i_; return *this;} 8047a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8057a984708SDavid Chisnall __map_iterator operator++(int) 8067a984708SDavid Chisnall { 8077a984708SDavid Chisnall __map_iterator __t(*this); 8087a984708SDavid Chisnall ++(*this); 8097a984708SDavid Chisnall return __t; 8107a984708SDavid Chisnall } 8117a984708SDavid Chisnall 8127a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8137a984708SDavid Chisnall __map_iterator& operator--() {--__i_; return *this;} 8147a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8157a984708SDavid Chisnall __map_iterator operator--(int) 8167a984708SDavid Chisnall { 8177a984708SDavid Chisnall __map_iterator __t(*this); 8187a984708SDavid Chisnall --(*this); 8197a984708SDavid Chisnall return __t; 8207a984708SDavid Chisnall } 8217a984708SDavid Chisnall 8227a984708SDavid Chisnall friend _LIBCPP_INLINE_VISIBILITY 8237a984708SDavid Chisnall bool operator==(const __map_iterator& __x, const __map_iterator& __y) 8247a984708SDavid Chisnall {return __x.__i_ == __y.__i_;} 8257a984708SDavid Chisnall friend 8267a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8277a984708SDavid Chisnall bool operator!=(const __map_iterator& __x, const __map_iterator& __y) 8287a984708SDavid Chisnall {return __x.__i_ != __y.__i_;} 8297a984708SDavid Chisnall 830aed8d94eSDimitry Andric template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map; 831aed8d94eSDimitry Andric template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap; 832aed8d94eSDimitry Andric template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; 8337a984708SDavid Chisnall}; 8347a984708SDavid Chisnall 8357a984708SDavid Chisnalltemplate <class _TreeIterator> 836aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __map_const_iterator 8377a984708SDavid Chisnall{ 8387c82a1ecSDimitry Andric typedef typename _TreeIterator::_NodeTypes _NodeTypes; 8397c82a1ecSDimitry Andric typedef typename _TreeIterator::__pointer_traits __pointer_traits; 8407c82a1ecSDimitry Andric 8417a984708SDavid Chisnall _TreeIterator __i_; 8427a984708SDavid Chisnall 8437a984708SDavid Chisnallpublic: 8447a984708SDavid Chisnall typedef bidirectional_iterator_tag iterator_category; 8457c82a1ecSDimitry Andric typedef typename _NodeTypes::__map_value_type value_type; 8467a984708SDavid Chisnall typedef typename _TreeIterator::difference_type difference_type; 8477a984708SDavid Chisnall typedef const value_type& reference; 8487c82a1ecSDimitry Andric typedef typename _NodeTypes::__const_map_value_type_pointer pointer; 8497a984708SDavid Chisnall 8507a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8517a984708SDavid Chisnall __map_const_iterator() _NOEXCEPT {} 8527a984708SDavid Chisnall 8537a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8547a984708SDavid Chisnall __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} 8557a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 856854fa44bSDimitry Andric __map_const_iterator(__map_iterator< 857854fa44bSDimitry Andric typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT 8587a984708SDavid Chisnall : __i_(__i.__i_) {} 8597a984708SDavid Chisnall 8607a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8614ba319b5SDimitry Andric reference operator*() const {return __i_->__get_value();} 8627a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8634ba319b5SDimitry Andric pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());} 8647a984708SDavid Chisnall 8657a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8667a984708SDavid Chisnall __map_const_iterator& operator++() {++__i_; return *this;} 8677a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8687a984708SDavid Chisnall __map_const_iterator operator++(int) 8697a984708SDavid Chisnall { 8707a984708SDavid Chisnall __map_const_iterator __t(*this); 8717a984708SDavid Chisnall ++(*this); 8727a984708SDavid Chisnall return __t; 8737a984708SDavid Chisnall } 8747a984708SDavid Chisnall 8757a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8767a984708SDavid Chisnall __map_const_iterator& operator--() {--__i_; return *this;} 8777a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8787a984708SDavid Chisnall __map_const_iterator operator--(int) 8797a984708SDavid Chisnall { 8807a984708SDavid Chisnall __map_const_iterator __t(*this); 8817a984708SDavid Chisnall --(*this); 8827a984708SDavid Chisnall return __t; 8837a984708SDavid Chisnall } 8847a984708SDavid Chisnall 8857a984708SDavid Chisnall friend _LIBCPP_INLINE_VISIBILITY 8867a984708SDavid Chisnall bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) 8877a984708SDavid Chisnall {return __x.__i_ == __y.__i_;} 8887a984708SDavid Chisnall friend _LIBCPP_INLINE_VISIBILITY 8897a984708SDavid Chisnall bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) 8907a984708SDavid Chisnall {return __x.__i_ != __y.__i_;} 8917a984708SDavid Chisnall 892aed8d94eSDimitry Andric template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map; 893aed8d94eSDimitry Andric template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap; 894aed8d94eSDimitry Andric template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; 8957a984708SDavid Chisnall}; 8967a984708SDavid Chisnall 8977a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare = less<_Key>, 8987a984708SDavid Chisnall class _Allocator = allocator<pair<const _Key, _Tp> > > 899aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS map 9007a984708SDavid Chisnall{ 9017a984708SDavid Chisnallpublic: 9027a984708SDavid Chisnall // types: 9037a984708SDavid Chisnall typedef _Key key_type; 9047a984708SDavid Chisnall typedef _Tp mapped_type; 9057a984708SDavid Chisnall typedef pair<const key_type, mapped_type> value_type; 9067a984708SDavid Chisnall typedef _Compare key_compare; 9077a984708SDavid Chisnall typedef _Allocator allocator_type; 9087a984708SDavid Chisnall typedef value_type& reference; 9097a984708SDavid Chisnall typedef const value_type& const_reference; 9107a984708SDavid Chisnall 911*b5893f02SDimitry Andric static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); 9129729cf09SDimitry Andric static_assert((is_same<typename allocator_type::value_type, value_type>::value), 9139729cf09SDimitry Andric "Allocator::value_type must be same type as value_type"); 9149729cf09SDimitry Andric 915aed8d94eSDimitry Andric class _LIBCPP_TEMPLATE_VIS value_compare 9167a984708SDavid Chisnall : public binary_function<value_type, value_type, bool> 9177a984708SDavid Chisnall { 9187a984708SDavid Chisnall friend class map; 9197a984708SDavid Chisnall protected: 9207a984708SDavid Chisnall key_compare comp; 9217a984708SDavid Chisnall 9227a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {} 9237a984708SDavid Chisnall public: 9247a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9257a984708SDavid Chisnall bool operator()(const value_type& __x, const value_type& __y) const 9267a984708SDavid Chisnall {return comp(__x.first, __y.first);} 9277a984708SDavid Chisnall }; 9287a984708SDavid Chisnall 9297a984708SDavid Chisnallprivate: 9304bab9fd9SDavid Chisnall 9314f7ab58eSDimitry Andric typedef _VSTD::__value_type<key_type, mapped_type> __value_type; 9324bab9fd9SDavid Chisnall typedef __map_value_compare<key_type, __value_type, key_compare> __vc; 933854fa44bSDimitry Andric typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, 934854fa44bSDimitry Andric __value_type>::type __allocator_type; 9357a984708SDavid Chisnall typedef __tree<__value_type, __vc, __allocator_type> __base; 9367a984708SDavid Chisnall typedef typename __base::__node_traits __node_traits; 9377a984708SDavid Chisnall typedef allocator_traits<allocator_type> __alloc_traits; 9387a984708SDavid Chisnall 9397a984708SDavid Chisnall __base __tree_; 9407a984708SDavid Chisnall 9417a984708SDavid Chisnallpublic: 9427a984708SDavid Chisnall typedef typename __alloc_traits::pointer pointer; 9437a984708SDavid Chisnall typedef typename __alloc_traits::const_pointer const_pointer; 9447a984708SDavid Chisnall typedef typename __alloc_traits::size_type size_type; 9457a984708SDavid Chisnall typedef typename __alloc_traits::difference_type difference_type; 9467a984708SDavid Chisnall typedef __map_iterator<typename __base::iterator> iterator; 9477a984708SDavid Chisnall typedef __map_const_iterator<typename __base::const_iterator> const_iterator; 9487a984708SDavid Chisnall typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 9497a984708SDavid Chisnall typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 9507a984708SDavid Chisnall 9514ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 9524ba319b5SDimitry Andric typedef __map_node_handle<typename __base::__node, allocator_type> node_type; 9534ba319b5SDimitry Andric typedef __insert_return_type<iterator, node_type> insert_return_type; 9544ba319b5SDimitry Andric#endif 9554ba319b5SDimitry Andric 956*b5893f02SDimitry Andric template <class _Key2, class _Value2, class _Comp2, class _Alloc2> 957*b5893f02SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS map; 958*b5893f02SDimitry Andric template <class _Key2, class _Value2, class _Comp2, class _Alloc2> 959*b5893f02SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multimap; 960*b5893f02SDimitry Andric 9617a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 962d72607e9SDimitry Andric map() 9637a984708SDavid Chisnall _NOEXCEPT_( 9647a984708SDavid Chisnall is_nothrow_default_constructible<allocator_type>::value && 9657a984708SDavid Chisnall is_nothrow_default_constructible<key_compare>::value && 9667a984708SDavid Chisnall is_nothrow_copy_constructible<key_compare>::value) 967d72607e9SDimitry Andric : __tree_(__vc(key_compare())) {} 968d72607e9SDimitry Andric 969d72607e9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 970d72607e9SDimitry Andric explicit map(const key_compare& __comp) 971d72607e9SDimitry Andric _NOEXCEPT_( 972d72607e9SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 973d72607e9SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 9747a984708SDavid Chisnall : __tree_(__vc(__comp)) {} 9757a984708SDavid Chisnall 9767a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9777a984708SDavid Chisnall explicit map(const key_compare& __comp, const allocator_type& __a) 9787c82a1ecSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {} 9797a984708SDavid Chisnall 9807a984708SDavid Chisnall template <class _InputIterator> 9817a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9827a984708SDavid Chisnall map(_InputIterator __f, _InputIterator __l, 9837a984708SDavid Chisnall const key_compare& __comp = key_compare()) 9847a984708SDavid Chisnall : __tree_(__vc(__comp)) 9857a984708SDavid Chisnall { 9867a984708SDavid Chisnall insert(__f, __l); 9877a984708SDavid Chisnall } 9887a984708SDavid Chisnall 9897a984708SDavid Chisnall template <class _InputIterator> 9907a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9917a984708SDavid Chisnall map(_InputIterator __f, _InputIterator __l, 9927a984708SDavid Chisnall const key_compare& __comp, const allocator_type& __a) 9937c82a1ecSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) 9947a984708SDavid Chisnall { 9957a984708SDavid Chisnall insert(__f, __l); 9967a984708SDavid Chisnall } 9977a984708SDavid Chisnall 9984f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 9994f7ab58eSDimitry Andric template <class _InputIterator> 10004f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10014f7ab58eSDimitry Andric map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) 10024f7ab58eSDimitry Andric : map(__f, __l, key_compare(), __a) {} 10034f7ab58eSDimitry Andric#endif 10044f7ab58eSDimitry Andric 10057a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10067a984708SDavid Chisnall map(const map& __m) 10077a984708SDavid Chisnall : __tree_(__m.__tree_) 10087a984708SDavid Chisnall { 10097a984708SDavid Chisnall insert(__m.begin(), __m.end()); 10107a984708SDavid Chisnall } 10117a984708SDavid Chisnall 10127a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10137a984708SDavid Chisnall map& operator=(const map& __m) 10147a984708SDavid Chisnall { 10157c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 10167a984708SDavid Chisnall __tree_ = __m.__tree_; 10174bab9fd9SDavid Chisnall#else 1018a0492a11SDimitry Andric if (this != &__m) { 10194bab9fd9SDavid Chisnall __tree_.clear(); 10204bab9fd9SDavid Chisnall __tree_.value_comp() = __m.__tree_.value_comp(); 10214bab9fd9SDavid Chisnall __tree_.__copy_assign_alloc(__m.__tree_); 10224bab9fd9SDavid Chisnall insert(__m.begin(), __m.end()); 1023a0492a11SDimitry Andric } 10244bab9fd9SDavid Chisnall#endif 10257a984708SDavid Chisnall return *this; 10267a984708SDavid Chisnall } 10277a984708SDavid Chisnall 1028540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 10297a984708SDavid Chisnall 10307a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10317a984708SDavid Chisnall map(map&& __m) 10327a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) 10337a984708SDavid Chisnall : __tree_(_VSTD::move(__m.__tree_)) 10347a984708SDavid Chisnall { 10357a984708SDavid Chisnall } 10367a984708SDavid Chisnall 10377a984708SDavid Chisnall map(map&& __m, const allocator_type& __a); 10387a984708SDavid Chisnall 10397a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10407a984708SDavid Chisnall map& operator=(map&& __m) 10417a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) 10427a984708SDavid Chisnall { 10437a984708SDavid Chisnall __tree_ = _VSTD::move(__m.__tree_); 10447a984708SDavid Chisnall return *this; 10457a984708SDavid Chisnall } 10467a984708SDavid Chisnall 10477a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10487a984708SDavid Chisnall map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) 10497a984708SDavid Chisnall : __tree_(__vc(__comp)) 10507a984708SDavid Chisnall { 10517a984708SDavid Chisnall insert(__il.begin(), __il.end()); 10527a984708SDavid Chisnall } 10537a984708SDavid Chisnall 10547a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10557a984708SDavid Chisnall map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) 10567c82a1ecSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) 10577a984708SDavid Chisnall { 10587a984708SDavid Chisnall insert(__il.begin(), __il.end()); 10597a984708SDavid Chisnall } 10607a984708SDavid Chisnall 10614f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 10624f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10634f7ab58eSDimitry Andric map(initializer_list<value_type> __il, const allocator_type& __a) 10644f7ab58eSDimitry Andric : map(__il, key_compare(), __a) {} 10654f7ab58eSDimitry Andric#endif 10664f7ab58eSDimitry Andric 10677a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10687a984708SDavid Chisnall map& operator=(initializer_list<value_type> __il) 10697a984708SDavid Chisnall { 10707a984708SDavid Chisnall __tree_.__assign_unique(__il.begin(), __il.end()); 10717a984708SDavid Chisnall return *this; 10727a984708SDavid Chisnall } 10737a984708SDavid Chisnall 1074540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 10757a984708SDavid Chisnall 10767a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10777a984708SDavid Chisnall explicit map(const allocator_type& __a) 10787c82a1ecSDimitry Andric : __tree_(typename __base::allocator_type(__a)) 10797a984708SDavid Chisnall { 10807a984708SDavid Chisnall } 10817a984708SDavid Chisnall 10827a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10837a984708SDavid Chisnall map(const map& __m, const allocator_type& __a) 10847c82a1ecSDimitry Andric : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) 10857a984708SDavid Chisnall { 10867a984708SDavid Chisnall insert(__m.begin(), __m.end()); 10877a984708SDavid Chisnall } 10887a984708SDavid Chisnall 10897a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10907a984708SDavid Chisnall iterator begin() _NOEXCEPT {return __tree_.begin();} 10917a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10927a984708SDavid Chisnall const_iterator begin() const _NOEXCEPT {return __tree_.begin();} 10937a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10947a984708SDavid Chisnall iterator end() _NOEXCEPT {return __tree_.end();} 10957a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10967a984708SDavid Chisnall const_iterator end() const _NOEXCEPT {return __tree_.end();} 10977a984708SDavid Chisnall 10987a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10997a984708SDavid Chisnall reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} 11007a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11017a984708SDavid Chisnall const_reverse_iterator rbegin() const _NOEXCEPT 11027a984708SDavid Chisnall {return const_reverse_iterator(end());} 11037a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11047a984708SDavid Chisnall reverse_iterator rend() _NOEXCEPT 11057a984708SDavid Chisnall {return reverse_iterator(begin());} 11067a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11077a984708SDavid Chisnall const_reverse_iterator rend() const _NOEXCEPT 11087a984708SDavid Chisnall {return const_reverse_iterator(begin());} 11097a984708SDavid Chisnall 11107a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11117a984708SDavid Chisnall const_iterator cbegin() const _NOEXCEPT {return begin();} 11127a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11137a984708SDavid Chisnall const_iterator cend() const _NOEXCEPT {return end();} 11147a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11157a984708SDavid Chisnall const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 11167a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11177a984708SDavid Chisnall const_reverse_iterator crend() const _NOEXCEPT {return rend();} 11187a984708SDavid Chisnall 1119b2c7081bSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 11207a984708SDavid Chisnall bool empty() const _NOEXCEPT {return __tree_.size() == 0;} 11217a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11227a984708SDavid Chisnall size_type size() const _NOEXCEPT {return __tree_.size();} 11237a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11247a984708SDavid Chisnall size_type max_size() const _NOEXCEPT {return __tree_.max_size();} 11257a984708SDavid Chisnall 11267a984708SDavid Chisnall mapped_type& operator[](const key_type& __k); 11277c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 11287a984708SDavid Chisnall mapped_type& operator[](key_type&& __k); 11297a984708SDavid Chisnall#endif 11307a984708SDavid Chisnall 11317a984708SDavid Chisnall mapped_type& at(const key_type& __k); 11327a984708SDavid Chisnall const mapped_type& at(const key_type& __k) const; 11337a984708SDavid Chisnall 11347a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11357c82a1ecSDimitry Andric allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());} 11367a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11377a984708SDavid Chisnall key_compare key_comp() const {return __tree_.value_comp().key_comp();} 11387a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11397a984708SDavid Chisnall value_compare value_comp() const {return value_compare(__tree_.value_comp().key_comp());} 11407a984708SDavid Chisnall 11417c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 11427c82a1ecSDimitry Andric template <class ..._Args> 11437c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 11447c82a1ecSDimitry Andric pair<iterator, bool> emplace(_Args&& ...__args) { 11457c82a1ecSDimitry Andric return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...); 11467c82a1ecSDimitry Andric } 11477a984708SDavid Chisnall 1148936e9439SDimitry Andric template <class ..._Args> 11497c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 11507c82a1ecSDimitry Andric iterator emplace_hint(const_iterator __p, _Args&& ...__args) { 11517c82a1ecSDimitry Andric return __tree_.__emplace_hint_unique(__p.__i_, _VSTD::forward<_Args>(__args)...); 11527c82a1ecSDimitry Andric } 11537a984708SDavid Chisnall 115494e3ee44SDavid Chisnall template <class _Pp, 115594e3ee44SDavid Chisnall class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 11567a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 115794e3ee44SDavid Chisnall pair<iterator, bool> insert(_Pp&& __p) 115894e3ee44SDavid Chisnall {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));} 11597a984708SDavid Chisnall 116094e3ee44SDavid Chisnall template <class _Pp, 116194e3ee44SDavid Chisnall class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 11627a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 116394e3ee44SDavid Chisnall iterator insert(const_iterator __pos, _Pp&& __p) 116494e3ee44SDavid Chisnall {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));} 11657a984708SDavid Chisnall 11667c82a1ecSDimitry Andric#endif // _LIBCPP_CXX03_LANG 11677a984708SDavid Chisnall 11687a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11697a984708SDavid Chisnall pair<iterator, bool> 11707a984708SDavid Chisnall insert(const value_type& __v) {return __tree_.__insert_unique(__v);} 11717a984708SDavid Chisnall 11727a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11737a984708SDavid Chisnall iterator 11747a984708SDavid Chisnall insert(const_iterator __p, const value_type& __v) 11757a984708SDavid Chisnall {return __tree_.__insert_unique(__p.__i_, __v);} 11767a984708SDavid Chisnall 11777c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 11789729cf09SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11799729cf09SDimitry Andric pair<iterator, bool> 11807c82a1ecSDimitry Andric insert(value_type&& __v) {return __tree_.__insert_unique(_VSTD::move(__v));} 11819729cf09SDimitry Andric 11829729cf09SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11837c82a1ecSDimitry Andric iterator insert(const_iterator __p, value_type&& __v) 11847c82a1ecSDimitry Andric {return __tree_.__insert_unique(__p.__i_, _VSTD::move(__v));} 1185540d2a8bSDimitry Andric 1186540d2a8bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1187540d2a8bSDimitry Andric void insert(initializer_list<value_type> __il) 1188540d2a8bSDimitry Andric {insert(__il.begin(), __il.end());} 11899729cf09SDimitry Andric#endif 11909729cf09SDimitry Andric 11917a984708SDavid Chisnall template <class _InputIterator> 11927a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11937a984708SDavid Chisnall void insert(_InputIterator __f, _InputIterator __l) 11947a984708SDavid Chisnall { 11957a984708SDavid Chisnall for (const_iterator __e = cend(); __f != __l; ++__f) 11967a984708SDavid Chisnall insert(__e.__i_, *__f); 11977a984708SDavid Chisnall } 11987a984708SDavid Chisnall 1199854fa44bSDimitry Andric#if _LIBCPP_STD_VER > 14 12007c82a1ecSDimitry Andric 1201854fa44bSDimitry Andric template <class... _Args> 1202854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1203854fa44bSDimitry Andric pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) 1204854fa44bSDimitry Andric { 12057c82a1ecSDimitry Andric return __tree_.__emplace_unique_key_args(__k, 12067c82a1ecSDimitry Andric _VSTD::piecewise_construct, 12077c82a1ecSDimitry Andric _VSTD::forward_as_tuple(__k), 12087c82a1ecSDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); 1209854fa44bSDimitry Andric } 1210854fa44bSDimitry Andric 1211854fa44bSDimitry Andric template <class... _Args> 1212854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1213854fa44bSDimitry Andric pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) 1214854fa44bSDimitry Andric { 12157c82a1ecSDimitry Andric return __tree_.__emplace_unique_key_args(__k, 12167c82a1ecSDimitry Andric _VSTD::piecewise_construct, 12177c82a1ecSDimitry Andric _VSTD::forward_as_tuple(_VSTD::move(__k)), 12187c82a1ecSDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); 1219854fa44bSDimitry Andric } 1220854fa44bSDimitry Andric 1221854fa44bSDimitry Andric template <class... _Args> 1222854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1223854fa44bSDimitry Andric iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) 1224854fa44bSDimitry Andric { 12257c82a1ecSDimitry Andric return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, 12267c82a1ecSDimitry Andric _VSTD::piecewise_construct, 12277c82a1ecSDimitry Andric _VSTD::forward_as_tuple(__k), 1228854fa44bSDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); 1229854fa44bSDimitry Andric } 1230854fa44bSDimitry Andric 1231854fa44bSDimitry Andric template <class... _Args> 1232854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1233854fa44bSDimitry Andric iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) 1234854fa44bSDimitry Andric { 12357c82a1ecSDimitry Andric return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, 12367c82a1ecSDimitry Andric _VSTD::piecewise_construct, 12377c82a1ecSDimitry Andric _VSTD::forward_as_tuple(_VSTD::move(__k)), 1238854fa44bSDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); 1239854fa44bSDimitry Andric } 1240854fa44bSDimitry Andric 1241854fa44bSDimitry Andric template <class _Vp> 1242854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1243854fa44bSDimitry Andric pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) 1244854fa44bSDimitry Andric { 1245854fa44bSDimitry Andric iterator __p = lower_bound(__k); 1246854fa44bSDimitry Andric if ( __p != end() && !key_comp()(__k, __p->first)) 1247854fa44bSDimitry Andric { 1248854fa44bSDimitry Andric __p->second = _VSTD::forward<_Vp>(__v); 1249854fa44bSDimitry Andric return _VSTD::make_pair(__p, false); 1250854fa44bSDimitry Andric } 1251854fa44bSDimitry Andric return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true); 1252854fa44bSDimitry Andric } 1253854fa44bSDimitry Andric 1254854fa44bSDimitry Andric template <class _Vp> 1255854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1256854fa44bSDimitry Andric pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) 1257854fa44bSDimitry Andric { 1258854fa44bSDimitry Andric iterator __p = lower_bound(__k); 1259854fa44bSDimitry Andric if ( __p != end() && !key_comp()(__k, __p->first)) 1260854fa44bSDimitry Andric { 1261854fa44bSDimitry Andric __p->second = _VSTD::forward<_Vp>(__v); 1262854fa44bSDimitry Andric return _VSTD::make_pair(__p, false); 1263854fa44bSDimitry Andric } 1264854fa44bSDimitry Andric return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true); 1265854fa44bSDimitry Andric } 1266854fa44bSDimitry Andric 1267854fa44bSDimitry Andric template <class _Vp> 1268854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1269854fa44bSDimitry Andric iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) 1270854fa44bSDimitry Andric { 1271854fa44bSDimitry Andric iterator __p = lower_bound(__k); 1272854fa44bSDimitry Andric if ( __p != end() && !key_comp()(__k, __p->first)) 1273854fa44bSDimitry Andric { 1274854fa44bSDimitry Andric __p->second = _VSTD::forward<_Vp>(__v); 1275854fa44bSDimitry Andric return __p; 1276854fa44bSDimitry Andric } 1277854fa44bSDimitry Andric return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v)); 1278854fa44bSDimitry Andric } 1279854fa44bSDimitry Andric 1280854fa44bSDimitry Andric template <class _Vp> 1281854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1282854fa44bSDimitry Andric iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) 1283854fa44bSDimitry Andric { 1284854fa44bSDimitry Andric iterator __p = lower_bound(__k); 1285854fa44bSDimitry Andric if ( __p != end() && !key_comp()(__k, __p->first)) 1286854fa44bSDimitry Andric { 1287854fa44bSDimitry Andric __p->second = _VSTD::forward<_Vp>(__v); 1288854fa44bSDimitry Andric return __p; 1289854fa44bSDimitry Andric } 1290854fa44bSDimitry Andric return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)); 1291854fa44bSDimitry Andric } 12927c82a1ecSDimitry Andric 1293540d2a8bSDimitry Andric#endif // _LIBCPP_STD_VER > 14 1294854fa44bSDimitry Andric 12957a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12967a984708SDavid Chisnall iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} 12977a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 1298854fa44bSDimitry Andric iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} 1299854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 13007a984708SDavid Chisnall size_type erase(const key_type& __k) 13017a984708SDavid Chisnall {return __tree_.__erase_unique(__k);} 13027a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13037a984708SDavid Chisnall iterator erase(const_iterator __f, const_iterator __l) 13047a984708SDavid Chisnall {return __tree_.erase(__f.__i_, __l.__i_);} 13057a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13067a984708SDavid Chisnall void clear() _NOEXCEPT {__tree_.clear();} 13077a984708SDavid Chisnall 13084ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 13094ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13104ba319b5SDimitry Andric insert_return_type insert(node_type&& __nh) 13114ba319b5SDimitry Andric { 13124ba319b5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 13134ba319b5SDimitry Andric "node_type with incompatible allocator passed to map::insert()"); 13144ba319b5SDimitry Andric return __tree_.template __node_handle_insert_unique< 13154ba319b5SDimitry Andric node_type, insert_return_type>(_VSTD::move(__nh)); 13164ba319b5SDimitry Andric } 13174ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13184ba319b5SDimitry Andric iterator insert(const_iterator __hint, node_type&& __nh) 13194ba319b5SDimitry Andric { 13204ba319b5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 13214ba319b5SDimitry Andric "node_type with incompatible allocator passed to map::insert()"); 13224ba319b5SDimitry Andric return __tree_.template __node_handle_insert_unique<node_type>( 13234ba319b5SDimitry Andric __hint.__i_, _VSTD::move(__nh)); 13244ba319b5SDimitry Andric } 13254ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13264ba319b5SDimitry Andric node_type extract(key_type const& __key) 13274ba319b5SDimitry Andric { 13284ba319b5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__key); 13294ba319b5SDimitry Andric } 13304ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13314ba319b5SDimitry Andric node_type extract(const_iterator __it) 13324ba319b5SDimitry Andric { 13334ba319b5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__it.__i_); 13344ba319b5SDimitry Andric } 1335*b5893f02SDimitry Andric template <class _Compare2> 1336*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1337*b5893f02SDimitry Andric void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) 1338*b5893f02SDimitry Andric { 1339*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1340*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1341*b5893f02SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 1342*b5893f02SDimitry Andric } 1343*b5893f02SDimitry Andric template <class _Compare2> 1344*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1345*b5893f02SDimitry Andric void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) 1346*b5893f02SDimitry Andric { 1347*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1348*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1349*b5893f02SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 1350*b5893f02SDimitry Andric } 1351*b5893f02SDimitry Andric template <class _Compare2> 1352*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1353*b5893f02SDimitry Andric void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) 1354*b5893f02SDimitry Andric { 1355*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1356*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1357*b5893f02SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 1358*b5893f02SDimitry Andric } 1359*b5893f02SDimitry Andric template <class _Compare2> 1360*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1361*b5893f02SDimitry Andric void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) 1362*b5893f02SDimitry Andric { 1363*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1364*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1365*b5893f02SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 1366*b5893f02SDimitry Andric } 13674ba319b5SDimitry Andric#endif 13684ba319b5SDimitry Andric 13697a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13707a984708SDavid Chisnall void swap(map& __m) 13717a984708SDavid Chisnall _NOEXCEPT_(__is_nothrow_swappable<__base>::value) 13727a984708SDavid Chisnall {__tree_.swap(__m.__tree_);} 13737a984708SDavid Chisnall 13747a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13757a984708SDavid Chisnall iterator find(const key_type& __k) {return __tree_.find(__k);} 13767a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13777a984708SDavid Chisnall const_iterator find(const key_type& __k) const {return __tree_.find(__k);} 13784f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 13794f7ab58eSDimitry Andric template <typename _K2> 13804f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 13814f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 13824f7ab58eSDimitry Andric find(const _K2& __k) {return __tree_.find(__k);} 13834f7ab58eSDimitry Andric template <typename _K2> 13844f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 13854f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 13864f7ab58eSDimitry Andric find(const _K2& __k) const {return __tree_.find(__k);} 13874f7ab58eSDimitry Andric#endif 13884f7ab58eSDimitry Andric 13897a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13907a984708SDavid Chisnall size_type count(const key_type& __k) const 13917a984708SDavid Chisnall {return __tree_.__count_unique(__k);} 1392d72607e9SDimitry Andric#if _LIBCPP_STD_VER > 11 1393d72607e9SDimitry Andric template <typename _K2> 1394d72607e9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1395d72607e9SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type 13964ba319b5SDimitry Andric count(const _K2& __k) const {return __tree_.__count_multi(__k);} 1397d72607e9SDimitry Andric#endif 13987a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13997a984708SDavid Chisnall iterator lower_bound(const key_type& __k) 14007a984708SDavid Chisnall {return __tree_.lower_bound(__k);} 14017a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14027a984708SDavid Chisnall const_iterator lower_bound(const key_type& __k) const 14037a984708SDavid Chisnall {return __tree_.lower_bound(__k);} 14044f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 14054f7ab58eSDimitry Andric template <typename _K2> 14064f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 14074f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 14084f7ab58eSDimitry Andric lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} 14094f7ab58eSDimitry Andric 14104f7ab58eSDimitry Andric template <typename _K2> 14114f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 14124f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 14134f7ab58eSDimitry Andric lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} 14144f7ab58eSDimitry Andric#endif 14154f7ab58eSDimitry Andric 14167a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14177a984708SDavid Chisnall iterator upper_bound(const key_type& __k) 14187a984708SDavid Chisnall {return __tree_.upper_bound(__k);} 14197a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14207a984708SDavid Chisnall const_iterator upper_bound(const key_type& __k) const 14217a984708SDavid Chisnall {return __tree_.upper_bound(__k);} 14224f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 14234f7ab58eSDimitry Andric template <typename _K2> 14244f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 14254f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 14264f7ab58eSDimitry Andric upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} 14274f7ab58eSDimitry Andric template <typename _K2> 14284f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 14294f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 14304f7ab58eSDimitry Andric upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} 14314f7ab58eSDimitry Andric#endif 14324f7ab58eSDimitry Andric 14337a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14347a984708SDavid Chisnall pair<iterator,iterator> equal_range(const key_type& __k) 14357a984708SDavid Chisnall {return __tree_.__equal_range_unique(__k);} 14367a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14377a984708SDavid Chisnall pair<const_iterator,const_iterator> equal_range(const key_type& __k) const 14387a984708SDavid Chisnall {return __tree_.__equal_range_unique(__k);} 14394f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 14404f7ab58eSDimitry Andric template <typename _K2> 14414f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 14424f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type 14434ba319b5SDimitry Andric equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} 14444f7ab58eSDimitry Andric template <typename _K2> 14454f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 14464f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type 14474ba319b5SDimitry Andric equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} 14484f7ab58eSDimitry Andric#endif 14497a984708SDavid Chisnall 14507a984708SDavid Chisnallprivate: 14517a984708SDavid Chisnall typedef typename __base::__node __node; 14527a984708SDavid Chisnall typedef typename __base::__node_allocator __node_allocator; 14537a984708SDavid Chisnall typedef typename __base::__node_pointer __node_pointer; 14547a984708SDavid Chisnall typedef typename __base::__node_base_pointer __node_base_pointer; 1455aed8d94eSDimitry Andric typedef typename __base::__parent_pointer __parent_pointer; 14567c82a1ecSDimitry Andric 145794e3ee44SDavid Chisnall typedef __map_node_destructor<__node_allocator> _Dp; 145894e3ee44SDavid Chisnall typedef unique_ptr<__node, _Dp> __node_holder; 14597a984708SDavid Chisnall 14607c82a1ecSDimitry Andric#ifdef _LIBCPP_CXX03_LANG 14614bab9fd9SDavid Chisnall __node_holder __construct_node_with_key(const key_type& __k); 14627c82a1ecSDimitry Andric#endif 14637a984708SDavid Chisnall}; 14647a984708SDavid Chisnall 14657c82a1ecSDimitry Andric 14667c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 14677a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 14687a984708SDavid Chisnallmap<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) 14697c82a1ecSDimitry Andric : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a)) 14707a984708SDavid Chisnall{ 14717a984708SDavid Chisnall if (__a != __m.get_allocator()) 14727a984708SDavid Chisnall { 14737a984708SDavid Chisnall const_iterator __e = cend(); 14747a984708SDavid Chisnall while (!__m.empty()) 14757a984708SDavid Chisnall __tree_.__insert_unique(__e.__i_, 14764ba319b5SDimitry Andric __m.__tree_.remove(__m.begin().__i_)->__value_.__move()); 14777a984708SDavid Chisnall } 14787a984708SDavid Chisnall} 14797a984708SDavid Chisnall 1480540d2a8bSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1481540d2a8bSDimitry Andric_Tp& 1482540d2a8bSDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) 1483540d2a8bSDimitry Andric{ 1484540d2a8bSDimitry Andric return __tree_.__emplace_unique_key_args(__k, 1485540d2a8bSDimitry Andric _VSTD::piecewise_construct, 1486540d2a8bSDimitry Andric _VSTD::forward_as_tuple(__k), 14874ba319b5SDimitry Andric _VSTD::forward_as_tuple()).first->__get_value().second; 1488540d2a8bSDimitry Andric} 14897a984708SDavid Chisnall 1490540d2a8bSDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator> 1491540d2a8bSDimitry Andric_Tp& 1492540d2a8bSDimitry Andricmap<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) 1493540d2a8bSDimitry Andric{ 1494540d2a8bSDimitry Andric return __tree_.__emplace_unique_key_args(__k, 1495540d2a8bSDimitry Andric _VSTD::piecewise_construct, 1496540d2a8bSDimitry Andric _VSTD::forward_as_tuple(_VSTD::move(__k)), 14974ba319b5SDimitry Andric _VSTD::forward_as_tuple()).first->__get_value().second; 1498540d2a8bSDimitry Andric} 14997a984708SDavid Chisnall 1500540d2a8bSDimitry Andric#else // _LIBCPP_CXX03_LANG 15017a984708SDavid Chisnall 15027a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15037a984708SDavid Chisnalltypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder 15044bab9fd9SDavid Chisnallmap<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) 15057a984708SDavid Chisnall{ 15067a984708SDavid Chisnall __node_allocator& __na = __tree_.__node_alloc(); 150794e3ee44SDavid Chisnall __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 15084ba319b5SDimitry Andric __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k); 15097a984708SDavid Chisnall __h.get_deleter().__first_constructed = true; 15104ba319b5SDimitry Andric __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second)); 15117a984708SDavid Chisnall __h.get_deleter().__second_constructed = true; 15129729cf09SDimitry Andric return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 15137a984708SDavid Chisnall} 15147a984708SDavid Chisnall 15157a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15167a984708SDavid Chisnall_Tp& 15177a984708SDavid Chisnallmap<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) 15187a984708SDavid Chisnall{ 1519aed8d94eSDimitry Andric __parent_pointer __parent; 1520aed8d94eSDimitry Andric __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); 15217a984708SDavid Chisnall __node_pointer __r = static_cast<__node_pointer>(__child); 15227a984708SDavid Chisnall if (__child == nullptr) 15237a984708SDavid Chisnall { 15244bab9fd9SDavid Chisnall __node_holder __h = __construct_node_with_key(__k); 15254bab9fd9SDavid Chisnall __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); 15267a984708SDavid Chisnall __r = __h.release(); 15277a984708SDavid Chisnall } 15284ba319b5SDimitry Andric return __r->__value_.__get_value().second; 15297a984708SDavid Chisnall} 15307a984708SDavid Chisnall 1531540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 15327a984708SDavid Chisnall 15337a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15347a984708SDavid Chisnall_Tp& 15357a984708SDavid Chisnallmap<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) 15367a984708SDavid Chisnall{ 1537aed8d94eSDimitry Andric __parent_pointer __parent; 1538aed8d94eSDimitry Andric __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); 15397a984708SDavid Chisnall#ifndef _LIBCPP_NO_EXCEPTIONS 15407a984708SDavid Chisnall if (__child == nullptr) 15417a984708SDavid Chisnall throw out_of_range("map::at: key not found"); 15427a984708SDavid Chisnall#endif // _LIBCPP_NO_EXCEPTIONS 15434ba319b5SDimitry Andric return static_cast<__node_pointer>(__child)->__value_.__get_value().second; 15447a984708SDavid Chisnall} 15457a984708SDavid Chisnall 15467a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15477a984708SDavid Chisnallconst _Tp& 15487a984708SDavid Chisnallmap<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const 15497a984708SDavid Chisnall{ 1550aed8d94eSDimitry Andric __parent_pointer __parent; 1551aed8d94eSDimitry Andric __node_base_pointer __child = __tree_.__find_equal(__parent, __k); 15527a984708SDavid Chisnall#ifndef _LIBCPP_NO_EXCEPTIONS 15537a984708SDavid Chisnall if (__child == nullptr) 15547a984708SDavid Chisnall throw out_of_range("map::at: key not found"); 15557a984708SDavid Chisnall#endif // _LIBCPP_NO_EXCEPTIONS 15564ba319b5SDimitry Andric return static_cast<__node_pointer>(__child)->__value_.__get_value().second; 15577a984708SDavid Chisnall} 15587a984708SDavid Chisnall 15597a984708SDavid Chisnall 15607a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15617a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 15627a984708SDavid Chisnallbool 15637a984708SDavid Chisnalloperator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, 15647a984708SDavid Chisnall const map<_Key, _Tp, _Compare, _Allocator>& __y) 15657a984708SDavid Chisnall{ 15667a984708SDavid Chisnall return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); 15677a984708SDavid Chisnall} 15687a984708SDavid Chisnall 15697a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15707a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 15717a984708SDavid Chisnallbool 15727a984708SDavid Chisnalloperator< (const map<_Key, _Tp, _Compare, _Allocator>& __x, 15737a984708SDavid Chisnall const map<_Key, _Tp, _Compare, _Allocator>& __y) 15747a984708SDavid Chisnall{ 15757a984708SDavid Chisnall return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 15767a984708SDavid Chisnall} 15777a984708SDavid Chisnall 15787a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15797a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 15807a984708SDavid Chisnallbool 15817a984708SDavid Chisnalloperator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x, 15827a984708SDavid Chisnall const map<_Key, _Tp, _Compare, _Allocator>& __y) 15837a984708SDavid Chisnall{ 15847a984708SDavid Chisnall return !(__x == __y); 15857a984708SDavid Chisnall} 15867a984708SDavid Chisnall 15877a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15887a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 15897a984708SDavid Chisnallbool 15907a984708SDavid Chisnalloperator> (const map<_Key, _Tp, _Compare, _Allocator>& __x, 15917a984708SDavid Chisnall const map<_Key, _Tp, _Compare, _Allocator>& __y) 15927a984708SDavid Chisnall{ 15937a984708SDavid Chisnall return __y < __x; 15947a984708SDavid Chisnall} 15957a984708SDavid Chisnall 15967a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 15977a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 15987a984708SDavid Chisnallbool 15997a984708SDavid Chisnalloperator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x, 16007a984708SDavid Chisnall const map<_Key, _Tp, _Compare, _Allocator>& __y) 16017a984708SDavid Chisnall{ 16027a984708SDavid Chisnall return !(__x < __y); 16037a984708SDavid Chisnall} 16047a984708SDavid Chisnall 16057a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16067a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 16077a984708SDavid Chisnallbool 16087a984708SDavid Chisnalloperator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, 16097a984708SDavid Chisnall const map<_Key, _Tp, _Compare, _Allocator>& __y) 16107a984708SDavid Chisnall{ 16117a984708SDavid Chisnall return !(__y < __x); 16127a984708SDavid Chisnall} 16137a984708SDavid Chisnall 16147a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 16157a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 16167a984708SDavid Chisnallvoid 16177a984708SDavid Chisnallswap(map<_Key, _Tp, _Compare, _Allocator>& __x, 16187a984708SDavid Chisnall map<_Key, _Tp, _Compare, _Allocator>& __y) 16197a984708SDavid Chisnall _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 16207a984708SDavid Chisnall{ 16217a984708SDavid Chisnall __x.swap(__y); 16227a984708SDavid Chisnall} 16237a984708SDavid Chisnall 1624*b5893f02SDimitry Andric#if _LIBCPP_STD_VER > 17 1625*b5893f02SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate> 1626*b5893f02SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1627*b5893f02SDimitry Andricvoid erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) 1628*b5893f02SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); } 1629*b5893f02SDimitry Andric#endif 1630*b5893f02SDimitry Andric 1631*b5893f02SDimitry Andric 16327a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare = less<_Key>, 16337a984708SDavid Chisnall class _Allocator = allocator<pair<const _Key, _Tp> > > 1634aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS multimap 16357a984708SDavid Chisnall{ 16367a984708SDavid Chisnallpublic: 16377a984708SDavid Chisnall // types: 16387a984708SDavid Chisnall typedef _Key key_type; 16397a984708SDavid Chisnall typedef _Tp mapped_type; 16407a984708SDavid Chisnall typedef pair<const key_type, mapped_type> value_type; 16417a984708SDavid Chisnall typedef _Compare key_compare; 16427a984708SDavid Chisnall typedef _Allocator allocator_type; 16437a984708SDavid Chisnall typedef value_type& reference; 16447a984708SDavid Chisnall typedef const value_type& const_reference; 16457a984708SDavid Chisnall 1646*b5893f02SDimitry Andric static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); 16479729cf09SDimitry Andric static_assert((is_same<typename allocator_type::value_type, value_type>::value), 16489729cf09SDimitry Andric "Allocator::value_type must be same type as value_type"); 16499729cf09SDimitry Andric 1650aed8d94eSDimitry Andric class _LIBCPP_TEMPLATE_VIS value_compare 16517a984708SDavid Chisnall : public binary_function<value_type, value_type, bool> 16527a984708SDavid Chisnall { 16537a984708SDavid Chisnall friend class multimap; 16547a984708SDavid Chisnall protected: 16557a984708SDavid Chisnall key_compare comp; 16567a984708SDavid Chisnall 16577a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 16587a984708SDavid Chisnall value_compare(key_compare c) : comp(c) {} 16597a984708SDavid Chisnall public: 16607a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 16617a984708SDavid Chisnall bool operator()(const value_type& __x, const value_type& __y) const 16627a984708SDavid Chisnall {return comp(__x.first, __y.first);} 16637a984708SDavid Chisnall }; 16647a984708SDavid Chisnall 16657a984708SDavid Chisnallprivate: 16664bab9fd9SDavid Chisnall 16674f7ab58eSDimitry Andric typedef _VSTD::__value_type<key_type, mapped_type> __value_type; 16684bab9fd9SDavid Chisnall typedef __map_value_compare<key_type, __value_type, key_compare> __vc; 1669854fa44bSDimitry Andric typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, 1670854fa44bSDimitry Andric __value_type>::type __allocator_type; 16717a984708SDavid Chisnall typedef __tree<__value_type, __vc, __allocator_type> __base; 16727a984708SDavid Chisnall typedef typename __base::__node_traits __node_traits; 16737a984708SDavid Chisnall typedef allocator_traits<allocator_type> __alloc_traits; 16747a984708SDavid Chisnall 16757a984708SDavid Chisnall __base __tree_; 16767a984708SDavid Chisnall 16777a984708SDavid Chisnallpublic: 16787a984708SDavid Chisnall typedef typename __alloc_traits::pointer pointer; 16797a984708SDavid Chisnall typedef typename __alloc_traits::const_pointer const_pointer; 16807a984708SDavid Chisnall typedef typename __alloc_traits::size_type size_type; 16817a984708SDavid Chisnall typedef typename __alloc_traits::difference_type difference_type; 16827a984708SDavid Chisnall typedef __map_iterator<typename __base::iterator> iterator; 16837a984708SDavid Chisnall typedef __map_const_iterator<typename __base::const_iterator> const_iterator; 16847a984708SDavid Chisnall typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 16857a984708SDavid Chisnall typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 16867a984708SDavid Chisnall 16874ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 16884ba319b5SDimitry Andric typedef __map_node_handle<typename __base::__node, allocator_type> node_type; 16894ba319b5SDimitry Andric#endif 16904ba319b5SDimitry Andric 1691*b5893f02SDimitry Andric template <class _Key2, class _Value2, class _Comp2, class _Alloc2> 1692*b5893f02SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS map; 1693*b5893f02SDimitry Andric template <class _Key2, class _Value2, class _Comp2, class _Alloc2> 1694*b5893f02SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multimap; 1695*b5893f02SDimitry Andric 16967a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 1697d72607e9SDimitry Andric multimap() 16987a984708SDavid Chisnall _NOEXCEPT_( 16997a984708SDavid Chisnall is_nothrow_default_constructible<allocator_type>::value && 17007a984708SDavid Chisnall is_nothrow_default_constructible<key_compare>::value && 17017a984708SDavid Chisnall is_nothrow_copy_constructible<key_compare>::value) 1702d72607e9SDimitry Andric : __tree_(__vc(key_compare())) {} 1703d72607e9SDimitry Andric 1704d72607e9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1705d72607e9SDimitry Andric explicit multimap(const key_compare& __comp) 1706d72607e9SDimitry Andric _NOEXCEPT_( 1707d72607e9SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 1708d72607e9SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 17097a984708SDavid Chisnall : __tree_(__vc(__comp)) {} 17107a984708SDavid Chisnall 17117a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17127a984708SDavid Chisnall explicit multimap(const key_compare& __comp, const allocator_type& __a) 17137c82a1ecSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {} 17147a984708SDavid Chisnall 17157a984708SDavid Chisnall template <class _InputIterator> 17167a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17177a984708SDavid Chisnall multimap(_InputIterator __f, _InputIterator __l, 17187a984708SDavid Chisnall const key_compare& __comp = key_compare()) 17197a984708SDavid Chisnall : __tree_(__vc(__comp)) 17207a984708SDavid Chisnall { 17217a984708SDavid Chisnall insert(__f, __l); 17227a984708SDavid Chisnall } 17237a984708SDavid Chisnall 17247a984708SDavid Chisnall template <class _InputIterator> 17257a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17267a984708SDavid Chisnall multimap(_InputIterator __f, _InputIterator __l, 17277a984708SDavid Chisnall const key_compare& __comp, const allocator_type& __a) 17287c82a1ecSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) 17297a984708SDavid Chisnall { 17307a984708SDavid Chisnall insert(__f, __l); 17317a984708SDavid Chisnall } 17327a984708SDavid Chisnall 17334f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 17344f7ab58eSDimitry Andric template <class _InputIterator> 17354f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17364f7ab58eSDimitry Andric multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) 17374f7ab58eSDimitry Andric : multimap(__f, __l, key_compare(), __a) {} 17384f7ab58eSDimitry Andric#endif 17394f7ab58eSDimitry Andric 17407a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17417a984708SDavid Chisnall multimap(const multimap& __m) 17427a984708SDavid Chisnall : __tree_(__m.__tree_.value_comp(), 17437a984708SDavid Chisnall __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc())) 17447a984708SDavid Chisnall { 17457a984708SDavid Chisnall insert(__m.begin(), __m.end()); 17467a984708SDavid Chisnall } 17477a984708SDavid Chisnall 17487a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17497a984708SDavid Chisnall multimap& operator=(const multimap& __m) 17507a984708SDavid Chisnall { 17517c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 17527a984708SDavid Chisnall __tree_ = __m.__tree_; 17534bab9fd9SDavid Chisnall#else 1754a0492a11SDimitry Andric if (this != &__m) { 17554bab9fd9SDavid Chisnall __tree_.clear(); 17564bab9fd9SDavid Chisnall __tree_.value_comp() = __m.__tree_.value_comp(); 17574bab9fd9SDavid Chisnall __tree_.__copy_assign_alloc(__m.__tree_); 17584bab9fd9SDavid Chisnall insert(__m.begin(), __m.end()); 1759a0492a11SDimitry Andric } 17604bab9fd9SDavid Chisnall#endif 17617a984708SDavid Chisnall return *this; 17627a984708SDavid Chisnall } 17637a984708SDavid Chisnall 1764540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 17657a984708SDavid Chisnall 17667a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17677a984708SDavid Chisnall multimap(multimap&& __m) 17687a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) 17697a984708SDavid Chisnall : __tree_(_VSTD::move(__m.__tree_)) 17707a984708SDavid Chisnall { 17717a984708SDavid Chisnall } 17727a984708SDavid Chisnall 17737a984708SDavid Chisnall multimap(multimap&& __m, const allocator_type& __a); 17747a984708SDavid Chisnall 17757a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17767a984708SDavid Chisnall multimap& operator=(multimap&& __m) 17777a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) 17787a984708SDavid Chisnall { 17797a984708SDavid Chisnall __tree_ = _VSTD::move(__m.__tree_); 17807a984708SDavid Chisnall return *this; 17817a984708SDavid Chisnall } 17827a984708SDavid Chisnall 17837a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17847a984708SDavid Chisnall multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) 17857a984708SDavid Chisnall : __tree_(__vc(__comp)) 17867a984708SDavid Chisnall { 17877a984708SDavid Chisnall insert(__il.begin(), __il.end()); 17887a984708SDavid Chisnall } 17897a984708SDavid Chisnall 17907a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17917a984708SDavid Chisnall multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) 17927c82a1ecSDimitry Andric : __tree_(__vc(__comp), typename __base::allocator_type(__a)) 17937a984708SDavid Chisnall { 17947a984708SDavid Chisnall insert(__il.begin(), __il.end()); 17957a984708SDavid Chisnall } 17967a984708SDavid Chisnall 17974f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 17984f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17994f7ab58eSDimitry Andric multimap(initializer_list<value_type> __il, const allocator_type& __a) 18004f7ab58eSDimitry Andric : multimap(__il, key_compare(), __a) {} 18014f7ab58eSDimitry Andric#endif 18024f7ab58eSDimitry Andric 18037a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18047a984708SDavid Chisnall multimap& operator=(initializer_list<value_type> __il) 18057a984708SDavid Chisnall { 18067a984708SDavid Chisnall __tree_.__assign_multi(__il.begin(), __il.end()); 18077a984708SDavid Chisnall return *this; 18087a984708SDavid Chisnall } 18097a984708SDavid Chisnall 1810540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 18117a984708SDavid Chisnall 18127a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18137a984708SDavid Chisnall explicit multimap(const allocator_type& __a) 18147c82a1ecSDimitry Andric : __tree_(typename __base::allocator_type(__a)) 18157a984708SDavid Chisnall { 18167a984708SDavid Chisnall } 18177a984708SDavid Chisnall 18187a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18197a984708SDavid Chisnall multimap(const multimap& __m, const allocator_type& __a) 18207c82a1ecSDimitry Andric : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) 18217a984708SDavid Chisnall { 18227a984708SDavid Chisnall insert(__m.begin(), __m.end()); 18237a984708SDavid Chisnall } 18247a984708SDavid Chisnall 18257a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18267a984708SDavid Chisnall iterator begin() _NOEXCEPT {return __tree_.begin();} 18277a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18287a984708SDavid Chisnall const_iterator begin() const _NOEXCEPT {return __tree_.begin();} 18297a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18307a984708SDavid Chisnall iterator end() _NOEXCEPT {return __tree_.end();} 18317a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18327a984708SDavid Chisnall const_iterator end() const _NOEXCEPT {return __tree_.end();} 18337a984708SDavid Chisnall 18347a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18357a984708SDavid Chisnall reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} 18367a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18377a984708SDavid Chisnall const_reverse_iterator rbegin() const _NOEXCEPT 18387a984708SDavid Chisnall {return const_reverse_iterator(end());} 18397a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18407a984708SDavid Chisnall reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} 18417a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18427a984708SDavid Chisnall const_reverse_iterator rend() const _NOEXCEPT 18437a984708SDavid Chisnall {return const_reverse_iterator(begin());} 18447a984708SDavid Chisnall 18457a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18467a984708SDavid Chisnall const_iterator cbegin() const _NOEXCEPT {return begin();} 18477a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18487a984708SDavid Chisnall const_iterator cend() const _NOEXCEPT {return end();} 18497a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18507a984708SDavid Chisnall const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 18517a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18527a984708SDavid Chisnall const_reverse_iterator crend() const _NOEXCEPT {return rend();} 18537a984708SDavid Chisnall 1854b2c7081bSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 18557a984708SDavid Chisnall bool empty() const _NOEXCEPT {return __tree_.size() == 0;} 18567a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18577a984708SDavid Chisnall size_type size() const _NOEXCEPT {return __tree_.size();} 18587a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18597a984708SDavid Chisnall size_type max_size() const _NOEXCEPT {return __tree_.max_size();} 18607a984708SDavid Chisnall 18617a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18627c82a1ecSDimitry Andric allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());} 18637a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18647a984708SDavid Chisnall key_compare key_comp() const {return __tree_.value_comp().key_comp();} 18657a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18667a984708SDavid Chisnall value_compare value_comp() const 18677a984708SDavid Chisnall {return value_compare(__tree_.value_comp().key_comp());} 18687a984708SDavid Chisnall 18697c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 18707a984708SDavid Chisnall 1871936e9439SDimitry Andric template <class ..._Args> 18727c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18737c82a1ecSDimitry Andric iterator emplace(_Args&& ...__args) { 18747c82a1ecSDimitry Andric return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...); 18757c82a1ecSDimitry Andric } 18767a984708SDavid Chisnall 1877936e9439SDimitry Andric template <class ..._Args> 18787c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18797c82a1ecSDimitry Andric iterator emplace_hint(const_iterator __p, _Args&& ...__args) { 18807c82a1ecSDimitry Andric return __tree_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...); 18817c82a1ecSDimitry Andric } 18827a984708SDavid Chisnall 188394e3ee44SDavid Chisnall template <class _Pp, 188494e3ee44SDavid Chisnall class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 18857a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 188694e3ee44SDavid Chisnall iterator insert(_Pp&& __p) 188794e3ee44SDavid Chisnall {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));} 18887a984708SDavid Chisnall 188994e3ee44SDavid Chisnall template <class _Pp, 189094e3ee44SDavid Chisnall class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 18917a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 189294e3ee44SDavid Chisnall iterator insert(const_iterator __pos, _Pp&& __p) 189394e3ee44SDavid Chisnall {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));} 18947a984708SDavid Chisnall 18957c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18967c82a1ecSDimitry Andric iterator insert(value_type&& __v) 18977c82a1ecSDimitry Andric {return __tree_.__insert_multi(_VSTD::move(__v));} 18987c82a1ecSDimitry Andric 18997c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 19007c82a1ecSDimitry Andric iterator insert(const_iterator __p, value_type&& __v) 19017c82a1ecSDimitry Andric {return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));} 19027c82a1ecSDimitry Andric 1903540d2a8bSDimitry Andric 1904540d2a8bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1905540d2a8bSDimitry Andric void insert(initializer_list<value_type> __il) 1906540d2a8bSDimitry Andric {insert(__il.begin(), __il.end());} 1907540d2a8bSDimitry Andric 19087c82a1ecSDimitry Andric#endif // _LIBCPP_CXX03_LANG 19097a984708SDavid Chisnall 19107a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19117a984708SDavid Chisnall iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);} 19127a984708SDavid Chisnall 19137a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19147a984708SDavid Chisnall iterator insert(const_iterator __p, const value_type& __v) 19157a984708SDavid Chisnall {return __tree_.__insert_multi(__p.__i_, __v);} 19167a984708SDavid Chisnall 19177a984708SDavid Chisnall template <class _InputIterator> 19187a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19197a984708SDavid Chisnall void insert(_InputIterator __f, _InputIterator __l) 19207a984708SDavid Chisnall { 19217a984708SDavid Chisnall for (const_iterator __e = cend(); __f != __l; ++__f) 19227a984708SDavid Chisnall __tree_.__insert_multi(__e.__i_, *__f); 19237a984708SDavid Chisnall } 19247a984708SDavid Chisnall 19257a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19267a984708SDavid Chisnall iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} 19277a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 1928854fa44bSDimitry Andric iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} 1929854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 19307a984708SDavid Chisnall size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} 19317a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19327a984708SDavid Chisnall iterator erase(const_iterator __f, const_iterator __l) 19337a984708SDavid Chisnall {return __tree_.erase(__f.__i_, __l.__i_);} 19344ba319b5SDimitry Andric 19354ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 19364ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 19374ba319b5SDimitry Andric iterator insert(node_type&& __nh) 19384ba319b5SDimitry Andric { 19394ba319b5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 19404ba319b5SDimitry Andric "node_type with incompatible allocator passed to multimap::insert()"); 19414ba319b5SDimitry Andric return __tree_.template __node_handle_insert_multi<node_type>( 19424ba319b5SDimitry Andric _VSTD::move(__nh)); 19434ba319b5SDimitry Andric } 19444ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 19454ba319b5SDimitry Andric iterator insert(const_iterator __hint, node_type&& __nh) 19464ba319b5SDimitry Andric { 19474ba319b5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 19484ba319b5SDimitry Andric "node_type with incompatible allocator passed to multimap::insert()"); 19494ba319b5SDimitry Andric return __tree_.template __node_handle_insert_multi<node_type>( 19504ba319b5SDimitry Andric __hint.__i_, _VSTD::move(__nh)); 19514ba319b5SDimitry Andric } 19524ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 19534ba319b5SDimitry Andric node_type extract(key_type const& __key) 19544ba319b5SDimitry Andric { 19554ba319b5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__key); 19564ba319b5SDimitry Andric } 19574ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 19584ba319b5SDimitry Andric node_type extract(const_iterator __it) 19594ba319b5SDimitry Andric { 19604ba319b5SDimitry Andric return __tree_.template __node_handle_extract<node_type>( 19614ba319b5SDimitry Andric __it.__i_); 19624ba319b5SDimitry Andric } 1963*b5893f02SDimitry Andric template <class _Compare2> 1964*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1965*b5893f02SDimitry Andric void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) 1966*b5893f02SDimitry Andric { 1967*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1968*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1969*b5893f02SDimitry Andric return __tree_.__node_handle_merge_multi(__source.__tree_); 1970*b5893f02SDimitry Andric } 1971*b5893f02SDimitry Andric template <class _Compare2> 1972*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1973*b5893f02SDimitry Andric void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) 1974*b5893f02SDimitry Andric { 1975*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1976*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1977*b5893f02SDimitry Andric return __tree_.__node_handle_merge_multi(__source.__tree_); 1978*b5893f02SDimitry Andric } 1979*b5893f02SDimitry Andric template <class _Compare2> 1980*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1981*b5893f02SDimitry Andric void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) 1982*b5893f02SDimitry Andric { 1983*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1984*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1985*b5893f02SDimitry Andric return __tree_.__node_handle_merge_multi(__source.__tree_); 1986*b5893f02SDimitry Andric } 1987*b5893f02SDimitry Andric template <class _Compare2> 1988*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1989*b5893f02SDimitry Andric void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) 1990*b5893f02SDimitry Andric { 1991*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1992*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1993*b5893f02SDimitry Andric return __tree_.__node_handle_merge_multi(__source.__tree_); 1994*b5893f02SDimitry Andric } 19954ba319b5SDimitry Andric#endif 19964ba319b5SDimitry Andric 19977a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 1998*b5893f02SDimitry Andric void clear() _NOEXCEPT {__tree_.clear();} 19997a984708SDavid Chisnall 20007a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20017a984708SDavid Chisnall void swap(multimap& __m) 20027a984708SDavid Chisnall _NOEXCEPT_(__is_nothrow_swappable<__base>::value) 20037a984708SDavid Chisnall {__tree_.swap(__m.__tree_);} 20047a984708SDavid Chisnall 20057a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20067a984708SDavid Chisnall iterator find(const key_type& __k) {return __tree_.find(__k);} 20077a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20087a984708SDavid Chisnall const_iterator find(const key_type& __k) const {return __tree_.find(__k);} 20094f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 20104f7ab58eSDimitry Andric template <typename _K2> 20114f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 20124f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 20134f7ab58eSDimitry Andric find(const _K2& __k) {return __tree_.find(__k);} 20144f7ab58eSDimitry Andric template <typename _K2> 20154f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 20164f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 20174f7ab58eSDimitry Andric find(const _K2& __k) const {return __tree_.find(__k);} 20184f7ab58eSDimitry Andric#endif 20194f7ab58eSDimitry Andric 20207a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20217a984708SDavid Chisnall size_type count(const key_type& __k) const 20227a984708SDavid Chisnall {return __tree_.__count_multi(__k);} 2023d72607e9SDimitry Andric#if _LIBCPP_STD_VER > 11 2024d72607e9SDimitry Andric template <typename _K2> 2025d72607e9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2026d72607e9SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type 2027854fa44bSDimitry Andric count(const _K2& __k) const {return __tree_.__count_multi(__k);} 2028d72607e9SDimitry Andric#endif 20297a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20307a984708SDavid Chisnall iterator lower_bound(const key_type& __k) 20317a984708SDavid Chisnall {return __tree_.lower_bound(__k);} 20327a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20337a984708SDavid Chisnall const_iterator lower_bound(const key_type& __k) const 20347a984708SDavid Chisnall {return __tree_.lower_bound(__k);} 20354f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 20364f7ab58eSDimitry Andric template <typename _K2> 20374f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 20384f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 20394f7ab58eSDimitry Andric lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} 20404f7ab58eSDimitry Andric 20414f7ab58eSDimitry Andric template <typename _K2> 20424f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 20434f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 20444f7ab58eSDimitry Andric lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} 20454f7ab58eSDimitry Andric#endif 20464f7ab58eSDimitry Andric 20477a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20487a984708SDavid Chisnall iterator upper_bound(const key_type& __k) 20497a984708SDavid Chisnall {return __tree_.upper_bound(__k);} 20507a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20517a984708SDavid Chisnall const_iterator upper_bound(const key_type& __k) const 20527a984708SDavid Chisnall {return __tree_.upper_bound(__k);} 20534f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 20544f7ab58eSDimitry Andric template <typename _K2> 20554f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 20564f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 20574f7ab58eSDimitry Andric upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} 20584f7ab58eSDimitry Andric template <typename _K2> 20594f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 20604f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 20614f7ab58eSDimitry Andric upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} 20624f7ab58eSDimitry Andric#endif 20634f7ab58eSDimitry Andric 20647a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20657a984708SDavid Chisnall pair<iterator,iterator> equal_range(const key_type& __k) 20667a984708SDavid Chisnall {return __tree_.__equal_range_multi(__k);} 20677a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20687a984708SDavid Chisnall pair<const_iterator,const_iterator> equal_range(const key_type& __k) const 20697a984708SDavid Chisnall {return __tree_.__equal_range_multi(__k);} 20704f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 20714f7ab58eSDimitry Andric template <typename _K2> 20724f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 20734f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type 20744f7ab58eSDimitry Andric equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} 20754f7ab58eSDimitry Andric template <typename _K2> 20764f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 20774f7ab58eSDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type 20784f7ab58eSDimitry Andric equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} 20794f7ab58eSDimitry Andric#endif 20807a984708SDavid Chisnall 20817a984708SDavid Chisnallprivate: 20827a984708SDavid Chisnall typedef typename __base::__node __node; 20837a984708SDavid Chisnall typedef typename __base::__node_allocator __node_allocator; 20847a984708SDavid Chisnall typedef typename __base::__node_pointer __node_pointer; 20857c82a1ecSDimitry Andric 208694e3ee44SDavid Chisnall typedef __map_node_destructor<__node_allocator> _Dp; 208794e3ee44SDavid Chisnall typedef unique_ptr<__node, _Dp> __node_holder; 20887a984708SDavid Chisnall}; 20897a984708SDavid Chisnall 20907c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 20917a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 20927a984708SDavid Chisnallmultimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a) 20937c82a1ecSDimitry Andric : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a)) 20947a984708SDavid Chisnall{ 20957a984708SDavid Chisnall if (__a != __m.get_allocator()) 20967a984708SDavid Chisnall { 20977a984708SDavid Chisnall const_iterator __e = cend(); 20987a984708SDavid Chisnall while (!__m.empty()) 20997a984708SDavid Chisnall __tree_.__insert_multi(__e.__i_, 21004ba319b5SDimitry Andric _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move())); 21017a984708SDavid Chisnall } 21027a984708SDavid Chisnall} 21037c82a1ecSDimitry Andric#endif 21047a984708SDavid Chisnall 21057a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21067a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 21077a984708SDavid Chisnallbool 21087a984708SDavid Chisnalloperator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21097a984708SDavid Chisnall const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21107a984708SDavid Chisnall{ 21117a984708SDavid Chisnall return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); 21127a984708SDavid Chisnall} 21137a984708SDavid Chisnall 21147a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21157a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 21167a984708SDavid Chisnallbool 21177a984708SDavid Chisnalloperator< (const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21187a984708SDavid Chisnall const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21197a984708SDavid Chisnall{ 21207a984708SDavid Chisnall return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 21217a984708SDavid Chisnall} 21227a984708SDavid Chisnall 21237a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21247a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 21257a984708SDavid Chisnallbool 21267a984708SDavid Chisnalloperator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21277a984708SDavid Chisnall const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21287a984708SDavid Chisnall{ 21297a984708SDavid Chisnall return !(__x == __y); 21307a984708SDavid Chisnall} 21317a984708SDavid Chisnall 21327a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21337a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 21347a984708SDavid Chisnallbool 21357a984708SDavid Chisnalloperator> (const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21367a984708SDavid Chisnall const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21377a984708SDavid Chisnall{ 21387a984708SDavid Chisnall return __y < __x; 21397a984708SDavid Chisnall} 21407a984708SDavid Chisnall 21417a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21427a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 21437a984708SDavid Chisnallbool 21447a984708SDavid Chisnalloperator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21457a984708SDavid Chisnall const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21467a984708SDavid Chisnall{ 21477a984708SDavid Chisnall return !(__x < __y); 21487a984708SDavid Chisnall} 21497a984708SDavid Chisnall 21507a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21517a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 21527a984708SDavid Chisnallbool 21537a984708SDavid Chisnalloperator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21547a984708SDavid Chisnall const multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21557a984708SDavid Chisnall{ 21567a984708SDavid Chisnall return !(__y < __x); 21577a984708SDavid Chisnall} 21587a984708SDavid Chisnall 21597a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Compare, class _Allocator> 21607a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 21617a984708SDavid Chisnallvoid 21627a984708SDavid Chisnallswap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, 21637a984708SDavid Chisnall multimap<_Key, _Tp, _Compare, _Allocator>& __y) 21647a984708SDavid Chisnall _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 21657a984708SDavid Chisnall{ 21667a984708SDavid Chisnall __x.swap(__y); 21677a984708SDavid Chisnall} 21687a984708SDavid Chisnall 2169*b5893f02SDimitry Andric#if _LIBCPP_STD_VER > 17 2170*b5893f02SDimitry Andrictemplate <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate> 2171*b5893f02SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 2172*b5893f02SDimitry Andricvoid erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) 2173*b5893f02SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); } 2174*b5893f02SDimitry Andric#endif 2175*b5893f02SDimitry Andric 21767a984708SDavid Chisnall_LIBCPP_END_NAMESPACE_STD 21777a984708SDavid Chisnall 21787a984708SDavid Chisnall#endif // _LIBCPP_MAP 2179