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