| OLD | NEW |
| 1 // -*- C++ -*- | 1 // -*- C++ -*- |
| 2 //===-------------------------- unordered_map -----------------------------===// | 2 //===-------------------------- unordered_map -----------------------------===// |
| 3 // | 3 // |
| 4 // The LLVM Compiler Infrastructure | 4 // The LLVM Compiler Infrastructure |
| 5 // | 5 // |
| 6 // This file is dual licensed under the MIT and the University of Illinois Open | 6 // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 // Source Licenses. See LICENSE.TXT for details. | 7 // Source Licenses. See LICENSE.TXT for details. |
| 8 // | 8 // |
| 9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
| 10 | 10 |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 typedef typename __alloc_traits::pointer pointer; | 536 typedef typename __alloc_traits::pointer pointer; |
| 537 private: | 537 private: |
| 538 typedef typename value_type::value_type::first_type first_type; | 538 typedef typename value_type::value_type::first_type first_type; |
| 539 typedef typename value_type::value_type::second_type second_type; | 539 typedef typename value_type::value_type::second_type second_type; |
| 540 | 540 |
| 541 allocator_type& __na_; | 541 allocator_type& __na_; |
| 542 | 542 |
| 543 __hash_map_node_destructor& operator=(const __hash_map_node_destructor&); | 543 __hash_map_node_destructor& operator=(const __hash_map_node_destructor&); |
| 544 | 544 |
| 545 public: | 545 public: |
| 546 bool __first_constructed; | 546 bool __constructed; |
| 547 bool __second_constructed; | |
| 548 | 547 |
| 549 _LIBCPP_INLINE_VISIBILITY | 548 _LIBCPP_INLINE_VISIBILITY |
| 550 explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT | 549 explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT |
| 551 : __na_(__na), | 550 : __na_(__na), |
| 552 __first_constructed(false), | 551 __constructed(false) |
| 553 __second_constructed(false) | |
| 554 {} | 552 {} |
| 555 | 553 |
| 556 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 554 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 557 _LIBCPP_INLINE_VISIBILITY | 555 _LIBCPP_INLINE_VISIBILITY |
| 558 __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) | 556 __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) |
| 559 _NOEXCEPT | 557 _NOEXCEPT |
| 560 : __na_(__x.__na_), | 558 : __na_(__x.__na_), |
| 561 __first_constructed(__x.__value_constructed), | 559 __constructed(__x.__value_constructed) |
| 562 __second_constructed(__x.__value_constructed) | |
| 563 { | 560 { |
| 564 __x.__value_constructed = false; | 561 __x.__value_constructed = false; |
| 565 } | 562 } |
| 566 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 563 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 567 _LIBCPP_INLINE_VISIBILITY | 564 _LIBCPP_INLINE_VISIBILITY |
| 568 __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x
) | 565 __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x
) |
| 569 : __na_(__x.__na_), | 566 : __na_(__x.__na_), |
| 570 __first_constructed(__x.__value_constructed), | 567 __constructed(__x.__value_constructed) |
| 571 __second_constructed(__x.__value_constructed) | |
| 572 { | 568 { |
| 573 const_cast<bool&>(__x.__value_constructed) = false; | 569 const_cast<bool&>(__x.__value_constructed) = false; |
| 574 } | 570 } |
| 575 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 571 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 576 | 572 |
| 577 _LIBCPP_INLINE_VISIBILITY | 573 _LIBCPP_INLINE_VISIBILITY |
| 578 void operator()(pointer __p) _NOEXCEPT | 574 void operator()(pointer __p) _NOEXCEPT |
| 579 { | 575 { |
| 580 if (__second_constructed) | 576 if (__constructed) |
| 581 __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.s
econd)); | 577 __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_)); |
| 582 if (__first_constructed) | |
| 583 __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.f
irst)); | |
| 584 if (__p) | 578 if (__p) |
| 585 __alloc_traits::deallocate(__na_, __p, 1); | 579 __alloc_traits::deallocate(__na_, __p, 1); |
| 586 } | 580 } |
| 587 }; | 581 }; |
| 588 | 582 |
| 589 #if __cplusplus >= 201103L | 583 #if __cplusplus >= 201103L |
| 590 | 584 |
| 591 template <class _Key, class _Tp> | 585 template <class _Key, class _Tp> |
| 592 union __hash_value_type | 586 union __hash_value_type |
| 593 { | 587 { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_c
onst_iterator& __y) | 755 bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_c
onst_iterator& __y) |
| 762 {return __x.__i_ != __y.__i_;} | 756 {return __x.__i_ != __y.__i_;} |
| 763 | 757 |
| 764 template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_O
NLY unordered_map; | 758 template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_O
NLY unordered_map; |
| 765 template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_O
NLY unordered_multimap; | 759 template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_O
NLY unordered_multimap; |
| 766 template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; | 760 template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; |
| 767 template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_itera
tor; | 761 template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_itera
tor; |
| 768 }; | 762 }; |
| 769 | 763 |
| 770 template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_t
o<_Key>, | 764 template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_t
o<_Key>, |
| 771 class _Alloc = allocator<pair<const _Key, _Tp> > > | 765 class _Alloc = counting_allocator<pair<const _Key, _Tp>, allocation_gr
oup::unordered_map > > |
| 772 class _LIBCPP_TYPE_VIS_ONLY unordered_map | 766 class _LIBCPP_TYPE_VIS_ONLY unordered_map |
| 773 { | 767 { |
| 774 public: | 768 public: |
| 775 // types | 769 // types |
| 776 typedef _Key key_type; | 770 typedef _Key key_type; |
| 777 typedef _Tp mapped_type; | 771 typedef _Tp mapped_type; |
| 778 typedef _Hash hasher; | 772 typedef _Hash hasher; |
| 779 typedef _Pred key_equal; | 773 typedef _Pred key_equal; |
| 780 typedef _Alloc allocator_type; | 774 typedef _Alloc allocator_type; |
| 781 typedef pair<const key_type, mapped_type> value_type; | 775 typedef pair<const key_type, mapped_type> value_type; |
| 782 typedef pair<key_type, mapped_type> __nc_value_type; | 776 typedef pair<key_type, mapped_type> __nc_value_type; |
| 783 typedef value_type& reference; | 777 typedef value_type& reference; |
| 784 typedef const value_type& const_reference; | 778 typedef const value_type& const_reference; |
| 785 static_assert((is_same<value_type, typename allocator_type::value_type>::val
ue), | 779 static_assert((is_same<value_type, typename allocator_type::value_type>::val
ue), |
| 786 "Invalid allocator::value_type"); | 780 "Invalid allocator::value_type"); |
| 787 | 781 |
| 788 private: | 782 private: |
| 789 typedef __hash_value_type<key_type, mapped_type> __value_typ
e; | 783 typedef __hash_value_type<key_type, mapped_type> __value_typ
e; |
| 790 typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; | 784 typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; |
| 791 typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal
; | 785 typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal
; |
| 792 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, | 786 typedef typename __rebind_counting_alloc_helper<allocator_traits<allocator_t
ype>, |
| 793 __value_type>::type __allocator
_type; | 787 __value_type>::type __allocator
_type; |
| 794 | 788 |
| 795 typedef __hash_table<__value_type, __hasher, | 789 typedef __hash_table<__value_type, __hasher, |
| 796 __key_equal, __allocator_type> __table; | 790 __key_equal, __allocator_type> __table; |
| 797 | 791 |
| 798 __table __table_; | 792 __table __table_; |
| 799 | 793 |
| 800 typedef typename __table::__node_pointer __node_pointer; | 794 typedef typename __table::__node_pointer __node_pointer; |
| 801 typedef typename __table::__node_const_pointer __node_const_pointer; | 795 typedef typename __table::__node_const_pointer __node_const_pointer; |
| 802 typedef typename __table::__node_traits __node_traits; | 796 typedef typename __table::__node_traits __node_traits; |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 | 1422 |
| 1429 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 1423 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 1430 | 1424 |
| 1431 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1425 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1432 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | 1426 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 1433 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node() | 1427 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node() |
| 1434 { | 1428 { |
| 1435 __node_allocator& __na = __table_.__node_alloc(); | 1429 __node_allocator& __na = __table_.__node_alloc(); |
| 1436 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1430 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1437 __node_traits::construct(__na, _VSTD::addressof(__h->__value_)); | 1431 __node_traits::construct(__na, _VSTD::addressof(__h->__value_)); |
| 1438 __h.get_deleter().__first_constructed = true; | 1432 __h.get_deleter().__constructed = true; |
| 1439 __h.get_deleter().__second_constructed = true; | |
| 1440 return __h; | 1433 return __h; |
| 1441 } | 1434 } |
| 1442 | 1435 |
| 1443 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1436 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1444 template <class _A0> | 1437 template <class _A0> |
| 1445 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | 1438 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 1446 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0) | 1439 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0) |
| 1447 { | 1440 { |
| 1448 __node_allocator& __na = __table_.__node_alloc(); | 1441 __node_allocator& __na = __table_.__node_alloc(); |
| 1449 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1442 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1450 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), | 1443 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), |
| 1451 _VSTD::forward<_A0>(__a0)); | 1444 _VSTD::forward<_A0>(__a0)); |
| 1452 __h.get_deleter().__first_constructed = true; | 1445 __h.get_deleter().__constructed = true; |
| 1453 __h.get_deleter().__second_constructed = true; | |
| 1454 return __h; | 1446 return __h; |
| 1455 } | 1447 } |
| 1456 | 1448 |
| 1457 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1449 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1458 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | 1450 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 1459 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_ty
pe&& __k) | 1451 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_ty
pe&& __k) |
| 1460 { | 1452 { |
| 1461 __node_allocator& __na = __table_.__node_alloc(); | 1453 __node_allocator& __na = __table_.__node_alloc(); |
| 1462 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1454 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1463 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _
VSTD::move(__k)); | 1455 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::piece
wise_construct, |
| 1464 __h.get_deleter().__first_constructed = true; | 1456 _VSTD::forward_as_tuple(_VSTD::move(__k)), _VSTD::f
orward_as_tuple()); |
| 1465 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); | 1457 __h.get_deleter().__constructed = true; |
| 1466 __h.get_deleter().__second_constructed = true; | |
| 1467 return __h; | 1458 return __h; |
| 1468 } | 1459 } |
| 1469 | 1460 |
| 1470 #ifndef _LIBCPP_HAS_NO_VARIADICS | 1461 #ifndef _LIBCPP_HAS_NO_VARIADICS |
| 1471 | 1462 |
| 1472 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1463 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1473 template <class _A0, class _A1, class ..._Args> | 1464 template <class _A0, class _A1, class ..._Args> |
| 1474 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | 1465 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 1475 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0, | 1466 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0, |
| 1476 _A1&& __a1, | 1467 _A1&& __a1, |
| 1477 _Args&&... __ar
gs) | 1468 _Args&&... __ar
gs) |
| 1478 { | 1469 { |
| 1479 __node_allocator& __na = __table_.__node_alloc(); | 1470 __node_allocator& __na = __table_.__node_alloc(); |
| 1480 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1471 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1481 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), | 1472 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), |
| 1482 _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1
), | 1473 _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1
), |
| 1483 _VSTD::forward<_Args>(__args)...); | 1474 _VSTD::forward<_Args>(__args)...); |
| 1484 __h.get_deleter().__first_constructed = true; | 1475 __h.get_deleter().__constructed = true; |
| 1485 __h.get_deleter().__second_constructed = true; | |
| 1486 return __h; | 1476 return __h; |
| 1487 } | 1477 } |
| 1488 | 1478 |
| 1489 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1479 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1490 template <class... _Args> | 1480 template <class... _Args> |
| 1491 pair<typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator, bool> | 1481 pair<typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator, bool> |
| 1492 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args) | 1482 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args) |
| 1493 { | 1483 { |
| 1494 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); | 1484 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); |
| 1495 pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get()); | 1485 pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get()); |
| 1496 if (__r.second) | 1486 if (__r.second) |
| 1497 __h.release(); | 1487 __h.release(); |
| 1498 return __r; | 1488 return __r; |
| 1499 } | 1489 } |
| 1500 | 1490 |
| 1501 #endif // _LIBCPP_HAS_NO_VARIADICS | |
| 1502 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES | |
| 1503 | |
| 1504 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1491 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1505 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | 1492 typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 1506 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const
key_type& __k) | 1493 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const
key_type& __k) |
| 1507 { | 1494 { |
| 1508 __node_allocator& __na = __table_.__node_alloc(); | 1495 __node_allocator& __na = __table_.__node_alloc(); |
| 1509 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1496 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1510 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _
_k); | 1497 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::piece
wise_construct, |
| 1511 __h.get_deleter().__first_constructed = true; | 1498 _VSTD::forward_as_tuple(__k), _VSTD::forward_as_tup
le()); |
| 1512 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); | 1499 __h.get_deleter().__constructed = true; |
| 1513 __h.get_deleter().__second_constructed = true; | 1500 return __h; |
| 1514 return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 | |
| 1515 } | 1501 } |
| 1516 | 1502 |
| 1503 #endif // _LIBCPP_HAS_NO_VARIADICS |
| 1504 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 1505 |
| 1517 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1506 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1518 template <class _InputIterator> | 1507 template <class _InputIterator> |
| 1519 inline _LIBCPP_INLINE_VISIBILITY | 1508 inline _LIBCPP_INLINE_VISIBILITY |
| 1520 void | 1509 void |
| 1521 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, | 1510 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, |
| 1522 _InputIterator __last) | 1511 _InputIterator __last) |
| 1523 { | 1512 { |
| 1524 for (; __first != __last; ++__first) | 1513 for (; __first != __last; ++__first) |
| 1525 __table_.__insert_unique(*__first); | 1514 __table_.__insert_unique(*__first); |
| 1526 } | 1515 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1600 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1612 inline _LIBCPP_INLINE_VISIBILITY | 1601 inline _LIBCPP_INLINE_VISIBILITY |
| 1613 bool | 1602 bool |
| 1614 operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, | 1603 operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 1615 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) | 1604 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) |
| 1616 { | 1605 { |
| 1617 return !(__x == __y); | 1606 return !(__x == __y); |
| 1618 } | 1607 } |
| 1619 | 1608 |
| 1620 template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_t
o<_Key>, | 1609 template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_t
o<_Key>, |
| 1621 class _Alloc = allocator<pair<const _Key, _Tp> > > | 1610 class _Alloc = counting_allocator<pair<const _Key, _Tp>, allocation_gr
oup::unordered_multimap > > |
| 1622 class _LIBCPP_TYPE_VIS_ONLY unordered_multimap | 1611 class _LIBCPP_TYPE_VIS_ONLY unordered_multimap |
| 1623 { | 1612 { |
| 1624 public: | 1613 public: |
| 1625 // types | 1614 // types |
| 1626 typedef _Key key_type; | 1615 typedef _Key key_type; |
| 1627 typedef _Tp mapped_type; | 1616 typedef _Tp mapped_type; |
| 1628 typedef _Hash hasher; | 1617 typedef _Hash hasher; |
| 1629 typedef _Pred key_equal; | 1618 typedef _Pred key_equal; |
| 1630 typedef _Alloc allocator_type; | 1619 typedef _Alloc allocator_type; |
| 1631 typedef pair<const key_type, mapped_type> value_type; | 1620 typedef pair<const key_type, mapped_type> value_type; |
| 1632 typedef pair<key_type, mapped_type> __nc_value_type; | 1621 typedef pair<key_type, mapped_type> __nc_value_type; |
| 1633 typedef value_type& reference; | 1622 typedef value_type& reference; |
| 1634 typedef const value_type& const_reference; | 1623 typedef const value_type& const_reference; |
| 1635 static_assert((is_same<value_type, typename allocator_type::value_type>::val
ue), | 1624 static_assert((is_same<value_type, typename allocator_type::value_type>::val
ue), |
| 1636 "Invalid allocator::value_type"); | 1625 "Invalid allocator::value_type"); |
| 1637 | 1626 |
| 1638 private: | 1627 private: |
| 1639 typedef __hash_value_type<key_type, mapped_type> __value_typ
e; | 1628 typedef __hash_value_type<key_type, mapped_type> __value_typ
e; |
| 1640 typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; | 1629 typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; |
| 1641 typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal
; | 1630 typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal
; |
| 1642 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, | 1631 typedef typename __rebind_counting_alloc_helper<allocator_traits<allocator_t
ype>, |
| 1643 __value_type>::type __allocator
_type; | 1632 __value_type>::type __allocator
_type; |
| 1644 | 1633 |
| 1645 typedef __hash_table<__value_type, __hasher, | 1634 typedef __hash_table<__value_type, __hasher, |
| 1646 __key_equal, __allocator_type> __table; | 1635 __key_equal, __allocator_type> __table; |
| 1647 | 1636 |
| 1648 __table __table_; | 1637 __table __table_; |
| 1649 | 1638 |
| 1650 typedef typename __table::__node_traits __node_traits; | 1639 typedef typename __table::__node_traits __node_traits; |
| 1651 typedef typename __table::__node_allocator __node_allocator; | 1640 typedef typename __table::__node_allocator __node_allocator; |
| 1652 typedef typename __table::__node __node; | 1641 typedef typename __table::__node __node; |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 | 2112 |
| 2124 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 2113 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 2125 | 2114 |
| 2126 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 2115 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2127 typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | 2116 typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 2128 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node() | 2117 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node() |
| 2129 { | 2118 { |
| 2130 __node_allocator& __na = __table_.__node_alloc(); | 2119 __node_allocator& __na = __table_.__node_alloc(); |
| 2131 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 2120 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 2132 __node_traits::construct(__na, _VSTD::addressof(__h->__value_)); | 2121 __node_traits::construct(__na, _VSTD::addressof(__h->__value_)); |
| 2133 __h.get_deleter().__first_constructed = true; | 2122 __h.get_deleter().__constructed = true; |
| 2134 __h.get_deleter().__second_constructed = true; | |
| 2135 return __h; | 2123 return __h; |
| 2136 } | 2124 } |
| 2137 | 2125 |
| 2138 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 2126 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2139 template <class _A0> | 2127 template <class _A0> |
| 2140 typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | 2128 typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 2141 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0
) | 2129 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0
) |
| 2142 { | 2130 { |
| 2143 __node_allocator& __na = __table_.__node_alloc(); | 2131 __node_allocator& __na = __table_.__node_alloc(); |
| 2144 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 2132 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 2145 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), | 2133 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), |
| 2146 _VSTD::forward<_A0>(__a0)); | 2134 _VSTD::forward<_A0>(__a0)); |
| 2147 __h.get_deleter().__first_constructed = true; | 2135 __h.get_deleter().__constructed = true; |
| 2148 __h.get_deleter().__second_constructed = true; | |
| 2149 return __h; | 2136 return __h; |
| 2150 } | 2137 } |
| 2151 | 2138 |
| 2152 #ifndef _LIBCPP_HAS_NO_VARIADICS | 2139 #ifndef _LIBCPP_HAS_NO_VARIADICS |
| 2153 | 2140 |
| 2154 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 2141 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2155 template <class _A0, class _A1, class ..._Args> | 2142 template <class _A0, class _A1, class ..._Args> |
| 2156 typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | 2143 typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 2157 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node( | 2144 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node( |
| 2158 _A0&& __a0, _A1&& __a1, _Args&&... __args) | 2145 _A0&& __a0, _A1&& __a1, _Args&&... __args) |
| 2159 { | 2146 { |
| 2160 __node_allocator& __na = __table_.__node_alloc(); | 2147 __node_allocator& __na = __table_.__node_alloc(); |
| 2161 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 2148 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 2162 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), | 2149 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), |
| 2163 _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1
), | 2150 _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1
), |
| 2164 _VSTD::forward<_Args>(__args)...); | 2151 _VSTD::forward<_Args>(__args)...); |
| 2165 __h.get_deleter().__first_constructed = true; | 2152 __h.get_deleter().__constructed = true; |
| 2166 __h.get_deleter().__second_constructed = true; | |
| 2167 return __h; | 2153 return __h; |
| 2168 } | 2154 } |
| 2169 | 2155 |
| 2170 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 2156 template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2171 template <class... _Args> | 2157 template <class... _Args> |
| 2172 typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator | 2158 typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator |
| 2173 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args) | 2159 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args) |
| 2174 { | 2160 { |
| 2175 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); | 2161 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); |
| 2176 iterator __r = __table_.__node_insert_multi(__h.get()); | 2162 iterator __r = __table_.__node_insert_multi(__h.get()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 bool | 2228 bool |
| 2243 operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, | 2229 operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 2244 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) | 2230 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) |
| 2245 { | 2231 { |
| 2246 return !(__x == __y); | 2232 return !(__x == __y); |
| 2247 } | 2233 } |
| 2248 | 2234 |
| 2249 _LIBCPP_END_NAMESPACE_STD | 2235 _LIBCPP_END_NAMESPACE_STD |
| 2250 | 2236 |
| 2251 #endif // _LIBCPP_UNORDERED_MAP | 2237 #endif // _LIBCPP_UNORDERED_MAP |
| OLD | NEW |