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