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