31#ifndef _HASHTABLE_POLICY_H
32#define _HASHTABLE_POLICY_H 1
38namespace std _GLIBCXX_VISIBILITY(default)
40_GLIBCXX_BEGIN_NAMESPACE_VERSION
43 template<
typename _Key,
typename _Value,
typename _Alloc,
44 typename _ExtractKey,
typename _Equal,
45 typename _Hash,
typename _RangeHash,
typename _Unused,
46 typename _RehashPolicy,
typename _Traits>
56 template<
typename _Key,
typename _Value,
typename _ExtractKey,
57 typename _Equal,
typename _Hash,
typename _RangeHash,
58 typename _Unused,
typename _Traits>
59 struct _Hashtable_base;
63 template<
class _Iterator>
65 __distance_fw(_Iterator __first, _Iterator __last,
67 {
return __first != __last ? 1 : 0; }
69 template<
class _Iterator>
71 __distance_fw(_Iterator __first, _Iterator __last,
75 template<
class _Iterator>
77 __distance_fw(_Iterator __first, _Iterator __last)
78 {
return __distance_fw(__first, __last,
83 template<
typename _Tp>
85 operator()(_Tp&& __x)
const noexcept
86 {
return std::forward<_Tp>(__x); }
91 template<
typename _Tp>
93 operator()(_Tp&& __x)
const noexcept
94 ->
decltype(std::get<0>(std::forward<_Tp>(__x)))
95 {
return std::get<0>(std::forward<_Tp>(__x)); }
98 template<
typename _NodeAlloc>
99 struct _Hashtable_alloc;
103 template<
typename _NodeAlloc>
104 struct _ReuseOrAllocNode
107 using __node_alloc_type = _NodeAlloc;
108 using __hashtable_alloc = _Hashtable_alloc<__node_alloc_type>;
109 using __node_alloc_traits =
110 typename __hashtable_alloc::__node_alloc_traits;
111 using __node_type =
typename __hashtable_alloc::__node_type;
114 _ReuseOrAllocNode(__node_type* __nodes, __hashtable_alloc& __h)
115 : _M_nodes(__nodes), _M_h(__h) { }
116 _ReuseOrAllocNode(
const _ReuseOrAllocNode&) =
delete;
119 { _M_h._M_deallocate_nodes(_M_nodes); }
121 template<
typename _Arg>
123 operator()(_Arg&& __arg)
const
127 __node_type* __node = _M_nodes;
128 _M_nodes = _M_nodes->_M_next();
129 __node->_M_nxt =
nullptr;
130 auto& __a = _M_h._M_node_allocator();
131 __node_alloc_traits::destroy(__a, __node->_M_valptr());
134 __node_alloc_traits::construct(__a, __node->_M_valptr(),
135 std::forward<_Arg>(__arg));
139 _M_h._M_deallocate_node_ptr(__node);
140 __throw_exception_again;
144 return _M_h._M_allocate_node(std::forward<_Arg>(__arg));
148 mutable __node_type* _M_nodes;
149 __hashtable_alloc& _M_h;
154 template<
typename _NodeAlloc>
158 using __hashtable_alloc = _Hashtable_alloc<_NodeAlloc>;
159 using __node_type =
typename __hashtable_alloc::__node_type;
162 _AllocNode(__hashtable_alloc& __h)
165 template<
typename _Arg>
167 operator()(_Arg&& __arg)
const
168 {
return _M_h._M_allocate_node(std::forward<_Arg>(__arg)); }
171 __hashtable_alloc& _M_h;
199 template<
bool _Cache_hash_code,
bool _Constant_iterators,
bool _Unique_keys>
200 struct _Hashtable_traits
202 using __hash_cached = __bool_constant<_Cache_hash_code>;
203 using __constant_iterators = __bool_constant<_Constant_iterators>;
204 using __unique_keys = __bool_constant<_Unique_keys>;
215 struct _Hash_node_base
217 _Hash_node_base* _M_nxt;
219 _Hash_node_base() noexcept : _M_nxt() { }
221 _Hash_node_base(_Hash_node_base* __next) noexcept : _M_nxt(__next) { }
229 template<
typename _Value>
230 struct _Hash_node_value_base
232 typedef _Value value_type;
234 __gnu_cxx::__aligned_buffer<_Value> _M_storage;
238 {
return _M_storage._M_ptr(); }
241 _M_valptr() const noexcept
242 {
return _M_storage._M_ptr(); }
246 {
return *_M_valptr(); }
249 _M_v() const noexcept
250 {
return *_M_valptr(); }
256 template<
bool _Cache_hash_code>
257 struct _Hash_node_code_cache
264 struct _Hash_node_code_cache<true>
265 { std::size_t _M_hash_code; };
267 template<
typename _Value,
bool _Cache_hash_code>
268 struct _Hash_node_value
269 : _Hash_node_value_base<_Value>
270 , _Hash_node_code_cache<_Cache_hash_code>
276 template<
typename _Value,
bool _Cache_hash_code>
279 , _Hash_node_value<_Value, _Cache_hash_code>
282 _M_next() const noexcept
283 {
return static_cast<_Hash_node*
>(this->_M_nxt); }
287 template<
typename _Value,
bool _Cache_hash_code>
288 struct _Node_iterator_base
290 using __node_type = _Hash_node<_Value, _Cache_hash_code>;
294 _Node_iterator_base() : _M_cur(nullptr) { }
295 _Node_iterator_base(__node_type* __p) noexcept
300 { _M_cur = _M_cur->_M_next(); }
303 operator==(
const _Node_iterator_base& __x,
const _Node_iterator_base& __y)
305 {
return __x._M_cur == __y._M_cur; }
307#if __cpp_impl_three_way_comparison < 201907L
309 operator!=(
const _Node_iterator_base& __x,
const _Node_iterator_base& __y)
311 {
return __x._M_cur != __y._M_cur; }
316 template<
typename _Value,
bool __constant_iterators,
bool __cache>
317 struct _Node_iterator
318 :
public _Node_iterator_base<_Value, __cache>
321 using __base_type = _Node_iterator_base<_Value, __cache>;
322 using __node_type =
typename __base_type::__node_type;
325 typedef _Value value_type;
326 typedef std::ptrdiff_t difference_type;
330 const value_type*, value_type*>::type;
333 const value_type&, value_type&>::type;
335 _Node_iterator() =
default;
338 _Node_iterator(__node_type* __p) noexcept
339 : __base_type(__p) { }
343 {
return this->_M_cur->_M_v(); }
346 operator->() const noexcept
347 {
return this->_M_cur->_M_valptr(); }
350 operator++() noexcept
357 operator++(
int)
noexcept
359 _Node_iterator __tmp(*
this);
366 template<
typename _Value,
bool __constant_iterators,
bool __cache>
367 struct _Node_const_iterator
368 :
public _Node_iterator_base<_Value, __cache>
371 using __base_type = _Node_iterator_base<_Value, __cache>;
372 using __node_type =
typename __base_type::__node_type;
375 typedef _Value value_type;
376 typedef std::ptrdiff_t difference_type;
379 typedef const value_type* pointer;
380 typedef const value_type& reference;
382 _Node_const_iterator() =
default;
385 _Node_const_iterator(__node_type* __p) noexcept
386 : __base_type(__p) { }
388 _Node_const_iterator(
const _Node_iterator<_Value, __constant_iterators,
389 __cache>& __x) noexcept
390 : __base_type(__x._M_cur) { }
394 {
return this->_M_cur->_M_v(); }
397 operator->() const noexcept
398 {
return this->_M_cur->_M_valptr(); }
400 _Node_const_iterator&
401 operator++() noexcept
408 operator++(
int)
noexcept
410 _Node_const_iterator __tmp(*
this);
421 struct _Mod_range_hashing
423 typedef std::size_t first_argument_type;
424 typedef std::size_t second_argument_type;
425 typedef std::size_t result_type;
428 operator()(first_argument_type __num,
429 second_argument_type __den)
const noexcept
430 {
return __num % __den; }
438 struct _Default_ranged_hash { };
442 struct _Prime_rehash_policy
446 _Prime_rehash_policy(
float __z = 1.0) noexcept
447 : _M_max_load_factor(__z), _M_next_resize(0) { }
450 max_load_factor() const noexcept
451 {
return _M_max_load_factor; }
455 _M_next_bkt(std::size_t __n)
const;
459 _M_bkt_for_elements(std::size_t __n)
const
460 {
return __builtin_ceil(__n / (
double)_M_max_load_factor); }
467 _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
468 std::size_t __n_ins)
const;
470 typedef std::size_t _State;
474 {
return _M_next_resize; }
478 { _M_next_resize = 0; }
481 _M_reset(_State __state)
482 { _M_next_resize = __state; }
484 static const std::size_t _S_growth_factor = 2;
486 float _M_max_load_factor;
487 mutable std::size_t _M_next_resize;
491 struct _Mask_range_hashing
493 typedef std::size_t first_argument_type;
494 typedef std::size_t second_argument_type;
495 typedef std::size_t result_type;
498 operator()(first_argument_type __num,
499 second_argument_type __den)
const noexcept
500 {
return __num & (__den - 1); }
505 __clp2(std::size_t __n)
noexcept
511 const unsigned __lz =
sizeof(size_t) >
sizeof(
long)
512 ? __builtin_clzll(__n - 1ull)
513 : __builtin_clzl(__n - 1ul);
515 return (
size_t(1) << (__int_traits<size_t>::__digits - __lz - 1)) << 1;
520 struct _Power2_rehash_policy
524 _Power2_rehash_policy(
float __z = 1.0) noexcept
525 : _M_max_load_factor(__z), _M_next_resize(0) { }
528 max_load_factor() const noexcept
529 {
return _M_max_load_factor; }
534 _M_next_bkt(std::size_t __n)
noexcept
542 const auto __max_width = std::min<size_t>(
sizeof(
size_t), 8);
543 const auto __max_bkt = size_t(1) << (__max_width * __CHAR_BIT__ - 1);
544 std::size_t __res = __clp2(__n);
554 if (__res == __max_bkt)
558 _M_next_resize = size_t(-1);
561 = __builtin_floor(__res * (
double)_M_max_load_factor);
568 _M_bkt_for_elements(std::size_t __n)
const noexcept
569 {
return __builtin_ceil(__n / (
double)_M_max_load_factor); }
576 _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
577 std::size_t __n_ins)
noexcept
579 if (__n_elt + __n_ins > _M_next_resize)
585 = std::max<std::size_t>(__n_elt + __n_ins, _M_next_resize ? 0 : 11)
586 / (double)_M_max_load_factor;
587 if (__min_bkts >= __n_bkt)
589 _M_next_bkt(std::max<std::size_t>(__builtin_floor(__min_bkts) + 1,
590 __n_bkt * _S_growth_factor)) };
593 = __builtin_floor(__n_bkt * (
double)_M_max_load_factor);
600 typedef std::size_t _State;
603 _M_state() const noexcept
604 {
return _M_next_resize; }
608 { _M_next_resize = 0; }
611 _M_reset(_State __state)
noexcept
612 { _M_next_resize = __state; }
614 static const std::size_t _S_growth_factor = 2;
616 float _M_max_load_factor;
617 std::size_t _M_next_resize;
638 template<
typename _Key,
typename _Value,
typename _Alloc,
639 typename _ExtractKey,
typename _Equal,
640 typename _Hash,
typename _RangeHash,
typename _Unused,
641 typename _RehashPolicy,
typename _Traits,
642 bool _Unique_keys = _Traits::__unique_keys::value>
643 struct _Map_base { };
646 template<
typename _Key,
typename _Pair,
typename _Alloc,
typename _Equal,
647 typename _Hash,
typename _RangeHash,
typename _Unused,
648 typename _RehashPolicy,
typename _Traits>
649 struct _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
650 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false>
656 template<
typename _Key,
typename _Pair,
typename _Alloc,
typename _Equal,
657 typename _Hash,
typename _RangeHash,
typename _Unused,
658 typename _RehashPolicy,
typename _Traits>
659 struct _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
660 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>
663 using __hashtable_base = _Hashtable_base<_Key, _Pair, _Select1st, _Equal,
664 _Hash, _RangeHash, _Unused,
667 using __hashtable = _Hashtable<_Key, _Pair, _Alloc, _Select1st, _Equal,
669 _Unused, _RehashPolicy, _Traits>;
671 using __hash_code =
typename __hashtable_base::__hash_code;
674 using key_type =
typename __hashtable_base::key_type;
678 operator[](
const key_type& __k);
681 operator[](key_type&& __k);
686 at(
const key_type& __k);
689 at(
const key_type& __k)
const;
692 template<
typename _Key,
typename _Pair,
typename _Alloc,
typename _Equal,
693 typename _Hash,
typename _RangeHash,
typename _Unused,
694 typename _RehashPolicy,
typename _Traits>
696 _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
697 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
true>::
698 operator[](
const key_type& __k)
701 __hashtable* __h =
static_cast<__hashtable*
>(
this);
702 __hash_code __code = __h->_M_hash_code(__k);
703 std::size_t __bkt = __h->_M_bucket_index(__code);
704 if (
auto __node = __h->_M_find_node(__bkt, __k, __code))
705 return __node->_M_v().second;
707 typename __hashtable::_Scoped_node __node {
714 = __h->_M_insert_unique_node(__bkt, __code, __node._M_node);
715 __node._M_node =
nullptr;
716 return __pos->second;
719 template<
typename _Key,
typename _Pair,
typename _Alloc,
typename _Equal,
720 typename _Hash,
typename _RangeHash,
typename _Unused,
721 typename _RehashPolicy,
typename _Traits>
723 _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
724 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
true>::
725 operator[](key_type&& __k)
728 __hashtable* __h =
static_cast<__hashtable*
>(
this);
729 __hash_code __code = __h->_M_hash_code(__k);
730 std::size_t __bkt = __h->_M_bucket_index(__code);
731 if (
auto __node = __h->_M_find_node(__bkt, __k, __code))
732 return __node->_M_v().second;
734 typename __hashtable::_Scoped_node __node {
741 = __h->_M_insert_unique_node(__bkt, __code, __node._M_node);
742 __node._M_node =
nullptr;
743 return __pos->second;
746 template<
typename _Key,
typename _Pair,
typename _Alloc,
typename _Equal,
747 typename _Hash,
typename _RangeHash,
typename _Unused,
748 typename _RehashPolicy,
typename _Traits>
750 _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
751 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
true>::
752 at(
const key_type& __k)
755 __hashtable* __h =
static_cast<__hashtable*
>(
this);
756 auto __ite = __h->find(__k);
759 __throw_out_of_range(__N(
"_Map_base::at"));
760 return __ite->second;
763 template<
typename _Key,
typename _Pair,
typename _Alloc,
typename _Equal,
764 typename _Hash,
typename _RangeHash,
typename _Unused,
765 typename _RehashPolicy,
typename _Traits>
767 _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
768 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
true>::
769 at(
const key_type& __k)
const
770 ->
const mapped_type&
772 const __hashtable* __h =
static_cast<const __hashtable*
>(
this);
773 auto __ite = __h->find(__k);
776 __throw_out_of_range(__N(
"_Map_base::at"));
777 return __ite->second;
785 template<
typename _Key,
typename _Value,
typename _Alloc,
786 typename _ExtractKey,
typename _Equal,
787 typename _Hash,
typename _RangeHash,
typename _Unused,
788 typename _RehashPolicy,
typename _Traits>
792 using __hashtable_base = _Hashtable_base<_Key, _Value, _ExtractKey,
793 _Equal, _Hash, _RangeHash,
796 using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
798 _Unused, _RehashPolicy, _Traits>;
800 using __hash_cached =
typename _Traits::__hash_cached;
801 using __constant_iterators =
typename _Traits::__constant_iterators;
803 using __hashtable_alloc = _Hashtable_alloc<
804 __alloc_rebind<_Alloc, _Hash_node<_Value,
805 __hash_cached::value>>>;
807 using value_type =
typename __hashtable_base::value_type;
808 using size_type =
typename __hashtable_base::size_type;
810 using __unique_keys =
typename _Traits::__unique_keys;
811 using __node_alloc_type =
typename __hashtable_alloc::__node_alloc_type;
812 using __node_gen_type = _AllocNode<__node_alloc_type>;
815 _M_conjure_hashtable()
816 {
return *(
static_cast<__hashtable*
>(
this)); }
818 template<
typename _InputIterator,
typename _NodeGetter>
820 _M_insert_range(_InputIterator __first, _InputIterator __last,
821 const _NodeGetter&, true_type __uks);
823 template<
typename _InputIterator,
typename _NodeGetter>
825 _M_insert_range(_InputIterator __first, _InputIterator __last,
826 const _NodeGetter&, false_type __uks);
829 using iterator = _Node_iterator<_Value, __constant_iterators::value,
830 __hash_cached::value>;
832 using const_iterator = _Node_const_iterator<_Value, __constant_iterators::value,
833 __hash_cached::value>;
840 insert(
const value_type& __v)
842 __hashtable& __h = _M_conjure_hashtable();
843 __node_gen_type __node_gen(__h);
844 return __h._M_insert(__v, __node_gen, __unique_keys{});
848 insert(const_iterator __hint,
const value_type& __v)
850 __hashtable& __h = _M_conjure_hashtable();
851 __node_gen_type __node_gen(__h);
852 return __h._M_insert(__hint, __v, __node_gen, __unique_keys{});
855 template<
typename _KType,
typename... _Args>
857 try_emplace(const_iterator, _KType&& __k, _Args&&... __args)
859 __hashtable& __h = _M_conjure_hashtable();
860 auto __code = __h._M_hash_code(__k);
861 std::size_t __bkt = __h._M_bucket_index(__code);
862 if (
auto __node = __h._M_find_node(__bkt, __k, __code))
863 return { iterator(__node),
false };
865 typename __hashtable::_Scoped_node __node {
872 = __h._M_insert_unique_node(__bkt, __code, __node._M_node);
873 __node._M_node =
nullptr;
874 return { __it,
true };
878 insert(initializer_list<value_type> __l)
879 { this->insert(__l.begin(), __l.end()); }
881 template<
typename _InputIterator>
883 insert(_InputIterator __first, _InputIterator __last)
885 __hashtable& __h = _M_conjure_hashtable();
886 __node_gen_type __node_gen(__h);
887 return _M_insert_range(__first, __last, __node_gen, __unique_keys{});
891 template<
typename _Key,
typename _Value,
typename _Alloc,
892 typename _ExtractKey,
typename _Equal,
893 typename _Hash,
typename _RangeHash,
typename _Unused,
894 typename _RehashPolicy,
typename _Traits>
895 template<
typename _InputIterator,
typename _NodeGetter>
897 _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
898 _Hash, _RangeHash, _Unused,
899 _RehashPolicy, _Traits>::
900 _M_insert_range(_InputIterator __first, _InputIterator __last,
901 const _NodeGetter& __node_gen,
true_type __uks)
903 __hashtable& __h = _M_conjure_hashtable();
904 for (; __first != __last; ++__first)
905 __h._M_insert(*__first, __node_gen, __uks);
908 template<
typename _Key,
typename _Value,
typename _Alloc,
909 typename _ExtractKey,
typename _Equal,
910 typename _Hash,
typename _RangeHash,
typename _Unused,
911 typename _RehashPolicy,
typename _Traits>
912 template<
typename _InputIterator,
typename _NodeGetter>
914 _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
915 _Hash, _RangeHash, _Unused,
916 _RehashPolicy, _Traits>::
917 _M_insert_range(_InputIterator __first, _InputIterator __last,
918 const _NodeGetter& __node_gen,
false_type __uks)
920 using __rehash_type =
typename __hashtable::__rehash_type;
921 using __rehash_state =
typename __hashtable::__rehash_state;
924 size_type __n_elt = __detail::__distance_fw(__first, __last);
928 __hashtable& __h = _M_conjure_hashtable();
929 __rehash_type& __rehash = __h._M_rehash_policy;
930 const __rehash_state& __saved_state = __rehash._M_state();
931 pair_type __do_rehash = __rehash._M_need_rehash(__h._M_bucket_count,
932 __h._M_element_count,
935 if (__do_rehash.first)
936 __h._M_rehash(__do_rehash.second, __saved_state);
938 for (; __first != __last; ++__first)
939 __h._M_insert(*__first, __node_gen, __uks);
948 template<
typename _Key,
typename _Value,
typename _Alloc,
949 typename _ExtractKey,
typename _Equal,
950 typename _Hash,
typename _RangeHash,
typename _Unused,
951 typename _RehashPolicy,
typename _Traits,
952 bool _Constant_iterators = _Traits::__constant_iterators::value>
956 template<
typename _Key,
typename _Value,
typename _Alloc,
957 typename _ExtractKey,
typename _Equal,
958 typename _Hash,
typename _RangeHash,
typename _Unused,
959 typename _RehashPolicy,
typename _Traits>
960 struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal,
961 _Hash, _RangeHash, _Unused,
962 _RehashPolicy, _Traits, true>
963 :
public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
964 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>
966 using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey,
967 _Equal, _Hash, _RangeHash, _Unused,
968 _RehashPolicy, _Traits>;
970 using value_type =
typename __base_type::value_type;
971 using iterator =
typename __base_type::iterator;
972 using const_iterator =
typename __base_type::const_iterator;
973 using __ireturn_type =
typename __base_type::__ireturn_type;
975 using __unique_keys =
typename __base_type::__unique_keys;
976 using __hashtable =
typename __base_type::__hashtable;
977 using __node_gen_type =
typename __base_type::__node_gen_type;
979 using __base_type::insert;
982 insert(value_type&& __v)
984 __hashtable& __h = this->_M_conjure_hashtable();
985 __node_gen_type __node_gen(__h);
986 return __h._M_insert(
std::move(__v), __node_gen, __unique_keys{});
990 insert(const_iterator __hint, value_type&& __v)
992 __hashtable& __h = this->_M_conjure_hashtable();
993 __node_gen_type __node_gen(__h);
994 return __h._M_insert(__hint,
std::move(__v), __node_gen,
1000 template<
typename _Key,
typename _Value,
typename _Alloc,
1001 typename _ExtractKey,
typename _Equal,
1002 typename _Hash,
typename _RangeHash,
typename _Unused,
1003 typename _RehashPolicy,
typename _Traits>
1004 struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1005 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false>
1006 :
public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1007 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>
1009 using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey,
1010 _Equal, _Hash, _RangeHash, _Unused,
1011 _RehashPolicy, _Traits>;
1012 using value_type =
typename __base_type::value_type;
1013 using iterator =
typename __base_type::iterator;
1014 using const_iterator =
typename __base_type::const_iterator;
1016 using __unique_keys =
typename __base_type::__unique_keys;
1017 using __hashtable =
typename __base_type::__hashtable;
1018 using __ireturn_type =
typename __base_type::__ireturn_type;
1020 using __base_type::insert;
1022 template<
typename _Pair>
1025 template<
typename _Pair>
1028 template<
typename _Pair>
1029 using _IFconsp =
typename _IFcons<_Pair>::type;
1031 template<
typename _Pair,
typename = _IFconsp<_Pair>>
1035 __hashtable& __h = this->_M_conjure_hashtable();
1036 return __h._M_emplace(__unique_keys{}, std::forward<_Pair>(__v));
1039 template<
typename _Pair,
typename = _IFconsp<_Pair>>
1041 insert(const_iterator __hint, _Pair&& __v)
1043 __hashtable& __h = this->_M_conjure_hashtable();
1044 return __h._M_emplace(__hint, __unique_keys{},
1045 std::forward<_Pair>(__v));
1049 template<
typename _Policy>
1050 using __has_load_factor =
typename _Policy::__has_load_factor;
1058 template<
typename _Key,
typename _Value,
typename _Alloc,
1059 typename _ExtractKey,
typename _Equal,
1060 typename _Hash,
typename _RangeHash,
typename _Unused,
1061 typename _RehashPolicy,
typename _Traits,
1063 __detected_or_t<false_type, __has_load_factor, _RehashPolicy>>
1064 struct _Rehash_base;
1067 template<
typename _Key,
typename _Value,
typename _Alloc,
1068 typename _ExtractKey,
typename _Equal,
1069 typename _Hash,
typename _RangeHash,
typename _Unused,
1070 typename _RehashPolicy,
typename _Traits>
1071 struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1072 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
1078 template<
typename _Key,
typename _Value,
typename _Alloc,
1079 typename _ExtractKey,
typename _Equal,
1080 typename _Hash,
typename _RangeHash,
typename _Unused,
1081 typename _RehashPolicy,
typename _Traits>
1082 struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1083 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
1086 using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey,
1087 _Equal, _Hash, _RangeHash, _Unused,
1088 _RehashPolicy, _Traits>;
1091 max_load_factor() const noexcept
1093 const __hashtable* __this =
static_cast<const __hashtable*
>(
this);
1094 return __this->__rehash_policy().max_load_factor();
1098 max_load_factor(
float __z)
1100 __hashtable* __this =
static_cast<__hashtable*
>(
this);
1101 __this->__rehash_policy(_RehashPolicy(__z));
1105 reserve(std::size_t __n)
1107 __hashtable* __this =
static_cast<__hashtable*
>(
this);
1108 __this->rehash(__this->__rehash_policy()._M_bkt_for_elements(__n));
1118 template<
int _Nm,
typename _Tp,
1119 bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
1120 struct _Hashtable_ebo_helper;
1123 template<
int _Nm,
typename _Tp>
1124 struct _Hashtable_ebo_helper<_Nm, _Tp, true>
1127 _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
1129 template<
typename _OtherTp>
1130 _Hashtable_ebo_helper(_OtherTp&& __tp)
1134 const _Tp& _M_cget()
const {
return static_cast<const _Tp&
>(*this); }
1135 _Tp& _M_get() {
return static_cast<_Tp&
>(*this); }
1139 template<
int _Nm,
typename _Tp>
1140 struct _Hashtable_ebo_helper<_Nm, _Tp, false>
1142 _Hashtable_ebo_helper() =
default;
1144 template<
typename _OtherTp>
1145 _Hashtable_ebo_helper(_OtherTp&& __tp)
1149 const _Tp& _M_cget()
const {
return _M_tp; }
1150 _Tp& _M_get() {
return _M_tp; }
1162 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1163 typename _Hash,
typename _RangeHash,
typename _Unused,
1164 bool __cache_hash_code>
1165 struct _Local_iterator_base;
1185 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1186 typename _Hash,
typename _RangeHash,
typename _Unused,
1187 bool __cache_hash_code>
1188 struct _Hash_code_base
1189 :
private _Hashtable_ebo_helper<1, _Hash>
1192 using __ebo_hash = _Hashtable_ebo_helper<1, _Hash>;
1195 friend struct _Local_iterator_base<_Key, _Value, _ExtractKey,
1196 _Hash, _RangeHash, _Unused, false>;
1199 typedef _Hash hasher;
1202 hash_function()
const
1203 {
return _M_hash(); }
1206 typedef std::size_t __hash_code;
1210 _Hash_code_base() =
default;
1212 _Hash_code_base(
const _Hash& __hash) : __ebo_hash(__hash) { }
1215 _M_hash_code(
const _Key& __k)
const
1217 static_assert(__is_invocable<const _Hash&, const _Key&>{},
1218 "hash function must be invocable with an argument of key type");
1219 return _M_hash()(__k);
1222 template<
typename _Kt>
1224 _M_hash_code_tr(
const _Kt& __k)
const
1226 static_assert(__is_invocable<const _Hash&, const _Kt&>{},
1227 "hash function must be invocable with an argument of key type");
1228 return _M_hash()(__k);
1232 _M_bucket_index(__hash_code __c, std::size_t __bkt_count)
const
1233 {
return _RangeHash{}(__c, __bkt_count); }
1236 _M_bucket_index(
const _Hash_node_value<_Value, false>& __n,
1237 std::size_t __bkt_count)
const
1238 noexcept(
noexcept(declval<const _Hash&>()(declval<const _Key&>()))
1239 &&
noexcept(declval<const _RangeHash&>()((__hash_code)0,
1242 return _RangeHash{}(_M_hash_code(_ExtractKey{}(__n._M_v())),
1247 _M_bucket_index(
const _Hash_node_value<_Value, true>& __n,
1248 std::size_t __bkt_count)
const
1249 noexcept(
noexcept(declval<const _RangeHash&>()((__hash_code)0,
1251 {
return _RangeHash{}(__n._M_hash_code, __bkt_count); }
1254 _M_store_code(_Hash_node_code_cache<false>&, __hash_code)
const
1258 _M_copy_code(_Hash_node_code_cache<false>&,
1259 const _Hash_node_code_cache<false>&)
const
1263 _M_store_code(_Hash_node_code_cache<true>& __n, __hash_code __c)
const
1264 { __n._M_hash_code = __c; }
1267 _M_copy_code(_Hash_node_code_cache<true>& __to,
1268 const _Hash_node_code_cache<true>& __from)
const
1269 { __to._M_hash_code = __from._M_hash_code; }
1272 _M_swap(_Hash_code_base& __x)
1273 {
std::swap(__ebo_hash::_M_get(), __x.__ebo_hash::_M_get()); }
1276 _M_hash()
const {
return __ebo_hash::_M_cget(); }
1280 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1281 typename _Hash,
typename _RangeHash,
typename _Unused>
1282 struct _Local_iterator_base<_Key, _Value, _ExtractKey,
1283 _Hash, _RangeHash, _Unused, true>
1284 :
public _Node_iterator_base<_Value, true>
1287 using __base_node_iter = _Node_iterator_base<_Value, true>;
1288 using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey,
1289 _Hash, _RangeHash, _Unused,
true>;
1291 _Local_iterator_base() =
default;
1292 _Local_iterator_base(
const __hash_code_base&,
1293 _Hash_node<_Value, true>* __p,
1294 std::size_t __bkt, std::size_t __bkt_count)
1295 : __base_node_iter(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count)
1301 __base_node_iter::_M_incr();
1305 = _RangeHash{}(this->_M_cur->_M_hash_code, _M_bucket_count);
1306 if (__bkt != _M_bucket)
1307 this->_M_cur =
nullptr;
1311 std::size_t _M_bucket;
1312 std::size_t _M_bucket_count;
1316 _M_get_bucket()
const {
return _M_bucket; }
1323 template<typename _Tp, bool _IsEmpty = std::is_empty<_Tp>::value>
1324 struct _Hash_code_storage
1326 __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
1329 _M_h() {
return _M_storage._M_ptr(); }
1332 _M_h()
const {
return _M_storage._M_ptr(); }
1336 template<
typename _Tp>
1337 struct _Hash_code_storage<_Tp, true>
1344 _M_h() {
return reinterpret_cast<_Tp*
>(
this); }
1347 _M_h()
const {
return reinterpret_cast<const _Tp*
>(
this); }
1350 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1351 typename _Hash,
typename _RangeHash,
typename _Unused>
1352 using __hash_code_for_local_iter
1353 = _Hash_code_storage<_Hash_code_base<_Key, _Value, _ExtractKey,
1354 _Hash, _RangeHash, _Unused,
false>>;
1357 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1358 typename _Hash,
typename _RangeHash,
typename _Unused>
1359 struct _Local_iterator_base<_Key, _Value, _ExtractKey,
1360 _Hash, _RangeHash, _Unused, false>
1361 : __hash_code_for_local_iter<_Key, _Value, _ExtractKey, _Hash, _RangeHash,
1363 , _Node_iterator_base<_Value, false>
1366 using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey,
1367 _Hash, _RangeHash, _Unused,
false>;
1368 using __node_iter_base = _Node_iterator_base<_Value, false>;
1370 _Local_iterator_base() : _M_bucket_count(-1) { }
1372 _Local_iterator_base(
const __hash_code_base& __base,
1373 _Hash_node<_Value, false>* __p,
1374 std::size_t __bkt, std::size_t __bkt_count)
1375 : __node_iter_base(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count)
1376 { _M_init(__base); }
1378 ~_Local_iterator_base()
1380 if (_M_bucket_count !=
size_t(-1))
1384 _Local_iterator_base(
const _Local_iterator_base& __iter)
1385 : __node_iter_base(__iter._M_cur), _M_bucket(__iter._M_bucket)
1386 , _M_bucket_count(__iter._M_bucket_count)
1388 if (_M_bucket_count !=
size_t(-1))
1389 _M_init(*__iter._M_h());
1392 _Local_iterator_base&
1393 operator=(
const _Local_iterator_base& __iter)
1395 if (_M_bucket_count != -1)
1397 this->_M_cur = __iter._M_cur;
1398 _M_bucket = __iter._M_bucket;
1399 _M_bucket_count = __iter._M_bucket_count;
1400 if (_M_bucket_count != -1)
1401 _M_init(*__iter._M_h());
1408 __node_iter_base::_M_incr();
1411 std::size_t __bkt = this->_M_h()->_M_bucket_index(*this->_M_cur,
1413 if (__bkt != _M_bucket)
1414 this->_M_cur =
nullptr;
1418 std::size_t _M_bucket;
1419 std::size_t _M_bucket_count;
1422 _M_init(
const __hash_code_base& __base)
1423 { ::new(this->_M_h()) __hash_code_base(__base); }
1426 _M_destroy() { this->_M_h()->~__hash_code_base(); }
1430 _M_get_bucket()
const {
return _M_bucket; }
1434 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1435 typename _Hash,
typename _RangeHash,
typename _Unused,
1436 bool __constant_iterators,
bool __cache>
1437 struct _Local_iterator
1438 :
public _Local_iterator_base<_Key, _Value, _ExtractKey,
1439 _Hash, _RangeHash, _Unused, __cache>
1442 using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey,
1443 _Hash, _RangeHash, _Unused, __cache>;
1444 using __hash_code_base =
typename __base_type::__hash_code_base;
1447 typedef _Value value_type;
1449 const value_type*, value_type*>::type
1452 const value_type&, value_type&>::type
1454 typedef std::ptrdiff_t difference_type;
1457 _Local_iterator() =
default;
1459 _Local_iterator(
const __hash_code_base& __base,
1460 _Hash_node<_Value, __cache>* __n,
1461 std::size_t __bkt, std::size_t __bkt_count)
1462 : __base_type(
__base, __n, __bkt, __bkt_count)
1467 {
return this->_M_cur->_M_v(); }
1471 {
return this->_M_cur->_M_valptr(); }
1483 _Local_iterator __tmp(*
this);
1490 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1491 typename _Hash,
typename _RangeHash,
typename _Unused,
1492 bool __constant_iterators,
bool __cache>
1493 struct _Local_const_iterator
1494 :
public _Local_iterator_base<_Key, _Value, _ExtractKey,
1495 _Hash, _RangeHash, _Unused, __cache>
1498 using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey,
1499 _Hash, _RangeHash, _Unused, __cache>;
1500 using __hash_code_base =
typename __base_type::__hash_code_base;
1503 typedef _Value value_type;
1504 typedef const value_type* pointer;
1505 typedef const value_type& reference;
1506 typedef std::ptrdiff_t difference_type;
1509 _Local_const_iterator() =
default;
1511 _Local_const_iterator(
const __hash_code_base& __base,
1512 _Hash_node<_Value, __cache>* __n,
1513 std::size_t __bkt, std::size_t __bkt_count)
1514 : __base_type(
__base, __n, __bkt, __bkt_count)
1517 _Local_const_iterator(
const _Local_iterator<_Key, _Value, _ExtractKey,
1518 _Hash, _RangeHash, _Unused,
1519 __constant_iterators,
1526 {
return this->_M_cur->_M_v(); }
1530 {
return this->_M_cur->_M_valptr(); }
1532 _Local_const_iterator&
1539 _Local_const_iterator
1542 _Local_const_iterator __tmp(*
this);
1558 template<
typename _Key,
typename _Value,
typename _ExtractKey,
1559 typename _Equal,
typename _Hash,
typename _RangeHash,
1560 typename _Unused,
typename _Traits>
1561 struct _Hashtable_base
1562 :
public _Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash,
1563 _Unused, _Traits::__hash_cached::value>,
1564 private _Hashtable_ebo_helper<0, _Equal>
1567 typedef _Key key_type;
1568 typedef _Value value_type;
1569 typedef _Equal key_equal;
1570 typedef std::size_t size_type;
1571 typedef std::ptrdiff_t difference_type;
1573 using __traits_type = _Traits;
1574 using __hash_cached =
typename __traits_type::__hash_cached;
1576 using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey,
1577 _Hash, _RangeHash, _Unused,
1578 __hash_cached::value>;
1580 using __hash_code =
typename __hash_code_base::__hash_code;
1583 using _EqualEBO = _Hashtable_ebo_helper<0, _Equal>;
1586 _S_equals(__hash_code,
const _Hash_node_code_cache<false>&)
1590 _S_node_equals(
const _Hash_node_code_cache<false>&,
1591 const _Hash_node_code_cache<false>&)
1595 _S_equals(__hash_code __c,
const _Hash_node_code_cache<true>& __n)
1596 {
return __c == __n._M_hash_code; }
1599 _S_node_equals(
const _Hash_node_code_cache<true>& __lhn,
1600 const _Hash_node_code_cache<true>& __rhn)
1601 {
return __lhn._M_hash_code == __rhn._M_hash_code; }
1604 _Hashtable_base() =
default;
1606 _Hashtable_base(
const _Hash& __hash,
const _Equal& __eq)
1607 : __hash_code_base(__hash), _EqualEBO(__eq)
1611 _M_equals(
const _Key& __k, __hash_code __c,
1612 const _Hash_node_value<_Value, __hash_cached::value>& __n)
const
1614 static_assert(__is_invocable<const _Equal&, const _Key&, const _Key&>{},
1615 "key equality predicate must be invocable with two arguments of "
1617 return _S_equals(__c, __n) && _M_eq()(__k, _ExtractKey{}(__n._M_v()));
1620 template<
typename _Kt>
1622 _M_equals_tr(
const _Kt& __k, __hash_code __c,
1623 const _Hash_node_value<_Value,
1624 __hash_cached::value>& __n)
const
1627 __is_invocable<const _Equal&, const _Kt&, const _Key&>{},
1628 "key equality predicate must be invocable with two arguments of "
1630 return _S_equals(__c, __n) && _M_eq()(__k, _ExtractKey{}(__n._M_v()));
1635 const _Hash_node_value<_Value, __hash_cached::value>& __lhn,
1636 const _Hash_node_value<_Value, __hash_cached::value>& __rhn)
const
1638 return _S_node_equals(__lhn, __rhn)
1639 && _M_eq()(_ExtractKey{}(__lhn._M_v()), _ExtractKey{}(__rhn._M_v()));
1643 _M_swap(_Hashtable_base& __x)
1645 __hash_code_base::_M_swap(__x);
1646 std::swap(_EqualEBO::_M_get(), __x._EqualEBO::_M_get());
1650 _M_eq()
const {
return _EqualEBO::_M_cget(); }
1661 template<
typename _Key,
typename _Value,
typename _Alloc,
1662 typename _ExtractKey,
typename _Equal,
1663 typename _Hash,
typename _RangeHash,
typename _Unused,
1664 typename _RehashPolicy,
typename _Traits,
1665 bool _Unique_keys = _Traits::__unique_keys::value>
1669 template<
typename _Key,
typename _Value,
typename _Alloc,
1670 typename _ExtractKey,
typename _Equal,
1671 typename _Hash,
typename _RangeHash,
typename _Unused,
1672 typename _RehashPolicy,
typename _Traits>
1673 struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1674 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>
1676 using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1677 _Hash, _RangeHash, _Unused,
1678 _RehashPolicy, _Traits>;
1681 _M_equal(
const __hashtable&)
const;
1684 template<
typename _Key,
typename _Value,
typename _Alloc,
1685 typename _ExtractKey,
typename _Equal,
1686 typename _Hash,
typename _RangeHash,
typename _Unused,
1687 typename _RehashPolicy,
typename _Traits>
1689 _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1690 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
true>::
1691 _M_equal(
const __hashtable& __other)
const
1693 using __node_type =
typename __hashtable::__node_type;
1694 const __hashtable* __this =
static_cast<const __hashtable*
>(
this);
1695 if (__this->size() != __other.size())
1698 for (
auto __itx = __this->begin(); __itx != __this->end(); ++__itx)
1700 std::size_t __ybkt = __other._M_bucket_index(*__itx._M_cur);
1701 auto __prev_n = __other._M_buckets[__ybkt];
1705 for (__node_type* __n =
static_cast<__node_type*
>(__prev_n->_M_nxt);;
1706 __n = __n->_M_next())
1708 if (__n->_M_v() == *__itx)
1712 || __other._M_bucket_index(*__n->_M_next()) != __ybkt)
1721 template<
typename _Key,
typename _Value,
typename _Alloc,
1722 typename _ExtractKey,
typename _Equal,
1723 typename _Hash,
typename _RangeHash,
typename _Unused,
1724 typename _RehashPolicy,
typename _Traits>
1725 struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1726 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false>
1728 using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1729 _Hash, _RangeHash, _Unused,
1730 _RehashPolicy, _Traits>;
1733 _M_equal(
const __hashtable&)
const;
1736 template<
typename _Key,
typename _Value,
typename _Alloc,
1737 typename _ExtractKey,
typename _Equal,
1738 typename _Hash,
typename _RangeHash,
typename _Unused,
1739 typename _RehashPolicy,
typename _Traits>
1741 _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
1742 _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits,
false>::
1743 _M_equal(
const __hashtable& __other)
const
1745 using __node_type =
typename __hashtable::__node_type;
1746 const __hashtable* __this =
static_cast<const __hashtable*
>(
this);
1747 if (__this->size() != __other.size())
1750 for (
auto __itx = __this->begin(); __itx != __this->end();)
1752 std::size_t __x_count = 1;
1753 auto __itx_end = __itx;
1754 for (++__itx_end; __itx_end != __this->end()
1755 && __this->key_eq()(_ExtractKey{}(*__itx),
1756 _ExtractKey{}(*__itx_end));
1760 std::size_t __ybkt = __other._M_bucket_index(*__itx._M_cur);
1761 auto __y_prev_n = __other._M_buckets[__ybkt];
1765 __node_type* __y_n =
static_cast<__node_type*
>(__y_prev_n->_M_nxt);
1768 if (__this->key_eq()(_ExtractKey{}(__y_n->_M_v()),
1769 _ExtractKey{}(*__itx)))
1772 auto __y_ref_n = __y_n;
1773 for (__y_n = __y_n->_M_next(); __y_n; __y_n = __y_n->_M_next())
1774 if (!__other._M_node_equals(*__y_ref_n, *__y_n))
1777 if (!__y_n || __other._M_bucket_index(*__y_n) != __ybkt)
1781 typename __hashtable::const_iterator __ity(__y_n);
1782 for (
auto __ity_end = __ity; __ity_end != __other.end(); ++__ity_end)
1783 if (--__x_count == 0)
1789 if (!std::is_permutation(__itx, __itx_end, __ity))
1801 template<
typename _NodeAlloc>
1802 struct _Hashtable_alloc :
private _Hashtable_ebo_helper<0, _NodeAlloc>
1805 using __ebo_node_alloc = _Hashtable_ebo_helper<0, _NodeAlloc>;
1807 using __node_type =
typename _NodeAlloc::value_type;
1808 using __node_alloc_type = _NodeAlloc;
1812 using __value_alloc_traits =
typename __node_alloc_traits::template
1813 rebind_traits<typename __node_type::value_type>;
1815 using __node_ptr = __node_type*;
1816 using __node_base = _Hash_node_base;
1817 using __node_base_ptr = __node_base*;
1818 using __buckets_alloc_type =
1819 __alloc_rebind<__node_alloc_type, __node_base_ptr>;
1821 using __buckets_ptr = __node_base_ptr*;
1823 _Hashtable_alloc() =
default;
1824 _Hashtable_alloc(
const _Hashtable_alloc&) =
default;
1825 _Hashtable_alloc(_Hashtable_alloc&&) =
default;
1827 template<
typename _Alloc>
1828 _Hashtable_alloc(_Alloc&& __a)
1829 : __ebo_node_alloc(
std::
forward<_Alloc>(__a))
1834 {
return __ebo_node_alloc::_M_get(); }
1836 const __node_alloc_type&
1837 _M_node_allocator()
const
1838 {
return __ebo_node_alloc::_M_cget(); }
1841 template<
typename... _Args>
1843 _M_allocate_node(_Args&&... __args);
1847 _M_deallocate_node(__node_ptr __n);
1851 _M_deallocate_node_ptr(__node_ptr __n);
1856 _M_deallocate_nodes(__node_ptr __n);
1859 _M_allocate_buckets(std::size_t __bkt_count);
1862 _M_deallocate_buckets(__buckets_ptr, std::size_t __bkt_count);
1867 template<
typename _NodeAlloc>
1868 template<
typename... _Args>
1870 _Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&&... __args)
1873 auto __nptr = __node_alloc_traits::allocate(_M_node_allocator(), 1);
1874 __node_ptr __n = std::__to_address(__nptr);
1877 ::new ((
void*)__n) __node_type;
1878 __node_alloc_traits::construct(_M_node_allocator(),
1880 std::forward<_Args>(__args)...);
1885 __node_alloc_traits::deallocate(_M_node_allocator(), __nptr, 1);
1886 __throw_exception_again;
1890 template<
typename _NodeAlloc>
1892 _Hashtable_alloc<_NodeAlloc>::_M_deallocate_node(__node_ptr __n)
1894 __node_alloc_traits::destroy(_M_node_allocator(), __n->_M_valptr());
1895 _M_deallocate_node_ptr(__n);
1898 template<
typename _NodeAlloc>
1900 _Hashtable_alloc<_NodeAlloc>::_M_deallocate_node_ptr(__node_ptr __n)
1902 typedef typename __node_alloc_traits::pointer _Ptr;
1904 __n->~__node_type();
1905 __node_alloc_traits::deallocate(_M_node_allocator(), __ptr, 1);
1908 template<
typename _NodeAlloc>
1910 _Hashtable_alloc<_NodeAlloc>::_M_deallocate_nodes(__node_ptr __n)
1914 __node_ptr __tmp = __n;
1915 __n = __n->_M_next();
1916 _M_deallocate_node(__tmp);
1920 template<
typename _NodeAlloc>
1922 _Hashtable_alloc<_NodeAlloc>::_M_allocate_buckets(std::size_t __bkt_count)
1925 __buckets_alloc_type __alloc(_M_node_allocator());
1927 auto __ptr = __buckets_alloc_traits::allocate(__alloc, __bkt_count);
1928 __buckets_ptr __p = std::__to_address(__ptr);
1929 __builtin_memset(__p, 0, __bkt_count *
sizeof(__node_base_ptr));
1933 template<
typename _NodeAlloc>
1935 _Hashtable_alloc<_NodeAlloc>::
1936 _M_deallocate_buckets(__buckets_ptr __bkts,
1937 std::size_t __bkt_count)
1939 typedef typename __buckets_alloc_traits::pointer _Ptr;
1941 __buckets_alloc_type __alloc(_M_node_allocator());
1942 __buckets_alloc_traits::deallocate(__alloc, __ptr, __bkt_count);
1948_GLIBCXX_END_NAMESPACE_VERSION
constexpr duration< __common_rep_t< _Rep2, _Rep1 >, _Period > operator*(const _Rep1 &__s, const duration< _Rep2, _Period > &__d)
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
std::forward_as_tuple
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr piecewise_construct_t piecewise_construct
Tag for piecewise construction of std::pair objects.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
__numeric_traits_integer< _Tp > __int_traits
Convenience alias for __numeric_traits<integer-type>.
constexpr _Iterator __base(_Iterator __it)
Primary class template, tuple.
Define a member typedef type to one of two argument types.
Define a member typedef type only if a boolean constant is true.
Uniform interface to all allocator types.
Traits class for iterators.
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Struct holding two objects of arbitrary type.
Uniform interface to C++98 and C++11 allocators.