Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 9bd9388 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_MAP |
| 11 | #define _LIBCPP_MAP |
| 12 | |
| 13 | /* |
| 14 | |
| 15 | map synopsis |
| 16 | |
| 17 | namespace std |
| 18 | { |
| 19 | |
| 20 | template <class Key, class T, class Compare = less<Key>, |
| 21 | class Allocator = allocator<pair<const Key, T>>> |
| 22 | class map |
| 23 | { |
| 24 | public: |
| 25 | // types: |
| 26 | typedef Key key_type; |
| 27 | typedef T mapped_type; |
| 28 | typedef pair<const key_type, mapped_type> value_type; |
| 29 | typedef Compare key_compare; |
| 30 | typedef Allocator allocator_type; |
| 31 | typedef typename allocator_type::reference reference; |
| 32 | typedef typename allocator_type::const_reference const_reference; |
| 33 | typedef typename allocator_type::pointer pointer; |
| 34 | typedef typename allocator_type::const_pointer const_pointer; |
| 35 | typedef typename allocator_type::size_type size_type; |
| 36 | typedef typename allocator_type::difference_type difference_type; |
| 37 | |
| 38 | typedef implementation-defined iterator; |
| 39 | typedef implementation-defined const_iterator; |
| 40 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 41 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 42 | typedef unspecified node_type; // C++17 |
| 43 | typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 44 | |
| 45 | class value_compare |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 46 | { |
| 47 | friend class map; |
| 48 | protected: |
| 49 | key_compare comp; |
| 50 | |
| 51 | value_compare(key_compare c); |
| 52 | public: |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 53 | typedef bool result_type; // deprecated in C++17, removed in C++20 |
| 54 | typedef value_type first_argument_type; // deprecated in C++17, removed in C++20 |
| 55 | typedef value_type second_argument_type; // deprecated in C++17, removed in C++20 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 56 | bool operator()(const value_type& x, const value_type& y) const; |
| 57 | }; |
| 58 | |
| 59 | // construct/copy/destroy: |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 60 | map() |
| 61 | noexcept( |
| 62 | is_nothrow_default_constructible<allocator_type>::value && |
| 63 | is_nothrow_default_constructible<key_compare>::value && |
| 64 | is_nothrow_copy_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 65 | explicit map(const key_compare& comp); |
| 66 | map(const key_compare& comp, const allocator_type& a); |
| 67 | template <class InputIterator> |
| 68 | map(InputIterator first, InputIterator last, |
| 69 | const key_compare& comp = key_compare()); |
| 70 | template <class InputIterator> |
| 71 | map(InputIterator first, InputIterator last, |
| 72 | const key_compare& comp, const allocator_type& a); |
| 73 | map(const map& m); |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 74 | map(map&& m) |
| 75 | noexcept( |
| 76 | is_nothrow_move_constructible<allocator_type>::value && |
| 77 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 78 | explicit map(const allocator_type& a); |
| 79 | map(const map& m, const allocator_type& a); |
| 80 | map(map&& m, const allocator_type& a); |
| 81 | map(initializer_list<value_type> il, const key_compare& comp = key_compare()); |
| 82 | map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 83 | template <class InputIterator> |
| 84 | map(InputIterator first, InputIterator last, const allocator_type& a) |
| 85 | : map(first, last, Compare(), a) {} // C++14 |
| 86 | map(initializer_list<value_type> il, const allocator_type& a) |
| 87 | : map(il, Compare(), a) {} // C++14 |
| 88 | ~map(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 89 | |
| 90 | map& operator=(const map& m); |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 91 | map& operator=(map&& m) |
| 92 | noexcept( |
| 93 | allocator_type::propagate_on_container_move_assignment::value && |
| 94 | is_nothrow_move_assignable<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 95 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 96 | map& operator=(initializer_list<value_type> il); |
| 97 | |
| 98 | // iterators: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 99 | iterator begin() noexcept; |
| 100 | const_iterator begin() const noexcept; |
| 101 | iterator end() noexcept; |
| 102 | const_iterator end() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 103 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 104 | reverse_iterator rbegin() noexcept; |
| 105 | const_reverse_iterator rbegin() const noexcept; |
| 106 | reverse_iterator rend() noexcept; |
| 107 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 108 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 109 | const_iterator cbegin() const noexcept; |
| 110 | const_iterator cend() const noexcept; |
| 111 | const_reverse_iterator crbegin() const noexcept; |
| 112 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 113 | |
| 114 | // capacity: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 115 | bool empty() const noexcept; |
| 116 | size_type size() const noexcept; |
| 117 | size_type max_size() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 118 | |
| 119 | // element access: |
| 120 | mapped_type& operator[](const key_type& k); |
| 121 | mapped_type& operator[](key_type&& k); |
| 122 | |
| 123 | mapped_type& at(const key_type& k); |
| 124 | const mapped_type& at(const key_type& k) const; |
| 125 | |
| 126 | // modifiers: |
| 127 | template <class... Args> |
| 128 | pair<iterator, bool> emplace(Args&&... args); |
| 129 | template <class... Args> |
| 130 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 131 | pair<iterator, bool> insert(const value_type& v); |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 132 | pair<iterator, bool> insert( value_type&& v); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 133 | template <class P> |
| 134 | pair<iterator, bool> insert(P&& p); |
| 135 | iterator insert(const_iterator position, const value_type& v); |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 136 | iterator insert(const_iterator position, value_type&& v); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 137 | template <class P> |
| 138 | iterator insert(const_iterator position, P&& p); |
| 139 | template <class InputIterator> |
| 140 | void insert(InputIterator first, InputIterator last); |
| 141 | void insert(initializer_list<value_type> il); |
| 142 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 143 | node_type extract(const_iterator position); // C++17 |
| 144 | node_type extract(const key_type& x); // C++17 |
| 145 | insert_return_type insert(node_type&& nh); // C++17 |
| 146 | iterator insert(const_iterator hint, node_type&& nh); // C++17 |
| 147 | |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 148 | template <class... Args> |
| 149 | pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17 |
| 150 | template <class... Args> |
| 151 | pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17 |
| 152 | template <class... Args> |
| 153 | iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 |
| 154 | template <class... Args> |
| 155 | iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 |
| 156 | template <class M> |
| 157 | pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17 |
| 158 | template <class M> |
| 159 | pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17 |
| 160 | template <class M> |
| 161 | iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 |
| 162 | template <class M> |
| 163 | iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 |
| 164 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 165 | iterator erase(const_iterator position); |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 166 | iterator erase(iterator position); // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 167 | size_type erase(const key_type& k); |
| 168 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 169 | void clear() noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 170 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 171 | template<class C2> |
| 172 | void merge(map<Key, T, C2, Allocator>& source); // C++17 |
| 173 | template<class C2> |
| 174 | void merge(map<Key, T, C2, Allocator>&& source); // C++17 |
| 175 | template<class C2> |
| 176 | void merge(multimap<Key, T, C2, Allocator>& source); // C++17 |
| 177 | template<class C2> |
| 178 | void merge(multimap<Key, T, C2, Allocator>&& source); // C++17 |
| 179 | |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 180 | void swap(map& m) |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 181 | noexcept(allocator_traits<allocator_type>::is_always_equal::value && |
Eric Fiselier | 6bfed25 | 2016-04-21 23:38:59 +0000 | [diff] [blame] | 182 | is_nothrow_swappable<key_compare>::value); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 183 | |
| 184 | // observers: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 185 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 186 | key_compare key_comp() const; |
| 187 | value_compare value_comp() const; |
| 188 | |
| 189 | // map operations: |
| 190 | iterator find(const key_type& k); |
| 191 | const_iterator find(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 192 | template<typename K> |
| 193 | iterator find(const K& x); // C++14 |
| 194 | template<typename K> |
| 195 | const_iterator find(const K& x) const; // C++14 |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 196 | |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 197 | template<typename K> |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 198 | size_type count(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 199 | size_type count(const key_type& k) const; |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 200 | |
| 201 | bool contains(const key_type& x) const; // C++20 |
| 202 | template<class K> bool contains(const K& x) const; // C++20 |
| 203 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 204 | iterator lower_bound(const key_type& k); |
| 205 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 206 | template<typename K> |
| 207 | iterator lower_bound(const K& x); // C++14 |
| 208 | template<typename K> |
| 209 | const_iterator lower_bound(const K& x) const; // C++14 |
| 210 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 211 | iterator upper_bound(const key_type& k); |
| 212 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 213 | template<typename K> |
| 214 | iterator upper_bound(const K& x); // C++14 |
| 215 | template<typename K> |
| 216 | const_iterator upper_bound(const K& x) const; // C++14 |
| 217 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 218 | pair<iterator,iterator> equal_range(const key_type& k); |
| 219 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 220 | template<typename K> |
| 221 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 222 | template<typename K> |
| 223 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 224 | }; |
| 225 | |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 226 | template <class InputIterator, |
| 227 | class Compare = less<iter_key_t<InputIterator>>, |
| 228 | class Allocator = allocator<iter_to_alloc_t<InputIterator>>> |
| 229 | map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) |
| 230 | -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17 |
| 231 | |
| 232 | template<class Key, class T, class Compare = less<Key>, |
| 233 | class Allocator = allocator<pair<const Key, T>>> |
| 234 | map(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator()) |
| 235 | -> map<Key, T, Compare, Allocator>; // C++17 |
| 236 | |
| 237 | template <class InputIterator, class Allocator> |
| 238 | map(InputIterator, InputIterator, Allocator) |
| 239 | -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, less<iter_key_t<InputIterator>>, |
| 240 | Allocator>; // C++17 |
| 241 | |
| 242 | template<class Key, class T, class Allocator> |
| 243 | map(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>; // C++17 |
| 244 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 245 | template <class Key, class T, class Compare, class Allocator> |
| 246 | bool |
| 247 | operator==(const map<Key, T, Compare, Allocator>& x, |
| 248 | const map<Key, T, Compare, Allocator>& y); |
| 249 | |
| 250 | template <class Key, class T, class Compare, class Allocator> |
| 251 | bool |
| 252 | operator< (const map<Key, T, Compare, Allocator>& x, |
| 253 | const map<Key, T, Compare, Allocator>& y); |
| 254 | |
| 255 | template <class Key, class T, class Compare, class Allocator> |
| 256 | bool |
| 257 | operator!=(const map<Key, T, Compare, Allocator>& x, |
| 258 | const map<Key, T, Compare, Allocator>& y); |
| 259 | |
| 260 | template <class Key, class T, class Compare, class Allocator> |
| 261 | bool |
| 262 | operator> (const map<Key, T, Compare, Allocator>& x, |
| 263 | const map<Key, T, Compare, Allocator>& y); |
| 264 | |
| 265 | template <class Key, class T, class Compare, class Allocator> |
| 266 | bool |
| 267 | operator>=(const map<Key, T, Compare, Allocator>& x, |
| 268 | const map<Key, T, Compare, Allocator>& y); |
| 269 | |
| 270 | template <class Key, class T, class Compare, class Allocator> |
| 271 | bool |
| 272 | operator<=(const map<Key, T, Compare, Allocator>& x, |
| 273 | const map<Key, T, Compare, Allocator>& y); |
| 274 | |
| 275 | // specialized algorithms: |
| 276 | template <class Key, class T, class Compare, class Allocator> |
| 277 | void |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 278 | swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y) |
| 279 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 280 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 281 | template <class Key, class T, class Compare, class Allocator, class Predicate> |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 282 | typename map<Key, T, Compare, Allocator>::size_type |
| 283 | erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 284 | |
| 285 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 286 | template <class Key, class T, class Compare = less<Key>, |
| 287 | class Allocator = allocator<pair<const Key, T>>> |
| 288 | class multimap |
| 289 | { |
| 290 | public: |
| 291 | // types: |
| 292 | typedef Key key_type; |
| 293 | typedef T mapped_type; |
| 294 | typedef pair<const key_type,mapped_type> value_type; |
| 295 | typedef Compare key_compare; |
| 296 | typedef Allocator allocator_type; |
| 297 | typedef typename allocator_type::reference reference; |
| 298 | typedef typename allocator_type::const_reference const_reference; |
| 299 | typedef typename allocator_type::size_type size_type; |
| 300 | typedef typename allocator_type::difference_type difference_type; |
| 301 | typedef typename allocator_type::pointer pointer; |
| 302 | typedef typename allocator_type::const_pointer const_pointer; |
| 303 | |
| 304 | typedef implementation-defined iterator; |
| 305 | typedef implementation-defined const_iterator; |
| 306 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 307 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 308 | typedef unspecified node_type; // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 309 | |
| 310 | class value_compare |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 311 | { |
| 312 | friend class multimap; |
| 313 | protected: |
| 314 | key_compare comp; |
| 315 | value_compare(key_compare c); |
| 316 | public: |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 317 | typedef bool result_type; // deprecated in C++17, removed in C++20 |
| 318 | typedef value_type first_argument_type; // deprecated in C++17, removed in C++20 |
| 319 | typedef value_type second_argument_type; // deprecated in C++17, removed in C++20 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 320 | bool operator()(const value_type& x, const value_type& y) const; |
| 321 | }; |
| 322 | |
| 323 | // construct/copy/destroy: |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 324 | multimap() |
| 325 | noexcept( |
| 326 | is_nothrow_default_constructible<allocator_type>::value && |
| 327 | is_nothrow_default_constructible<key_compare>::value && |
| 328 | is_nothrow_copy_constructible<key_compare>::value); |
| 329 | explicit multimap(const key_compare& comp); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 330 | multimap(const key_compare& comp, const allocator_type& a); |
| 331 | template <class InputIterator> |
| 332 | multimap(InputIterator first, InputIterator last, const key_compare& comp); |
| 333 | template <class InputIterator> |
| 334 | multimap(InputIterator first, InputIterator last, const key_compare& comp, |
| 335 | const allocator_type& a); |
| 336 | multimap(const multimap& m); |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 337 | multimap(multimap&& m) |
| 338 | noexcept( |
| 339 | is_nothrow_move_constructible<allocator_type>::value && |
| 340 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 341 | explicit multimap(const allocator_type& a); |
| 342 | multimap(const multimap& m, const allocator_type& a); |
| 343 | multimap(multimap&& m, const allocator_type& a); |
| 344 | multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); |
| 345 | multimap(initializer_list<value_type> il, const key_compare& comp, |
| 346 | const allocator_type& a); |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 347 | template <class InputIterator> |
| 348 | multimap(InputIterator first, InputIterator last, const allocator_type& a) |
| 349 | : multimap(first, last, Compare(), a) {} // C++14 |
| 350 | multimap(initializer_list<value_type> il, const allocator_type& a) |
| 351 | : multimap(il, Compare(), a) {} // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 352 | ~multimap(); |
| 353 | |
| 354 | multimap& operator=(const multimap& m); |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 355 | multimap& operator=(multimap&& m) |
| 356 | noexcept( |
| 357 | allocator_type::propagate_on_container_move_assignment::value && |
| 358 | is_nothrow_move_assignable<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 359 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 360 | multimap& operator=(initializer_list<value_type> il); |
| 361 | |
| 362 | // iterators: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 363 | iterator begin() noexcept; |
| 364 | const_iterator begin() const noexcept; |
| 365 | iterator end() noexcept; |
| 366 | const_iterator end() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 367 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 368 | reverse_iterator rbegin() noexcept; |
| 369 | const_reverse_iterator rbegin() const noexcept; |
| 370 | reverse_iterator rend() noexcept; |
| 371 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 372 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 373 | const_iterator cbegin() const noexcept; |
| 374 | const_iterator cend() const noexcept; |
| 375 | const_reverse_iterator crbegin() const noexcept; |
| 376 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 377 | |
| 378 | // capacity: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 379 | bool empty() const noexcept; |
| 380 | size_type size() const noexcept; |
| 381 | size_type max_size() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 382 | |
| 383 | // modifiers: |
| 384 | template <class... Args> |
| 385 | iterator emplace(Args&&... args); |
| 386 | template <class... Args> |
| 387 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 388 | iterator insert(const value_type& v); |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 389 | iterator insert( value_type&& v); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 390 | template <class P> |
| 391 | iterator insert(P&& p); |
| 392 | iterator insert(const_iterator position, const value_type& v); |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 393 | iterator insert(const_iterator position, value_type&& v); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 394 | template <class P> |
| 395 | iterator insert(const_iterator position, P&& p); |
| 396 | template <class InputIterator> |
| 397 | void insert(InputIterator first, InputIterator last); |
| 398 | void insert(initializer_list<value_type> il); |
| 399 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 400 | node_type extract(const_iterator position); // C++17 |
| 401 | node_type extract(const key_type& x); // C++17 |
| 402 | iterator insert(node_type&& nh); // C++17 |
| 403 | iterator insert(const_iterator hint, node_type&& nh); // C++17 |
| 404 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 405 | iterator erase(const_iterator position); |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 406 | iterator erase(iterator position); // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 407 | size_type erase(const key_type& k); |
| 408 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 409 | void clear() noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 410 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 411 | template<class C2> |
| 412 | void merge(multimap<Key, T, C2, Allocator>& source); // C++17 |
| 413 | template<class C2> |
| 414 | void merge(multimap<Key, T, C2, Allocator>&& source); // C++17 |
| 415 | template<class C2> |
| 416 | void merge(map<Key, T, C2, Allocator>& source); // C++17 |
| 417 | template<class C2> |
| 418 | void merge(map<Key, T, C2, Allocator>&& source); // C++17 |
| 419 | |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 420 | void swap(multimap& m) |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 421 | noexcept(allocator_traits<allocator_type>::is_always_equal::value && |
Eric Fiselier | 6bfed25 | 2016-04-21 23:38:59 +0000 | [diff] [blame] | 422 | is_nothrow_swappable<key_compare>::value); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 423 | |
| 424 | // observers: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 425 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 426 | key_compare key_comp() const; |
| 427 | value_compare value_comp() const; |
| 428 | |
| 429 | // map operations: |
| 430 | iterator find(const key_type& k); |
| 431 | const_iterator find(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 432 | template<typename K> |
| 433 | iterator find(const K& x); // C++14 |
| 434 | template<typename K> |
| 435 | const_iterator find(const K& x) const; // C++14 |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 436 | |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 437 | template<typename K> |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 438 | size_type count(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 439 | size_type count(const key_type& k) const; |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 440 | |
| 441 | bool contains(const key_type& x) const; // C++20 |
| 442 | template<class K> bool contains(const K& x) const; // C++20 |
| 443 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 444 | iterator lower_bound(const key_type& k); |
| 445 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 446 | template<typename K> |
| 447 | iterator lower_bound(const K& x); // C++14 |
| 448 | template<typename K> |
| 449 | const_iterator lower_bound(const K& x) const; // C++14 |
| 450 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 451 | iterator upper_bound(const key_type& k); |
| 452 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 453 | template<typename K> |
| 454 | iterator upper_bound(const K& x); // C++14 |
| 455 | template<typename K> |
| 456 | const_iterator upper_bound(const K& x) const; // C++14 |
| 457 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 458 | pair<iterator,iterator> equal_range(const key_type& k); |
| 459 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 460 | template<typename K> |
| 461 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 462 | template<typename K> |
| 463 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 464 | }; |
| 465 | |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 466 | template <class InputIterator, |
| 467 | class Compare = less<iter_key_t<InputIterator>>, |
| 468 | class Allocator = allocator<iter_to_alloc_t<InputIterator>>> |
| 469 | multimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) |
| 470 | -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17 |
| 471 | |
| 472 | template<class Key, class T, class Compare = less<Key>, |
| 473 | class Allocator = allocator<pair<const Key, T>>> |
| 474 | multimap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator()) |
| 475 | -> multimap<Key, T, Compare, Allocator>; // C++17 |
| 476 | |
| 477 | template <class InputIterator, class Allocator> |
| 478 | multimap(InputIterator, InputIterator, Allocator) |
| 479 | -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, |
| 480 | less<iter_key_t<InputIterator>>, Allocator>; // C++17 |
| 481 | |
| 482 | template<class Key, class T, class Allocator> |
| 483 | multimap(initializer_list<pair<const Key, T>>, Allocator) |
| 484 | -> multimap<Key, T, less<Key>, Allocator>; // C++17 |
| 485 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 486 | template <class Key, class T, class Compare, class Allocator> |
| 487 | bool |
| 488 | operator==(const multimap<Key, T, Compare, Allocator>& x, |
| 489 | const multimap<Key, T, Compare, Allocator>& y); |
| 490 | |
| 491 | template <class Key, class T, class Compare, class Allocator> |
| 492 | bool |
| 493 | operator< (const multimap<Key, T, Compare, Allocator>& x, |
| 494 | const multimap<Key, T, Compare, Allocator>& y); |
| 495 | |
| 496 | template <class Key, class T, class Compare, class Allocator> |
| 497 | bool |
| 498 | operator!=(const multimap<Key, T, Compare, Allocator>& x, |
| 499 | const multimap<Key, T, Compare, Allocator>& y); |
| 500 | |
| 501 | template <class Key, class T, class Compare, class Allocator> |
| 502 | bool |
| 503 | operator> (const multimap<Key, T, Compare, Allocator>& x, |
| 504 | const multimap<Key, T, Compare, Allocator>& y); |
| 505 | |
| 506 | template <class Key, class T, class Compare, class Allocator> |
| 507 | bool |
| 508 | operator>=(const multimap<Key, T, Compare, Allocator>& x, |
| 509 | const multimap<Key, T, Compare, Allocator>& y); |
| 510 | |
| 511 | template <class Key, class T, class Compare, class Allocator> |
| 512 | bool |
| 513 | operator<=(const multimap<Key, T, Compare, Allocator>& x, |
| 514 | const multimap<Key, T, Compare, Allocator>& y); |
| 515 | |
| 516 | // specialized algorithms: |
| 517 | template <class Key, class T, class Compare, class Allocator> |
| 518 | void |
| 519 | swap(multimap<Key, T, Compare, Allocator>& x, |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 520 | multimap<Key, T, Compare, Allocator>& y) |
| 521 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 522 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 523 | template <class Key, class T, class Compare, class Allocator, class Predicate> |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 524 | typename multimap<Key, T, Compare, Allocator>::size_type |
| 525 | erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 526 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 527 | } // std |
| 528 | |
| 529 | */ |
| 530 | |
| 531 | #include <__config> |
Arthur O'Dwyer | 597cac4 | 2021-05-12 23:04:03 -0400 | [diff] [blame] | 532 | #include <__debug> |
Christopher Di Bella | 55d7a82 | 2021-07-01 09:25:35 -0400 | [diff] [blame] | 533 | #include <__functional/is_transparent.h> |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 534 | #include <__iterator/iterator_traits.h> |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 535 | #include <__node_handle> |
Arthur O'Dwyer | 597cac4 | 2021-05-12 23:04:03 -0400 | [diff] [blame] | 536 | #include <__tree> |
Christopher Di Bella | 41f26e8 | 2021-06-05 02:47:47 +0000 | [diff] [blame] | 537 | #include <__utility/forward.h> |
Arthur O'Dwyer | 7deec12 | 2021-03-24 18:19:12 -0400 | [diff] [blame] | 538 | #include <compare> |
Arthur O'Dwyer | ef18160 | 2021-05-19 11:57:04 -0400 | [diff] [blame] | 539 | #include <functional> |
Arthur O'Dwyer | 7deec12 | 2021-03-24 18:19:12 -0400 | [diff] [blame] | 540 | #include <initializer_list> |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 541 | #include <iterator> // __libcpp_erase_if_container |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 542 | #include <memory> |
Eric Fiselier | f739430 | 2015-06-13 07:08:02 +0000 | [diff] [blame] | 543 | #include <type_traits> |
Arthur O'Dwyer | ef18160 | 2021-05-19 11:57:04 -0400 | [diff] [blame] | 544 | #include <utility> |
Marshall Clow | 0a1e750 | 2018-09-12 19:41:40 +0000 | [diff] [blame] | 545 | #include <version> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 546 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 547 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 548 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 549 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 550 | |
| 551 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 552 | |
Louis Dionne | 878a3a8 | 2018-12-06 21:46:17 +0000 | [diff] [blame] | 553 | template <class _Key, class _CP, class _Compare, |
| 554 | bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 555 | class __map_value_compare |
| 556 | : private _Compare |
| 557 | { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 558 | public: |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 559 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 560 | __map_value_compare() |
| 561 | _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) |
| 562 | : _Compare() {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 563 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 564 | __map_value_compare(_Compare c) |
| 565 | _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) |
| 566 | : _Compare(c) {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 567 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 568 | const _Compare& key_comp() const _NOEXCEPT {return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 569 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 570 | bool operator()(const _CP& __x, const _CP& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 571 | {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 572 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 573 | bool operator()(const _CP& __x, const _Key& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 574 | {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 575 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 576 | bool operator()(const _Key& __x, const _CP& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 577 | {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);} |
Arthur O'Dwyer | 1e1de50 | 2021-08-31 14:29:24 -0400 | [diff] [blame] | 578 | void swap(__map_value_compare& __y) |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 579 | _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) |
| 580 | { |
Eric Fiselier | 68b5f0b | 2017-04-13 00:34:24 +0000 | [diff] [blame] | 581 | using _VSTD::swap; |
| 582 | swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 583 | } |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 584 | |
| 585 | #if _LIBCPP_STD_VER > 11 |
| 586 | template <typename _K2> |
| 587 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 8a61572 | 2021-08-31 13:04:29 -0400 | [diff] [blame] | 588 | bool operator()(const _K2& __x, const _CP& __y) const |
| 589 | {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 590 | |
| 591 | template <typename _K2> |
| 592 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 8a61572 | 2021-08-31 13:04:29 -0400 | [diff] [blame] | 593 | bool operator()(const _CP& __x, const _K2& __y) const |
| 594 | {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 595 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 596 | }; |
| 597 | |
Howard Hinnant | 90b9159 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 598 | template <class _Key, class _CP, class _Compare> |
| 599 | class __map_value_compare<_Key, _CP, _Compare, false> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 600 | { |
| 601 | _Compare comp; |
| 602 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 603 | public: |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 604 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 605 | __map_value_compare() |
| 606 | _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) |
| 607 | : comp() {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 608 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 609 | __map_value_compare(_Compare c) |
| 610 | _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) |
| 611 | : comp(c) {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 612 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 613 | const _Compare& key_comp() const _NOEXCEPT {return comp;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 614 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 615 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 616 | bool operator()(const _CP& __x, const _CP& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 617 | {return comp(__x.__get_value().first, __y.__get_value().first);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 618 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 619 | bool operator()(const _CP& __x, const _Key& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 620 | {return comp(__x.__get_value().first, __y);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 621 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 622 | bool operator()(const _Key& __x, const _CP& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 623 | {return comp(__x, __y.__get_value().first);} |
Arthur O'Dwyer | 1e1de50 | 2021-08-31 14:29:24 -0400 | [diff] [blame] | 624 | void swap(__map_value_compare& __y) |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 625 | _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) |
| 626 | { |
| 627 | using _VSTD::swap; |
| 628 | swap(comp, __y.comp); |
| 629 | } |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 630 | |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 631 | #if _LIBCPP_STD_VER > 11 |
| 632 | template <typename _K2> |
| 633 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 8a61572 | 2021-08-31 13:04:29 -0400 | [diff] [blame] | 634 | bool operator()(const _K2& __x, const _CP& __y) const |
| 635 | {return comp(__x, __y.__get_value().first);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 636 | |
| 637 | template <typename _K2> |
| 638 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 8a61572 | 2021-08-31 13:04:29 -0400 | [diff] [blame] | 639 | bool operator()(const _CP& __x, const _K2& __y) const |
| 640 | {return comp(__x.__get_value().first, __y);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 641 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 642 | }; |
| 643 | |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 644 | template <class _Key, class _CP, class _Compare, bool __b> |
| 645 | inline _LIBCPP_INLINE_VISIBILITY |
| 646 | void |
| 647 | swap(__map_value_compare<_Key, _CP, _Compare, __b>& __x, |
| 648 | __map_value_compare<_Key, _CP, _Compare, __b>& __y) |
| 649 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
| 650 | { |
| 651 | __x.swap(__y); |
| 652 | } |
| 653 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 654 | template <class _Allocator> |
| 655 | class __map_node_destructor |
| 656 | { |
| 657 | typedef _Allocator allocator_type; |
| 658 | typedef allocator_traits<allocator_type> __alloc_traits; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 659 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 660 | public: |
| 661 | typedef typename __alloc_traits::pointer pointer; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 662 | |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 663 | private: |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 664 | allocator_type& __na_; |
| 665 | |
| 666 | __map_node_destructor& operator=(const __map_node_destructor&); |
| 667 | |
| 668 | public: |
| 669 | bool __first_constructed; |
| 670 | bool __second_constructed; |
| 671 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 672 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 673 | explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 674 | : __na_(__na), |
| 675 | __first_constructed(false), |
| 676 | __second_constructed(false) |
| 677 | {} |
| 678 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 679 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 680 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 681 | __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 682 | : __na_(__x.__na_), |
| 683 | __first_constructed(__x.__value_constructed), |
| 684 | __second_constructed(__x.__value_constructed) |
| 685 | { |
| 686 | __x.__value_constructed = false; |
| 687 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 688 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 689 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 690 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 691 | void operator()(pointer __p) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 692 | { |
| 693 | if (__second_constructed) |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 694 | __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 695 | if (__first_constructed) |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 696 | __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 697 | if (__p) |
| 698 | __alloc_traits::deallocate(__na_, __p, 1); |
| 699 | } |
| 700 | }; |
| 701 | |
Howard Hinnant | 944510a | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 702 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 703 | class map; |
| 704 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 705 | class multimap; |
| 706 | template <class _TreeIterator> class __map_const_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 707 | |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 708 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 709 | |
| 710 | template <class _Key, class _Tp> |
Amy Huang | 63f53b5 | 2021-03-15 14:20:49 -0700 | [diff] [blame] | 711 | struct _LIBCPP_STANDALONE_DEBUG __value_type |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 712 | { |
| 713 | typedef _Key key_type; |
| 714 | typedef _Tp mapped_type; |
| 715 | typedef pair<const key_type, mapped_type> value_type; |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 716 | typedef pair<key_type&, mapped_type&> __nc_ref_pair_type; |
| 717 | typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type; |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 718 | |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 719 | private: |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 720 | value_type __cc; |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 721 | |
| 722 | public: |
| 723 | _LIBCPP_INLINE_VISIBILITY |
| 724 | value_type& __get_value() |
| 725 | { |
| 726 | #if _LIBCPP_STD_VER > 14 |
| 727 | return *_VSTD::launder(_VSTD::addressof(__cc)); |
| 728 | #else |
| 729 | return __cc; |
| 730 | #endif |
| 731 | } |
| 732 | |
| 733 | _LIBCPP_INLINE_VISIBILITY |
| 734 | const value_type& __get_value() const |
| 735 | { |
| 736 | #if _LIBCPP_STD_VER > 14 |
| 737 | return *_VSTD::launder(_VSTD::addressof(__cc)); |
| 738 | #else |
| 739 | return __cc; |
| 740 | #endif |
| 741 | } |
| 742 | |
| 743 | _LIBCPP_INLINE_VISIBILITY |
| 744 | __nc_ref_pair_type __ref() |
| 745 | { |
| 746 | value_type& __v = __get_value(); |
| 747 | return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second); |
| 748 | } |
| 749 | |
| 750 | _LIBCPP_INLINE_VISIBILITY |
| 751 | __nc_rref_pair_type __move() |
| 752 | { |
| 753 | value_type& __v = __get_value(); |
| 754 | return __nc_rref_pair_type( |
| 755 | _VSTD::move(const_cast<key_type&>(__v.first)), |
| 756 | _VSTD::move(__v.second)); |
| 757 | } |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 758 | |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 759 | _LIBCPP_INLINE_VISIBILITY |
| 760 | __value_type& operator=(const __value_type& __v) |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 761 | { |
| 762 | __ref() = __v.__get_value(); |
| 763 | return *this; |
| 764 | } |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 765 | |
| 766 | _LIBCPP_INLINE_VISIBILITY |
| 767 | __value_type& operator=(__value_type&& __v) |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 768 | { |
| 769 | __ref() = __v.__move(); |
| 770 | return *this; |
| 771 | } |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 772 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 773 | template <class _ValueTp, |
| 774 | class = typename enable_if< |
| 775 | __is_same_uncvref<_ValueTp, value_type>::value |
| 776 | >::type |
| 777 | > |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 778 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 779 | __value_type& operator=(_ValueTp&& __v) |
| 780 | { |
| 781 | __ref() = _VSTD::forward<_ValueTp>(__v); |
| 782 | return *this; |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | private: |
Arthur O'Dwyer | 7bcb385 | 2021-09-16 22:47:36 -0400 | [diff] [blame] | 786 | __value_type() = delete; |
| 787 | ~__value_type() = delete; |
| 788 | __value_type(const __value_type&) = delete; |
| 789 | __value_type(__value_type&&) = delete; |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 790 | }; |
| 791 | |
| 792 | #else |
| 793 | |
| 794 | template <class _Key, class _Tp> |
| 795 | struct __value_type |
| 796 | { |
| 797 | typedef _Key key_type; |
| 798 | typedef _Tp mapped_type; |
| 799 | typedef pair<const key_type, mapped_type> value_type; |
| 800 | |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 801 | private: |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 802 | value_type __cc; |
| 803 | |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 804 | public: |
| 805 | _LIBCPP_INLINE_VISIBILITY |
| 806 | value_type& __get_value() { return __cc; } |
| 807 | _LIBCPP_INLINE_VISIBILITY |
| 808 | const value_type& __get_value() const { return __cc; } |
| 809 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 810 | private: |
| 811 | __value_type(); |
| 812 | __value_type(__value_type const&); |
| 813 | __value_type& operator=(__value_type const&); |
| 814 | ~__value_type(); |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 815 | }; |
| 816 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 817 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 818 | |
Eric Fiselier | 44f9fd0 | 2015-03-03 20:10:01 +0000 | [diff] [blame] | 819 | template <class _Tp> |
| 820 | struct __extract_key_value_types; |
| 821 | |
| 822 | template <class _Key, class _Tp> |
| 823 | struct __extract_key_value_types<__value_type<_Key, _Tp> > |
| 824 | { |
| 825 | typedef _Key const __key_type; |
| 826 | typedef _Tp __mapped_type; |
| 827 | }; |
| 828 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 829 | template <class _TreeIterator> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 830 | class _LIBCPP_TEMPLATE_VIS __map_iterator |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 831 | { |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 832 | typedef typename _TreeIterator::_NodeTypes _NodeTypes; |
| 833 | typedef typename _TreeIterator::__pointer_traits __pointer_traits; |
| 834 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 835 | _TreeIterator __i_; |
| 836 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 837 | public: |
| 838 | typedef bidirectional_iterator_tag iterator_category; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 839 | typedef typename _NodeTypes::__map_value_type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 840 | typedef typename _TreeIterator::difference_type difference_type; |
| 841 | typedef value_type& reference; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 842 | typedef typename _NodeTypes::__map_value_type_pointer pointer; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 843 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 844 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 845 | __map_iterator() _NOEXCEPT {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 846 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 847 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 848 | __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 849 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 850 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 851 | reference operator*() const {return __i_->__get_value();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 852 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 853 | pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 854 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 855 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 856 | __map_iterator& operator++() {++__i_; return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 857 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 858 | __map_iterator operator++(int) |
| 859 | { |
| 860 | __map_iterator __t(*this); |
| 861 | ++(*this); |
| 862 | return __t; |
| 863 | } |
| 864 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 865 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 866 | __map_iterator& operator--() {--__i_; return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 867 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 868 | __map_iterator operator--(int) |
| 869 | { |
| 870 | __map_iterator __t(*this); |
| 871 | --(*this); |
| 872 | return __t; |
| 873 | } |
| 874 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 875 | friend _LIBCPP_INLINE_VISIBILITY |
| 876 | bool operator==(const __map_iterator& __x, const __map_iterator& __y) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 877 | {return __x.__i_ == __y.__i_;} |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 878 | friend |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 879 | _LIBCPP_INLINE_VISIBILITY |
| 880 | bool operator!=(const __map_iterator& __x, const __map_iterator& __y) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 881 | {return __x.__i_ != __y.__i_;} |
| 882 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 883 | template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map; |
| 884 | template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap; |
| 885 | template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 886 | }; |
| 887 | |
| 888 | template <class _TreeIterator> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 889 | class _LIBCPP_TEMPLATE_VIS __map_const_iterator |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 890 | { |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 891 | typedef typename _TreeIterator::_NodeTypes _NodeTypes; |
| 892 | typedef typename _TreeIterator::__pointer_traits __pointer_traits; |
| 893 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 894 | _TreeIterator __i_; |
| 895 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 896 | public: |
| 897 | typedef bidirectional_iterator_tag iterator_category; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 898 | typedef typename _NodeTypes::__map_value_type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 899 | typedef typename _TreeIterator::difference_type difference_type; |
| 900 | typedef const value_type& reference; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 901 | typedef typename _NodeTypes::__const_map_value_type_pointer pointer; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 902 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 903 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 904 | __map_const_iterator() _NOEXCEPT {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 905 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 906 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 907 | __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 908 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 44f9fd0 | 2015-03-03 20:10:01 +0000 | [diff] [blame] | 909 | __map_const_iterator(__map_iterator< |
| 910 | typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT |
| 911 | : __i_(__i.__i_) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 912 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 913 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 914 | reference operator*() const {return __i_->__get_value();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 915 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 916 | pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 917 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 918 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 919 | __map_const_iterator& operator++() {++__i_; return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 920 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 921 | __map_const_iterator operator++(int) |
| 922 | { |
| 923 | __map_const_iterator __t(*this); |
| 924 | ++(*this); |
| 925 | return __t; |
| 926 | } |
| 927 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 928 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 929 | __map_const_iterator& operator--() {--__i_; return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 930 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 931 | __map_const_iterator operator--(int) |
| 932 | { |
| 933 | __map_const_iterator __t(*this); |
| 934 | --(*this); |
| 935 | return __t; |
| 936 | } |
| 937 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 938 | friend _LIBCPP_INLINE_VISIBILITY |
| 939 | bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 940 | {return __x.__i_ == __y.__i_;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 941 | friend _LIBCPP_INLINE_VISIBILITY |
| 942 | bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 943 | {return __x.__i_ != __y.__i_;} |
| 944 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 945 | template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map; |
| 946 | template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap; |
| 947 | template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 948 | }; |
| 949 | |
| 950 | template <class _Key, class _Tp, class _Compare = less<_Key>, |
| 951 | class _Allocator = allocator<pair<const _Key, _Tp> > > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 952 | class _LIBCPP_TEMPLATE_VIS map |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 953 | { |
| 954 | public: |
| 955 | // types: |
| 956 | typedef _Key key_type; |
| 957 | typedef _Tp mapped_type; |
| 958 | typedef pair<const key_type, mapped_type> value_type; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 959 | typedef __identity_t<_Compare> key_compare; |
| 960 | typedef __identity_t<_Allocator> allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 961 | typedef value_type& reference; |
| 962 | typedef const value_type& const_reference; |
| 963 | |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 964 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 965 | "Allocator::value_type must be same type as value_type"); |
| 966 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 967 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 968 | class _LIBCPP_TEMPLATE_VIS value_compare |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 969 | #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 970 | : public binary_function<value_type, value_type, bool> |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 971 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 972 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 973 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 974 | friend class map; |
| 975 | protected: |
| 976 | key_compare comp; |
| 977 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 978 | _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 979 | public: |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 980 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 981 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 982 | _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type; |
| 983 | _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type; |
| 984 | #endif |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 985 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 986 | bool operator()(const value_type& __x, const value_type& __y) const |
| 987 | {return comp(__x.first, __y.first);} |
| 988 | }; |
| 989 | |
| 990 | private: |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 991 | |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 992 | typedef _VSTD::__value_type<key_type, mapped_type> __value_type; |
Howard Hinnant | 90b9159 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 993 | typedef __map_value_compare<key_type, __value_type, key_compare> __vc; |
Marshall Clow | 940e01c | 2015-04-07 05:21:38 +0000 | [diff] [blame] | 994 | typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, |
| 995 | __value_type>::type __allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 996 | typedef __tree<__value_type, __vc, __allocator_type> __base; |
| 997 | typedef typename __base::__node_traits __node_traits; |
| 998 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 999 | |
| 1000 | __base __tree_; |
| 1001 | |
| 1002 | public: |
| 1003 | typedef typename __alloc_traits::pointer pointer; |
| 1004 | typedef typename __alloc_traits::const_pointer const_pointer; |
| 1005 | typedef typename __alloc_traits::size_type size_type; |
| 1006 | typedef typename __alloc_traits::difference_type difference_type; |
Eric Fiselier | 44f9fd0 | 2015-03-03 20:10:01 +0000 | [diff] [blame] | 1007 | typedef __map_iterator<typename __base::iterator> iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1008 | typedef __map_const_iterator<typename __base::const_iterator> const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1009 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 1010 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1011 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1012 | #if _LIBCPP_STD_VER > 14 |
| 1013 | typedef __map_node_handle<typename __base::__node, allocator_type> node_type; |
| 1014 | typedef __insert_return_type<iterator, node_type> insert_return_type; |
| 1015 | #endif |
| 1016 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1017 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1018 | friend class _LIBCPP_TEMPLATE_VIS map; |
| 1019 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1020 | friend class _LIBCPP_TEMPLATE_VIS multimap; |
| 1021 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1022 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 1023 | map() |
| 1024 | _NOEXCEPT_( |
| 1025 | is_nothrow_default_constructible<allocator_type>::value && |
| 1026 | is_nothrow_default_constructible<key_compare>::value && |
| 1027 | is_nothrow_copy_constructible<key_compare>::value) |
| 1028 | : __tree_(__vc(key_compare())) {} |
| 1029 | |
| 1030 | _LIBCPP_INLINE_VISIBILITY |
| 1031 | explicit map(const key_compare& __comp) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1032 | _NOEXCEPT_( |
| 1033 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1034 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1035 | : __tree_(__vc(__comp)) {} |
| 1036 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1037 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1038 | explicit map(const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1039 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1040 | |
| 1041 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1042 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1043 | map(_InputIterator __f, _InputIterator __l, |
| 1044 | const key_compare& __comp = key_compare()) |
| 1045 | : __tree_(__vc(__comp)) |
| 1046 | { |
| 1047 | insert(__f, __l); |
| 1048 | } |
| 1049 | |
| 1050 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1051 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1052 | map(_InputIterator __f, _InputIterator __l, |
| 1053 | const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1054 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1055 | { |
| 1056 | insert(__f, __l); |
| 1057 | } |
| 1058 | |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1059 | #if _LIBCPP_STD_VER > 11 |
| 1060 | template <class _InputIterator> |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1061 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1062 | map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 1063 | : map(__f, __l, key_compare(), __a) {} |
| 1064 | #endif |
| 1065 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1066 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1067 | map(const map& __m) |
| 1068 | : __tree_(__m.__tree_) |
| 1069 | { |
| 1070 | insert(__m.begin(), __m.end()); |
| 1071 | } |
| 1072 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1073 | _LIBCPP_INLINE_VISIBILITY |
| 1074 | map& operator=(const map& __m) |
| 1075 | { |
Marshall Clow | 476d3f4 | 2016-07-18 13:19:00 +0000 | [diff] [blame] | 1076 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1077 | __tree_ = __m.__tree_; |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1078 | #else |
Mark de Wever | 357a1fc | 2021-09-28 19:15:18 +0200 | [diff] [blame] | 1079 | if (this != _VSTD::addressof(__m)) { |
Marshall Clow | db3cfcb | 2014-02-08 04:03:14 +0000 | [diff] [blame] | 1080 | __tree_.clear(); |
| 1081 | __tree_.value_comp() = __m.__tree_.value_comp(); |
| 1082 | __tree_.__copy_assign_alloc(__m.__tree_); |
| 1083 | insert(__m.begin(), __m.end()); |
| 1084 | } |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1085 | #endif |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1086 | return *this; |
| 1087 | } |
| 1088 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1089 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1090 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1091 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1092 | map(map&& __m) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1093 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1094 | : __tree_(_VSTD::move(__m.__tree_)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1095 | { |
| 1096 | } |
| 1097 | |
| 1098 | map(map&& __m, const allocator_type& __a); |
| 1099 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1100 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1101 | map& operator=(map&& __m) |
| 1102 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
| 1103 | { |
| 1104 | __tree_ = _VSTD::move(__m.__tree_); |
| 1105 | return *this; |
| 1106 | } |
| 1107 | |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1108 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1109 | map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 1110 | : __tree_(__vc(__comp)) |
| 1111 | { |
| 1112 | insert(__il.begin(), __il.end()); |
| 1113 | } |
| 1114 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1115 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1116 | map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1117 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1118 | { |
| 1119 | insert(__il.begin(), __il.end()); |
| 1120 | } |
| 1121 | |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1122 | #if _LIBCPP_STD_VER > 11 |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1123 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1124 | map(initializer_list<value_type> __il, const allocator_type& __a) |
| 1125 | : map(__il, key_compare(), __a) {} |
| 1126 | #endif |
| 1127 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1128 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1129 | map& operator=(initializer_list<value_type> __il) |
| 1130 | { |
| 1131 | __tree_.__assign_unique(__il.begin(), __il.end()); |
| 1132 | return *this; |
| 1133 | } |
| 1134 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1135 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1136 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1137 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1138 | explicit map(const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1139 | : __tree_(typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1140 | { |
| 1141 | } |
| 1142 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1143 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1144 | map(const map& __m, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1145 | : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1146 | { |
| 1147 | insert(__m.begin(), __m.end()); |
| 1148 | } |
| 1149 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1150 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | 69c42c0 | 2019-04-11 16:14:56 +0000 | [diff] [blame] | 1151 | ~map() { |
| 1152 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 1153 | } |
| 1154 | |
| 1155 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1156 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1157 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1158 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1159 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1160 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1161 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1162 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1163 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1164 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1165 | reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1166 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1167 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 1168 | {return const_reverse_iterator(end());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1169 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1170 | reverse_iterator rend() _NOEXCEPT |
| 1171 | {return reverse_iterator(begin());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1172 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1173 | const_reverse_iterator rend() const _NOEXCEPT |
| 1174 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1175 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1176 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1177 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1178 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1179 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1180 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1181 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1182 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1183 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1184 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 1185 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1186 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1187 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1188 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1189 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1190 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1191 | |
| 1192 | mapped_type& operator[](const key_type& __k); |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1193 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1194 | mapped_type& operator[](key_type&& __k); |
| 1195 | #endif |
| 1196 | |
| 1197 | mapped_type& at(const key_type& __k); |
| 1198 | const mapped_type& at(const key_type& __k) const; |
| 1199 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1200 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1201 | allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1202 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1203 | key_compare key_comp() const {return __tree_.value_comp().key_comp();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1204 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1205 | value_compare value_comp() const {return value_compare(__tree_.value_comp().key_comp());} |
| 1206 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1207 | #ifndef _LIBCPP_CXX03_LANG |
| 1208 | template <class ..._Args> |
| 1209 | _LIBCPP_INLINE_VISIBILITY |
| 1210 | pair<iterator, bool> emplace(_Args&& ...__args) { |
| 1211 | return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...); |
| 1212 | } |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1213 | |
Howard Hinnant | 29eb9b8 | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1214 | template <class ..._Args> |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1215 | _LIBCPP_INLINE_VISIBILITY |
| 1216 | iterator emplace_hint(const_iterator __p, _Args&& ...__args) { |
| 1217 | return __tree_.__emplace_hint_unique(__p.__i_, _VSTD::forward<_Args>(__args)...); |
| 1218 | } |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1219 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1220 | template <class _Pp, |
| 1221 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1222 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1223 | pair<iterator, bool> insert(_Pp&& __p) |
| 1224 | {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1225 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1226 | template <class _Pp, |
| 1227 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1228 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1229 | iterator insert(const_iterator __pos, _Pp&& __p) |
| 1230 | {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1231 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1232 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1233 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1234 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1235 | pair<iterator, bool> |
| 1236 | insert(const value_type& __v) {return __tree_.__insert_unique(__v);} |
| 1237 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1238 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1239 | iterator |
| 1240 | insert(const_iterator __p, const value_type& __v) |
| 1241 | {return __tree_.__insert_unique(__p.__i_, __v);} |
| 1242 | |
Eric Fiselier | d614313 | 2016-04-18 01:40:45 +0000 | [diff] [blame] | 1243 | #ifndef _LIBCPP_CXX03_LANG |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 1244 | _LIBCPP_INLINE_VISIBILITY |
| 1245 | pair<iterator, bool> |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1246 | insert(value_type&& __v) {return __tree_.__insert_unique(_VSTD::move(__v));} |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 1247 | |
| 1248 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1249 | iterator insert(const_iterator __p, value_type&& __v) |
| 1250 | {return __tree_.__insert_unique(__p.__i_, _VSTD::move(__v));} |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1251 | |
| 1252 | _LIBCPP_INLINE_VISIBILITY |
| 1253 | void insert(initializer_list<value_type> __il) |
| 1254 | {insert(__il.begin(), __il.end());} |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 1255 | #endif |
| 1256 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1257 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1258 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1259 | void insert(_InputIterator __f, _InputIterator __l) |
| 1260 | { |
| 1261 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1262 | insert(__e.__i_, *__f); |
| 1263 | } |
| 1264 | |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1265 | #if _LIBCPP_STD_VER > 14 |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1266 | |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1267 | template <class... _Args> |
| 1268 | _LIBCPP_INLINE_VISIBILITY |
| 1269 | pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) |
| 1270 | { |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1271 | return __tree_.__emplace_unique_key_args(__k, |
| 1272 | _VSTD::piecewise_construct, |
| 1273 | _VSTD::forward_as_tuple(__k), |
| 1274 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | template <class... _Args> |
| 1278 | _LIBCPP_INLINE_VISIBILITY |
| 1279 | pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) |
| 1280 | { |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1281 | return __tree_.__emplace_unique_key_args(__k, |
| 1282 | _VSTD::piecewise_construct, |
| 1283 | _VSTD::forward_as_tuple(_VSTD::move(__k)), |
| 1284 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | template <class... _Args> |
| 1288 | _LIBCPP_INLINE_VISIBILITY |
| 1289 | iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) |
| 1290 | { |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1291 | return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, |
| 1292 | _VSTD::piecewise_construct, |
| 1293 | _VSTD::forward_as_tuple(__k), |
Mark de Wever | 1ba476f | 2020-09-19 15:39:09 +0200 | [diff] [blame] | 1294 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first; |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | template <class... _Args> |
| 1298 | _LIBCPP_INLINE_VISIBILITY |
| 1299 | iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) |
| 1300 | { |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1301 | return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, |
| 1302 | _VSTD::piecewise_construct, |
| 1303 | _VSTD::forward_as_tuple(_VSTD::move(__k)), |
Mark de Wever | 1ba476f | 2020-09-19 15:39:09 +0200 | [diff] [blame] | 1304 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)).first; |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1305 | } |
| 1306 | |
| 1307 | template <class _Vp> |
| 1308 | _LIBCPP_INLINE_VISIBILITY |
| 1309 | pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) |
| 1310 | { |
| 1311 | iterator __p = lower_bound(__k); |
| 1312 | if ( __p != end() && !key_comp()(__k, __p->first)) |
| 1313 | { |
| 1314 | __p->second = _VSTD::forward<_Vp>(__v); |
| 1315 | return _VSTD::make_pair(__p, false); |
| 1316 | } |
| 1317 | return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true); |
| 1318 | } |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1319 | |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1320 | template <class _Vp> |
| 1321 | _LIBCPP_INLINE_VISIBILITY |
| 1322 | pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) |
| 1323 | { |
| 1324 | iterator __p = lower_bound(__k); |
| 1325 | if ( __p != end() && !key_comp()(__k, __p->first)) |
| 1326 | { |
| 1327 | __p->second = _VSTD::forward<_Vp>(__v); |
| 1328 | return _VSTD::make_pair(__p, false); |
| 1329 | } |
| 1330 | return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true); |
| 1331 | } |
| 1332 | |
| 1333 | template <class _Vp> |
Mark de Wever | 1ba476f | 2020-09-19 15:39:09 +0200 | [diff] [blame] | 1334 | _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h, |
| 1335 | const key_type& __k, |
| 1336 | _Vp&& __v) { |
| 1337 | auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args( |
| 1338 | __h.__i_, __k, __k, _VSTD::forward<_Vp>(__v)); |
| 1339 | |
| 1340 | if (!__inserted) |
| 1341 | __r->__get_value().second = _VSTD::forward<_Vp>(__v); |
| 1342 | |
| 1343 | return __r; |
| 1344 | } |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1345 | |
| 1346 | template <class _Vp> |
Mark de Wever | 1ba476f | 2020-09-19 15:39:09 +0200 | [diff] [blame] | 1347 | _LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h, |
| 1348 | key_type&& __k, |
| 1349 | _Vp&& __v) { |
| 1350 | auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args( |
| 1351 | __h.__i_, __k, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)); |
| 1352 | |
| 1353 | if (!__inserted) |
| 1354 | __r->__get_value().second = _VSTD::forward<_Vp>(__v); |
| 1355 | |
| 1356 | return __r; |
| 1357 | } |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1358 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1359 | #endif // _LIBCPP_STD_VER > 14 |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1360 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1361 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1362 | iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1363 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 1364 | iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} |
| 1365 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1366 | size_type erase(const key_type& __k) |
| 1367 | {return __tree_.__erase_unique(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1368 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1369 | iterator erase(const_iterator __f, const_iterator __l) |
| 1370 | {return __tree_.erase(__f.__i_, __l.__i_);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1371 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1372 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1373 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1374 | #if _LIBCPP_STD_VER > 14 |
| 1375 | _LIBCPP_INLINE_VISIBILITY |
| 1376 | insert_return_type insert(node_type&& __nh) |
| 1377 | { |
| 1378 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1379 | "node_type with incompatible allocator passed to map::insert()"); |
| 1380 | return __tree_.template __node_handle_insert_unique< |
| 1381 | node_type, insert_return_type>(_VSTD::move(__nh)); |
| 1382 | } |
| 1383 | _LIBCPP_INLINE_VISIBILITY |
| 1384 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 1385 | { |
| 1386 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1387 | "node_type with incompatible allocator passed to map::insert()"); |
| 1388 | return __tree_.template __node_handle_insert_unique<node_type>( |
| 1389 | __hint.__i_, _VSTD::move(__nh)); |
| 1390 | } |
| 1391 | _LIBCPP_INLINE_VISIBILITY |
| 1392 | node_type extract(key_type const& __key) |
| 1393 | { |
| 1394 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 1395 | } |
| 1396 | _LIBCPP_INLINE_VISIBILITY |
| 1397 | node_type extract(const_iterator __it) |
| 1398 | { |
| 1399 | return __tree_.template __node_handle_extract<node_type>(__it.__i_); |
| 1400 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1401 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1402 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1403 | void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1404 | { |
| 1405 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1406 | "merging container with incompatible allocator"); |
| 1407 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 1408 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1409 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1410 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1411 | void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1412 | { |
| 1413 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1414 | "merging container with incompatible allocator"); |
| 1415 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 1416 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1417 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1418 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1419 | void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1420 | { |
| 1421 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1422 | "merging container with incompatible allocator"); |
| 1423 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 1424 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1425 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1426 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1427 | void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1428 | { |
| 1429 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1430 | "merging container with incompatible allocator"); |
| 1431 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 1432 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1433 | #endif |
| 1434 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1435 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1436 | void swap(map& __m) |
| 1437 | _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 1438 | {__tree_.swap(__m.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1439 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1440 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1441 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1442 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1443 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1444 | #if _LIBCPP_STD_VER > 11 |
| 1445 | template <typename _K2> |
| 1446 | _LIBCPP_INLINE_VISIBILITY |
| 1447 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1448 | find(const _K2& __k) {return __tree_.find(__k);} |
| 1449 | template <typename _K2> |
| 1450 | _LIBCPP_INLINE_VISIBILITY |
| 1451 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1452 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 1453 | #endif |
| 1454 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1455 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1456 | size_type count(const key_type& __k) const |
| 1457 | {return __tree_.__count_unique(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1458 | #if _LIBCPP_STD_VER > 11 |
| 1459 | template <typename _K2> |
| 1460 | _LIBCPP_INLINE_VISIBILITY |
| 1461 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 1462 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1463 | #endif |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 1464 | |
| 1465 | #if _LIBCPP_STD_VER > 17 |
| 1466 | _LIBCPP_INLINE_VISIBILITY |
| 1467 | bool contains(const key_type& __k) const {return find(__k) != end();} |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 1468 | template <typename _K2> |
| 1469 | _LIBCPP_INLINE_VISIBILITY |
| 1470 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 1471 | contains(const _K2& __k) const { return find(__k) != end(); } |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 1472 | #endif // _LIBCPP_STD_VER > 17 |
| 1473 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1474 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1475 | iterator lower_bound(const key_type& __k) |
| 1476 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1477 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1478 | const_iterator lower_bound(const key_type& __k) const |
| 1479 | {return __tree_.lower_bound(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1480 | #if _LIBCPP_STD_VER > 11 |
| 1481 | template <typename _K2> |
| 1482 | _LIBCPP_INLINE_VISIBILITY |
| 1483 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1484 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 1485 | |
| 1486 | template <typename _K2> |
| 1487 | _LIBCPP_INLINE_VISIBILITY |
| 1488 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1489 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 1490 | #endif |
| 1491 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1492 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1493 | iterator upper_bound(const key_type& __k) |
| 1494 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1495 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1496 | const_iterator upper_bound(const key_type& __k) const |
| 1497 | {return __tree_.upper_bound(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1498 | #if _LIBCPP_STD_VER > 11 |
| 1499 | template <typename _K2> |
| 1500 | _LIBCPP_INLINE_VISIBILITY |
| 1501 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1502 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 1503 | template <typename _K2> |
| 1504 | _LIBCPP_INLINE_VISIBILITY |
| 1505 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1506 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 1507 | #endif |
| 1508 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1509 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1510 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 1511 | {return __tree_.__equal_range_unique(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1512 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1513 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 1514 | {return __tree_.__equal_range_unique(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1515 | #if _LIBCPP_STD_VER > 11 |
| 1516 | template <typename _K2> |
| 1517 | _LIBCPP_INLINE_VISIBILITY |
| 1518 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 1519 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1520 | template <typename _K2> |
| 1521 | _LIBCPP_INLINE_VISIBILITY |
| 1522 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 1523 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1524 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1525 | |
| 1526 | private: |
| 1527 | typedef typename __base::__node __node; |
| 1528 | typedef typename __base::__node_allocator __node_allocator; |
| 1529 | typedef typename __base::__node_pointer __node_pointer; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1530 | typedef typename __base::__node_base_pointer __node_base_pointer; |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1531 | typedef typename __base::__parent_pointer __parent_pointer; |
Eric Fiselier | a92b073 | 2016-02-20 07:12:17 +0000 | [diff] [blame] | 1532 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1533 | typedef __map_node_destructor<__node_allocator> _Dp; |
| 1534 | typedef unique_ptr<__node, _Dp> __node_holder; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1535 | |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1536 | #ifdef _LIBCPP_CXX03_LANG |
Howard Hinnant | ac7e748 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1537 | __node_holder __construct_node_with_key(const key_type& __k); |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1538 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1539 | }; |
| 1540 | |
Louis Dionne | d59f8a5 | 2021-08-17 11:59:07 -0400 | [diff] [blame] | 1541 | #if _LIBCPP_STD_VER >= 17 |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 1542 | template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>, |
| 1543 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 1544 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 1545 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, |
| 1546 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 1547 | map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1548 | -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; |
| 1549 | |
| 1550 | template<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>, |
| 1551 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 1552 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, |
| 1553 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 1554 | map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1555 | -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; |
| 1556 | |
| 1557 | template<class _InputIterator, class _Allocator, |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 1558 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 1559 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 1560 | map(_InputIterator, _InputIterator, _Allocator) |
| 1561 | -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 1562 | less<__iter_key_type<_InputIterator>>, _Allocator>; |
| 1563 | |
| 1564 | template<class _Key, class _Tp, class _Allocator, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 1565 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 1566 | map(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 1567 | -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 1568 | #endif |
Eric Fiselier | a92b073 | 2016-02-20 07:12:17 +0000 | [diff] [blame] | 1569 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1570 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1571 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1572 | map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1573 | : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1574 | { |
| 1575 | if (__a != __m.get_allocator()) |
| 1576 | { |
| 1577 | const_iterator __e = cend(); |
| 1578 | while (!__m.empty()) |
| 1579 | __tree_.__insert_unique(__e.__i_, |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1580 | __m.__tree_.remove(__m.begin().__i_)->__value_.__move()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1581 | } |
| 1582 | } |
| 1583 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1584 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1585 | _Tp& |
| 1586 | map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) |
| 1587 | { |
| 1588 | return __tree_.__emplace_unique_key_args(__k, |
| 1589 | _VSTD::piecewise_construct, |
| 1590 | _VSTD::forward_as_tuple(__k), |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1591 | _VSTD::forward_as_tuple()).first->__get_value().second; |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1592 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1593 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1594 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1595 | _Tp& |
| 1596 | map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) |
| 1597 | { |
| 1598 | return __tree_.__emplace_unique_key_args(__k, |
| 1599 | _VSTD::piecewise_construct, |
| 1600 | _VSTD::forward_as_tuple(_VSTD::move(__k)), |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1601 | _VSTD::forward_as_tuple()).first->__get_value().second; |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1602 | } |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1603 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1604 | #else // _LIBCPP_CXX03_LANG |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1605 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1606 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1607 | typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder |
Howard Hinnant | ac7e748 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1608 | map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1609 | { |
| 1610 | __node_allocator& __na = __tree_.__node_alloc(); |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1611 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1612 | __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1613 | __h.get_deleter().__first_constructed = true; |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1614 | __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1615 | __h.get_deleter().__second_constructed = true; |
Louis Dionne | 7b84436 | 2020-07-30 09:42:23 -0400 | [diff] [blame] | 1616 | return __h; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1617 | } |
| 1618 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1619 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1620 | _Tp& |
| 1621 | map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) |
| 1622 | { |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1623 | __parent_pointer __parent; |
| 1624 | __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1625 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| 1626 | if (__child == nullptr) |
| 1627 | { |
Howard Hinnant | ac7e748 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1628 | __node_holder __h = __construct_node_with_key(__k); |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1629 | __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1630 | __r = __h.release(); |
| 1631 | } |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1632 | return __r->__value_.__get_value().second; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1633 | } |
| 1634 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1635 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1636 | |
| 1637 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1638 | _Tp& |
| 1639 | map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) |
| 1640 | { |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1641 | __parent_pointer __parent; |
| 1642 | __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1643 | if (__child == nullptr) |
Louis Dionne | 2b23916 | 2019-02-12 16:06:02 +0000 | [diff] [blame] | 1644 | __throw_out_of_range("map::at: key not found"); |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1645 | return static_cast<__node_pointer>(__child)->__value_.__get_value().second; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1646 | } |
| 1647 | |
| 1648 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1649 | const _Tp& |
| 1650 | map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const |
| 1651 | { |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1652 | __parent_pointer __parent; |
| 1653 | __node_base_pointer __child = __tree_.__find_equal(__parent, __k); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1654 | if (__child == nullptr) |
Louis Dionne | 2b23916 | 2019-02-12 16:06:02 +0000 | [diff] [blame] | 1655 | __throw_out_of_range("map::at: key not found"); |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1656 | return static_cast<__node_pointer>(__child)->__value_.__get_value().second; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1657 | } |
| 1658 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1659 | |
| 1660 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1661 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1662 | bool |
| 1663 | operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1664 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1665 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1666 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1667 | } |
| 1668 | |
| 1669 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1670 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1671 | bool |
| 1672 | operator< (const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1673 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1674 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1675 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1676 | } |
| 1677 | |
| 1678 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1679 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1680 | bool |
| 1681 | operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1682 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1683 | { |
| 1684 | return !(__x == __y); |
| 1685 | } |
| 1686 | |
| 1687 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1688 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1689 | bool |
| 1690 | operator> (const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1691 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1692 | { |
| 1693 | return __y < __x; |
| 1694 | } |
| 1695 | |
| 1696 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1697 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1698 | bool |
| 1699 | operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1700 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1701 | { |
| 1702 | return !(__x < __y); |
| 1703 | } |
| 1704 | |
| 1705 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1706 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1707 | bool |
| 1708 | operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1709 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1710 | { |
| 1711 | return !(__y < __x); |
| 1712 | } |
| 1713 | |
| 1714 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1715 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1716 | void |
| 1717 | swap(map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1718 | map<_Key, _Tp, _Compare, _Allocator>& __y) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1719 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1720 | { |
| 1721 | __x.swap(__y); |
| 1722 | } |
| 1723 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1724 | #if _LIBCPP_STD_VER > 17 |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1725 | template <class _Key, class _Tp, class _Compare, class _Allocator, |
| 1726 | class _Predicate> |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1727 | inline _LIBCPP_INLINE_VISIBILITY |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1728 | typename map<_Key, _Tp, _Compare, _Allocator>::size_type |
| 1729 | erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) { |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 1730 | return _VSTD::__libcpp_erase_if_container(__c, __pred); |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1731 | } |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1732 | #endif |
| 1733 | |
| 1734 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1735 | template <class _Key, class _Tp, class _Compare = less<_Key>, |
| 1736 | class _Allocator = allocator<pair<const _Key, _Tp> > > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1737 | class _LIBCPP_TEMPLATE_VIS multimap |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1738 | { |
| 1739 | public: |
| 1740 | // types: |
| 1741 | typedef _Key key_type; |
| 1742 | typedef _Tp mapped_type; |
| 1743 | typedef pair<const key_type, mapped_type> value_type; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 1744 | typedef __identity_t<_Compare> key_compare; |
| 1745 | typedef __identity_t<_Allocator> allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1746 | typedef value_type& reference; |
| 1747 | typedef const value_type& const_reference; |
| 1748 | |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 1749 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 1750 | "Allocator::value_type must be same type as value_type"); |
| 1751 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1752 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1753 | class _LIBCPP_TEMPLATE_VIS value_compare |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1754 | #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1755 | : public binary_function<value_type, value_type, bool> |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1756 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1757 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1758 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1759 | friend class multimap; |
| 1760 | protected: |
| 1761 | key_compare comp; |
| 1762 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1763 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1764 | value_compare(key_compare c) : comp(c) {} |
| 1765 | public: |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1766 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 1767 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 1768 | _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type; |
| 1769 | _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type; |
| 1770 | #endif |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1771 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1772 | bool operator()(const value_type& __x, const value_type& __y) const |
| 1773 | {return comp(__x.first, __y.first);} |
| 1774 | }; |
| 1775 | |
| 1776 | private: |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1777 | |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 1778 | typedef _VSTD::__value_type<key_type, mapped_type> __value_type; |
Howard Hinnant | 90b9159 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 1779 | typedef __map_value_compare<key_type, __value_type, key_compare> __vc; |
Marshall Clow | 940e01c | 2015-04-07 05:21:38 +0000 | [diff] [blame] | 1780 | typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, |
| 1781 | __value_type>::type __allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1782 | typedef __tree<__value_type, __vc, __allocator_type> __base; |
| 1783 | typedef typename __base::__node_traits __node_traits; |
| 1784 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1785 | |
| 1786 | __base __tree_; |
| 1787 | |
| 1788 | public: |
| 1789 | typedef typename __alloc_traits::pointer pointer; |
| 1790 | typedef typename __alloc_traits::const_pointer const_pointer; |
| 1791 | typedef typename __alloc_traits::size_type size_type; |
| 1792 | typedef typename __alloc_traits::difference_type difference_type; |
| 1793 | typedef __map_iterator<typename __base::iterator> iterator; |
| 1794 | typedef __map_const_iterator<typename __base::const_iterator> const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1795 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 1796 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1797 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1798 | #if _LIBCPP_STD_VER > 14 |
| 1799 | typedef __map_node_handle<typename __base::__node, allocator_type> node_type; |
| 1800 | #endif |
| 1801 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1802 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1803 | friend class _LIBCPP_TEMPLATE_VIS map; |
| 1804 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1805 | friend class _LIBCPP_TEMPLATE_VIS multimap; |
| 1806 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1807 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 1808 | multimap() |
| 1809 | _NOEXCEPT_( |
| 1810 | is_nothrow_default_constructible<allocator_type>::value && |
| 1811 | is_nothrow_default_constructible<key_compare>::value && |
| 1812 | is_nothrow_copy_constructible<key_compare>::value) |
| 1813 | : __tree_(__vc(key_compare())) {} |
| 1814 | |
| 1815 | _LIBCPP_INLINE_VISIBILITY |
| 1816 | explicit multimap(const key_compare& __comp) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1817 | _NOEXCEPT_( |
| 1818 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1819 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1820 | : __tree_(__vc(__comp)) {} |
| 1821 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1822 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1823 | explicit multimap(const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1824 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1825 | |
| 1826 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1827 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1828 | multimap(_InputIterator __f, _InputIterator __l, |
| 1829 | const key_compare& __comp = key_compare()) |
| 1830 | : __tree_(__vc(__comp)) |
| 1831 | { |
| 1832 | insert(__f, __l); |
| 1833 | } |
| 1834 | |
| 1835 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1836 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1837 | multimap(_InputIterator __f, _InputIterator __l, |
| 1838 | const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1839 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1840 | { |
| 1841 | insert(__f, __l); |
| 1842 | } |
| 1843 | |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1844 | #if _LIBCPP_STD_VER > 11 |
| 1845 | template <class _InputIterator> |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1846 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1847 | multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 1848 | : multimap(__f, __l, key_compare(), __a) {} |
| 1849 | #endif |
| 1850 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1851 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1852 | multimap(const multimap& __m) |
| 1853 | : __tree_(__m.__tree_.value_comp(), |
| 1854 | __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc())) |
| 1855 | { |
| 1856 | insert(__m.begin(), __m.end()); |
| 1857 | } |
| 1858 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1859 | _LIBCPP_INLINE_VISIBILITY |
| 1860 | multimap& operator=(const multimap& __m) |
| 1861 | { |
Marshall Clow | 476d3f4 | 2016-07-18 13:19:00 +0000 | [diff] [blame] | 1862 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1863 | __tree_ = __m.__tree_; |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1864 | #else |
Mark de Wever | 357a1fc | 2021-09-28 19:15:18 +0200 | [diff] [blame] | 1865 | if (this != _VSTD::addressof(__m)) { |
Marshall Clow | db3cfcb | 2014-02-08 04:03:14 +0000 | [diff] [blame] | 1866 | __tree_.clear(); |
| 1867 | __tree_.value_comp() = __m.__tree_.value_comp(); |
| 1868 | __tree_.__copy_assign_alloc(__m.__tree_); |
| 1869 | insert(__m.begin(), __m.end()); |
| 1870 | } |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1871 | #endif |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1872 | return *this; |
| 1873 | } |
| 1874 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1875 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1876 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1877 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1878 | multimap(multimap&& __m) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1879 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1880 | : __tree_(_VSTD::move(__m.__tree_)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1881 | { |
| 1882 | } |
| 1883 | |
| 1884 | multimap(multimap&& __m, const allocator_type& __a); |
| 1885 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1886 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1887 | multimap& operator=(multimap&& __m) |
| 1888 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
| 1889 | { |
| 1890 | __tree_ = _VSTD::move(__m.__tree_); |
| 1891 | return *this; |
| 1892 | } |
| 1893 | |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1894 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1895 | multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 1896 | : __tree_(__vc(__comp)) |
| 1897 | { |
| 1898 | insert(__il.begin(), __il.end()); |
| 1899 | } |
| 1900 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1901 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1902 | multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1903 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1904 | { |
| 1905 | insert(__il.begin(), __il.end()); |
| 1906 | } |
| 1907 | |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1908 | #if _LIBCPP_STD_VER > 11 |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1909 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1910 | multimap(initializer_list<value_type> __il, const allocator_type& __a) |
| 1911 | : multimap(__il, key_compare(), __a) {} |
| 1912 | #endif |
| 1913 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1914 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1915 | multimap& operator=(initializer_list<value_type> __il) |
| 1916 | { |
| 1917 | __tree_.__assign_multi(__il.begin(), __il.end()); |
| 1918 | return *this; |
| 1919 | } |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1920 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1921 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1922 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1923 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1924 | explicit multimap(const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1925 | : __tree_(typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1926 | { |
| 1927 | } |
| 1928 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1929 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1930 | multimap(const multimap& __m, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1931 | : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1932 | { |
| 1933 | insert(__m.begin(), __m.end()); |
| 1934 | } |
| 1935 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1936 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | 69c42c0 | 2019-04-11 16:14:56 +0000 | [diff] [blame] | 1937 | ~multimap() { |
| 1938 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 1939 | } |
| 1940 | |
| 1941 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1942 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1943 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1944 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1945 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1946 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1947 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1948 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1949 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1950 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1951 | reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1952 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1953 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 1954 | {return const_reverse_iterator(end());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1955 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1956 | reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1957 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1958 | const_reverse_iterator rend() const _NOEXCEPT |
| 1959 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1960 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1961 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1962 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1963 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1964 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1965 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1966 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1967 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1968 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1969 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 1970 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1971 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1972 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1973 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1974 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1975 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1976 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1977 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1978 | allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1979 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1980 | key_compare key_comp() const {return __tree_.value_comp().key_comp();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1981 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1982 | value_compare value_comp() const |
| 1983 | {return value_compare(__tree_.value_comp().key_comp());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1984 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1985 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1986 | |
Howard Hinnant | 29eb9b8 | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1987 | template <class ..._Args> |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1988 | _LIBCPP_INLINE_VISIBILITY |
| 1989 | iterator emplace(_Args&& ...__args) { |
| 1990 | return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...); |
| 1991 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1992 | |
Howard Hinnant | 29eb9b8 | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1993 | template <class ..._Args> |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1994 | _LIBCPP_INLINE_VISIBILITY |
| 1995 | iterator emplace_hint(const_iterator __p, _Args&& ...__args) { |
| 1996 | return __tree_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...); |
| 1997 | } |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1998 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1999 | template <class _Pp, |
| 2000 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2001 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2002 | iterator insert(_Pp&& __p) |
| 2003 | {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2004 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2005 | template <class _Pp, |
| 2006 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2007 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2008 | iterator insert(const_iterator __pos, _Pp&& __p) |
| 2009 | {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2010 | |
Eric Fiselier | d614313 | 2016-04-18 01:40:45 +0000 | [diff] [blame] | 2011 | _LIBCPP_INLINE_VISIBILITY |
| 2012 | iterator insert(value_type&& __v) |
| 2013 | {return __tree_.__insert_multi(_VSTD::move(__v));} |
| 2014 | |
| 2015 | _LIBCPP_INLINE_VISIBILITY |
| 2016 | iterator insert(const_iterator __p, value_type&& __v) |
| 2017 | {return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));} |
| 2018 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 2019 | |
| 2020 | _LIBCPP_INLINE_VISIBILITY |
| 2021 | void insert(initializer_list<value_type> __il) |
| 2022 | {insert(__il.begin(), __il.end());} |
| 2023 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2024 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2025 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2026 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2027 | iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);} |
| 2028 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2029 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2030 | iterator insert(const_iterator __p, const value_type& __v) |
| 2031 | {return __tree_.__insert_multi(__p.__i_, __v);} |
| 2032 | |
| 2033 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2034 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2035 | void insert(_InputIterator __f, _InputIterator __l) |
| 2036 | { |
| 2037 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 2038 | __tree_.__insert_multi(__e.__i_, *__f); |
| 2039 | } |
| 2040 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2041 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2042 | iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2043 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 2044 | iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} |
| 2045 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2046 | size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2047 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2048 | iterator erase(const_iterator __f, const_iterator __l) |
| 2049 | {return __tree_.erase(__f.__i_, __l.__i_);} |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 2050 | |
| 2051 | #if _LIBCPP_STD_VER > 14 |
| 2052 | _LIBCPP_INLINE_VISIBILITY |
| 2053 | iterator insert(node_type&& __nh) |
| 2054 | { |
| 2055 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 2056 | "node_type with incompatible allocator passed to multimap::insert()"); |
| 2057 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 2058 | _VSTD::move(__nh)); |
| 2059 | } |
| 2060 | _LIBCPP_INLINE_VISIBILITY |
| 2061 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 2062 | { |
| 2063 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 2064 | "node_type with incompatible allocator passed to multimap::insert()"); |
| 2065 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 2066 | __hint.__i_, _VSTD::move(__nh)); |
| 2067 | } |
| 2068 | _LIBCPP_INLINE_VISIBILITY |
| 2069 | node_type extract(key_type const& __key) |
| 2070 | { |
| 2071 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 2072 | } |
| 2073 | _LIBCPP_INLINE_VISIBILITY |
| 2074 | node_type extract(const_iterator __it) |
| 2075 | { |
| 2076 | return __tree_.template __node_handle_extract<node_type>( |
| 2077 | __it.__i_); |
| 2078 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 2079 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 2080 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 2081 | void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 2082 | { |
| 2083 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 2084 | "merging container with incompatible allocator"); |
| 2085 | return __tree_.__node_handle_merge_multi(__source.__tree_); |
| 2086 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 2087 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 2088 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 2089 | void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 2090 | { |
| 2091 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 2092 | "merging container with incompatible allocator"); |
| 2093 | return __tree_.__node_handle_merge_multi(__source.__tree_); |
| 2094 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 2095 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 2096 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 2097 | void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 2098 | { |
| 2099 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 2100 | "merging container with incompatible allocator"); |
| 2101 | return __tree_.__node_handle_merge_multi(__source.__tree_); |
| 2102 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 2103 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 2104 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 2105 | void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 2106 | { |
| 2107 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 2108 | "merging container with incompatible allocator"); |
| 2109 | return __tree_.__node_handle_merge_multi(__source.__tree_); |
| 2110 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 2111 | #endif |
| 2112 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2113 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | de1312a | 2018-08-22 04:28:43 +0000 | [diff] [blame] | 2114 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2115 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2116 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 2117 | void swap(multimap& __m) |
| 2118 | _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 2119 | {__tree_.swap(__m.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2120 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2121 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2122 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2123 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2124 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 2125 | #if _LIBCPP_STD_VER > 11 |
| 2126 | template <typename _K2> |
| 2127 | _LIBCPP_INLINE_VISIBILITY |
| 2128 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 2129 | find(const _K2& __k) {return __tree_.find(__k);} |
| 2130 | template <typename _K2> |
| 2131 | _LIBCPP_INLINE_VISIBILITY |
| 2132 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 2133 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 2134 | #endif |
| 2135 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2136 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2137 | size_type count(const key_type& __k) const |
| 2138 | {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 2139 | #if _LIBCPP_STD_VER > 11 |
| 2140 | template <typename _K2> |
| 2141 | _LIBCPP_INLINE_VISIBILITY |
| 2142 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Marshall Clow | 141e47b | 2015-06-30 18:15:41 +0000 | [diff] [blame] | 2143 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 2144 | #endif |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 2145 | |
| 2146 | #if _LIBCPP_STD_VER > 17 |
| 2147 | _LIBCPP_INLINE_VISIBILITY |
| 2148 | bool contains(const key_type& __k) const {return find(__k) != end();} |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 2149 | template <typename _K2> |
| 2150 | _LIBCPP_INLINE_VISIBILITY |
| 2151 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 2152 | contains(const _K2& __k) const { return find(__k) != end(); } |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 2153 | #endif // _LIBCPP_STD_VER > 17 |
| 2154 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2155 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2156 | iterator lower_bound(const key_type& __k) |
| 2157 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2158 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2159 | const_iterator lower_bound(const key_type& __k) const |
| 2160 | {return __tree_.lower_bound(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 2161 | #if _LIBCPP_STD_VER > 11 |
| 2162 | template <typename _K2> |
| 2163 | _LIBCPP_INLINE_VISIBILITY |
| 2164 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 2165 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 2166 | |
| 2167 | template <typename _K2> |
| 2168 | _LIBCPP_INLINE_VISIBILITY |
| 2169 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 2170 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 2171 | #endif |
| 2172 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2173 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2174 | iterator upper_bound(const key_type& __k) |
| 2175 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2176 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2177 | const_iterator upper_bound(const key_type& __k) const |
| 2178 | {return __tree_.upper_bound(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 2179 | #if _LIBCPP_STD_VER > 11 |
| 2180 | template <typename _K2> |
| 2181 | _LIBCPP_INLINE_VISIBILITY |
| 2182 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 2183 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 2184 | template <typename _K2> |
| 2185 | _LIBCPP_INLINE_VISIBILITY |
| 2186 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 2187 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 2188 | #endif |
| 2189 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2190 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2191 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 2192 | {return __tree_.__equal_range_multi(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2193 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2194 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 2195 | {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 2196 | #if _LIBCPP_STD_VER > 11 |
| 2197 | template <typename _K2> |
| 2198 | _LIBCPP_INLINE_VISIBILITY |
| 2199 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
| 2200 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
| 2201 | template <typename _K2> |
| 2202 | _LIBCPP_INLINE_VISIBILITY |
| 2203 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
| 2204 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
| 2205 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2206 | |
| 2207 | private: |
| 2208 | typedef typename __base::__node __node; |
| 2209 | typedef typename __base::__node_allocator __node_allocator; |
| 2210 | typedef typename __base::__node_pointer __node_pointer; |
Eric Fiselier | a92b073 | 2016-02-20 07:12:17 +0000 | [diff] [blame] | 2211 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2212 | typedef __map_node_destructor<__node_allocator> _Dp; |
| 2213 | typedef unique_ptr<__node, _Dp> __node_holder; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2214 | }; |
| 2215 | |
Louis Dionne | d59f8a5 | 2021-08-17 11:59:07 -0400 | [diff] [blame] | 2216 | #if _LIBCPP_STD_VER >= 17 |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 2217 | template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>, |
| 2218 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 2219 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 2220 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, |
| 2221 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 2222 | multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 2223 | -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; |
| 2224 | |
| 2225 | template<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>, |
| 2226 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 2227 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, |
| 2228 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 2229 | multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 2230 | -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; |
| 2231 | |
| 2232 | template<class _InputIterator, class _Allocator, |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 2233 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 2234 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 2235 | multimap(_InputIterator, _InputIterator, _Allocator) |
| 2236 | -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 2237 | less<__iter_key_type<_InputIterator>>, _Allocator>; |
| 2238 | |
| 2239 | template<class _Key, class _Tp, class _Allocator, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 2240 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | d23a5f2 | 2019-06-20 19:32:00 +0000 | [diff] [blame] | 2241 | multimap(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 2242 | -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 2243 | #endif |
| 2244 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 2245 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2246 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 2247 | multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 2248 | : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2249 | { |
| 2250 | if (__a != __m.get_allocator()) |
| 2251 | { |
| 2252 | const_iterator __e = cend(); |
| 2253 | while (!__m.empty()) |
| 2254 | __tree_.__insert_multi(__e.__i_, |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 2255 | _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move())); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2256 | } |
| 2257 | } |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 2258 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2259 | |
| 2260 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2261 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2262 | bool |
| 2263 | operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2264 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2265 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2266 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2270 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2271 | bool |
| 2272 | operator< (const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2273 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2274 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2275 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2276 | } |
| 2277 | |
| 2278 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2279 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2280 | bool |
| 2281 | operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2282 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2283 | { |
| 2284 | return !(__x == __y); |
| 2285 | } |
| 2286 | |
| 2287 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2288 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2289 | bool |
| 2290 | operator> (const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2291 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2292 | { |
| 2293 | return __y < __x; |
| 2294 | } |
| 2295 | |
| 2296 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2297 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2298 | bool |
| 2299 | operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2300 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2301 | { |
| 2302 | return !(__x < __y); |
| 2303 | } |
| 2304 | |
| 2305 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2306 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2307 | bool |
| 2308 | operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2309 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2310 | { |
| 2311 | return !(__y < __x); |
| 2312 | } |
| 2313 | |
| 2314 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2315 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2316 | void |
| 2317 | swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2318 | multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 2319 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2320 | { |
| 2321 | __x.swap(__y); |
| 2322 | } |
| 2323 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 2324 | #if _LIBCPP_STD_VER > 17 |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 2325 | template <class _Key, class _Tp, class _Compare, class _Allocator, |
| 2326 | class _Predicate> |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 2327 | inline _LIBCPP_INLINE_VISIBILITY |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 2328 | typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type |
| 2329 | erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, |
| 2330 | _Predicate __pred) { |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 2331 | return _VSTD::__libcpp_erase_if_container(__c, __pred); |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 2332 | } |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 2333 | #endif |
| 2334 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2335 | _LIBCPP_END_NAMESPACE_STD |
| 2336 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2337 | #endif // _LIBCPP_MAP |