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